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

The following examples show how to use javax.swing.text.View#Y_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: WrapEditorKit.java    From PacketProxy with Apache License 2.0 6 votes vote down vote up
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 CustomParagraphView(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);
		}
	}
	return new LabelView(elem);
}
 
Example 2
Source File: CustomTextPane.java    From mzmine3 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public View create(final Element element) {
  final String kind = element.getName();
  if (kind != null) {
    switch (kind) {
      case AbstractDocument.ContentElementName:
        return new WrapLabelView(element);
      case AbstractDocument.ParagraphElementName:
        return new ParagraphView(element);
      case AbstractDocument.SectionElementName:
        return new BoxView(element, View.Y_AXIS);
      case StyleConstants.ComponentElementName:
        return new ComponentView(element);
      case StyleConstants.IconElementName:
        return new IconView(element);
    }
  }

  // Default to text display.
  return new LabelView(element);
}
 
Example 3
Source File: MainPanel.java    From java-swing-tips with MIT License 6 votes vote down vote up
@Override public View create(Element elem) {
  switch (elem.getName()) {
    // case AbstractDocument.ContentElementName:
    //   return new LabelView(elem);
    case AbstractDocument.ParagraphElementName:
      return new ParagraphWithEopmView(elem);
    case AbstractDocument.SectionElementName:
      return new BoxView(elem, View.Y_AXIS);
    case StyleConstants.ComponentElementName:
      return new ComponentView(elem);
    case StyleConstants.IconElementName:
      return new IconView(elem);
    default:
      return new LabelView(elem);
  }
}
 
Example 4
Source File: JIMSendTextPane.java    From oim-fx with MIT License 6 votes vote down vote up
public View create(Element elem) {
	String kind = elem.getName();
	if (kind != null) {
		if (kind.equals(AbstractDocument.ContentElementName)) {
			return new WarpLabelView(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);
		}
	}

	// default to text display
	return new LabelView(elem);
}
 
Example 5
Source File: MainPanel.java    From java-swing-tips with MIT License 6 votes vote down vote up
@Override public View create(Element elem) {
  switch (elem.getName()) {
    // case AbstractDocument.ContentElementName:
    //   return new LabelView(elem);
    case AbstractDocument.ParagraphElementName:
      return new ParagraphWithEndMarkView(elem);
    case AbstractDocument.SectionElementName:
      return new BoxView(elem, View.Y_AXIS);
    case StyleConstants.ComponentElementName:
      return new ComponentView(elem);
    case StyleConstants.IconElementName:
      return new IconView(elem);
    default:
      return new LabelView(elem);
  }
}
 
Example 6
Source File: MainPanel.java    From java-swing-tips with MIT License 6 votes vote down vote up
@Override public View create(Element elem) {
  switch (elem.getName()) {
    // case AbstractDocument.ContentElementName:
    //   return new LabelView(elem);
    case AbstractDocument.ParagraphElementName:
      return new ParagraphView(elem) {
        @Override protected short getBottomInset() {
          return 5;
        }
      };
    case AbstractDocument.SectionElementName:
      return new BoxView(elem, View.Y_AXIS);
    case StyleConstants.ComponentElementName:
      return new ComponentView(elem);
    case StyleConstants.IconElementName:
      return new IconView(elem);
    default:
      return new LabelView(elem);
  }
}
 
Example 7
Source File: NumberedViewFactory.java    From spotbugs with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public View create(Element elem) {
    String kind = elem.getName();
    // System.out.println("Kind: " + kind);
    if (kind != null) {
        if (AbstractDocument.ContentElementName.equals(kind)) {
            return new LabelView(elem);
        } else if (AbstractDocument.ParagraphElementName.equals(kind)) {
            return new NumberedParagraphView(elem, highlight);
        } else if (AbstractDocument.SectionElementName.equals(kind)) {
            return new NoWrapBoxView(elem, View.Y_AXIS);
        } else if (StyleConstants.ComponentElementName.equals(kind)) {
            return new ComponentView(elem);
        } else if (StyleConstants.IconElementName.equals(kind)) {
            return new IconView(elem);
        }
    }
    // default to text display
    return new LabelView(elem);
}
 
Example 8
Source File: MainPanel.java    From java-swing-tips with MIT License 6 votes vote down vote up
@Override public ViewFactory getViewFactory() {
  return new HTMLFactory() {
    @Override public View create(Element elem) {
      AttributeSet attrs = elem.getAttributes();
      Object elementName = attrs.getAttribute(AbstractDocument.ElementNameAttribute);
      Object o = Objects.isNull(elementName) ? attrs.getAttribute(StyleConstants.NameAttribute) : null;
      if (o instanceof HTML.Tag) {
        HTML.Tag kind = (HTML.Tag) o;
        if (kind == HTML.Tag.DIV) {
          return new BlockView(elem, View.Y_AXIS) {
            @Override public String getToolTipText(float x, float y, Shape allocation) {
              String s = super.getToolTipText(x, y, allocation);
              if (Objects.isNull(s)) {
                s = Objects.toString(getElement().getAttributes().getAttribute(HTML.Attribute.TITLE));
              }
              return s;
            }
          };
        }
      }
      return super.create(elem);
    }
  };
}
 
Example 9
Source File: WrapEditorKit.java    From hortonmachine with GNU General Public License v3.0 6 votes vote down vote up
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);
        }
    }

    // default to text display
    return new LabelView(elem);
}
 
Example 10
Source File: KTextEdit.java    From stendhal with GNU General Public License v2.0 6 votes vote down vote up
@Override
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);
		}
	}

	// default to text display
	return new LabelView(elem);
}
 
Example 11
Source File: CustomTextPane.java    From mzmine2 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public View create(final Element element) {
  final String kind = element.getName();
  if (kind != null) {
    switch (kind) {
      case AbstractDocument.ContentElementName:
        return new WrapLabelView(element);
      case AbstractDocument.ParagraphElementName:
        return new ParagraphView(element);
      case AbstractDocument.SectionElementName:
        return new BoxView(element, View.Y_AXIS);
      case StyleConstants.ComponentElementName:
        return new ComponentView(element);
      case StyleConstants.IconElementName:
        return new IconView(element);
    }
  }

  // Default to text display.
  return new LabelView(element);
}
 
Example 12
Source File: GlyphVectorEditorKit.java    From PolyGlot with MIT License 6 votes vote down vote up
public View create(Element elem) {
    String kind = elem.getName();
    if (kind != null) {
        if (kind.equals(AbstractDocument.ContentElementName)) {
            return new PainterLabelView(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);
        }
    }

    // default to text display
    return new LabelView(elem);
}
 
Example 13
Source File: ViewUtilities.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example 14
Source File: KTextEdit.java    From stendhal with GNU General Public License v2.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 15
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 16
Source File: WrapEditorKit.java    From hortonmachine with GNU General Public License v3.0 5 votes vote down vote up
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 17
Source File: GapBoxView.java    From netbeans with Apache License 2.0 4 votes vote down vote up
protected final int getLayoutStateMinorAxis() {
    return (isStatusBitsNonZero(LAYOUT_STATE_X_MAJOR_AXIS_BIT))
        ? View.Y_AXIS 
        : View.X_AXIS;
}
 
Example 18
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 19
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 20
Source File: GapBoxView.java    From netbeans with Apache License 2.0 2 votes vote down vote up
/**
 * Fetch the minor axis (the axis orthoginal
 * to the tiled axis).  This will have a value of
 * either X_AXIS or Y_AXIS.
 */
public final int getMinorAxis() {
    return isXMajorAxis() ? View.Y_AXIS : View.X_AXIS;
}