下面列出了javax.swing.text.html.ImageView#javax.swing.text.LabelView 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
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);
}
@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);
}
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);
}
@Override
public View create(Element elem) {
View v = super.create(elem);
if (v instanceof LabelView) {
// the javax.swing.text.html.BRView (representing <br> tag) is a
// LabelView but must not be handled
// by a WrapLabelView. As BRView is private, check the html tag from
// elem attribute
Object o = elem.getAttributes().getAttribute(StyleConstants.NameAttribute);
if ((o instanceof HTML.Tag) && o == HTML.Tag.BR) {
return new BRView(elem);
}
}
if (v instanceof InlineView) {
return new WrapInlineView(elem);
} else if (v instanceof ParagraphView) {
return new WrapParagraphView(elem);
}
return v;
}
public View create(Element elem) {
String kind = elem.getName();
if (kind != null) {
if (kind.equals(AbstractDocument.ContentElementName)) {
return new LabelView(elem);
} else if (kind.equals(AbstractDocument.ParagraphElementName)) {
return null;
} else if (kind.equals(AbstractDocument.SectionElementName)) {
return new DocumentView(elem);
} else if (kind.equals(StyleConstants.ComponentElementName)) {
return new ComponentView(elem);
} else if (kind.equals(StyleConstants.IconElementName)) {
return new IconView(elem);
}
}
return null;
}
@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);
}
@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);
}
@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);
}
@Override public View create(Element elem) {
switch (elem.getName()) {
// case AbstractDocument.ContentElementName:
// return new LabelView(elem);
case AbstractDocument.ParagraphElementName:
return new NoWrapParagraphView(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);
}
}
@Override public ViewFactory getViewFactory() {
return new HTMLEditorKit.HTMLFactory() {
@Override public View create(Element elem) {
View view = super.create(elem);
if (view instanceof LabelView) {
System.out.println("debug: " + view.getAlignment(View.Y_AXIS));
}
AttributeSet attrs = elem.getAttributes();
Object elementName = attrs.getAttribute(AbstractDocument.ElementNameAttribute);
Object o = Objects.nonNull(elementName) ? null : attrs.getAttribute(StyleConstants.NameAttribute);
if (o instanceof HTML.Tag) {
HTML.Tag kind = (HTML.Tag) o;
if (kind == HTML.Tag.IMG) {
return new ImageView(elem) {
@Override public float getAlignment(int axis) {
// .8125f magic number...
return axis == View.Y_AXIS ? .8125f : super.getAlignment(axis);
}
};
}
}
return view;
}
};
}
@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);
}
}
@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);
}
}
@Override public View create(Element elem) {
switch (elem.getName()) {
// case AbstractDocument.ContentElementName:
// return new LabelView(elem);
case AbstractDocument.ParagraphElementName:
return new NoWrapParagraphView(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);
}
}
@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);
}
}
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);
}
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);
}
@Override
public javax.swing.text.View create(Element elem) {
String kind = elem.getName();
if (kind != null) {
switch (kind) {
case AbstractDocument.ContentElementName:
return new WrapLabelView(elem);
case AbstractDocument.ParagraphElementName:
return new ParagraphView(elem);
case AbstractDocument.SectionElementName:
return new BoxView(elem, javax.swing.text.View.Y_AXIS);
case StyleConstants.ComponentElementName:
return new ComponentView(elem);
case StyleConstants.IconElementName:
return new IconView(elem);
}
}
// default to text display
return new LabelView(elem);
}
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 WarpIconView(elem);
}
}
// default to text display
return new LabelView(elem);
}