public View create(Element elem) {
String kind = elem.getName();
if (kind != null) {
if (kind.equals(AbstractDocument.ContentElementName)) {
return new LabelView(elem) {
@Override
public int getBreakWeight(int axis, float pos, float len) {
return 0;
}
};
} else if (kind.equals(AbstractDocument.ParagraphElementName)) {
return new ParagraphView(elem) {
@Override
public int getBreakWeight(int axis, float pos, float len) {
return 0;
}
};
} else if (kind.equals(AbstractDocument.SectionElementName)) {
return new BoxView(elem, View.Y_AXIS);
} else if (kind.equals(StyleConstants.ComponentElementName)) {
return new ComponentView(elem) {
@Override
public int getBreakWeight(int axis, float pos, float len) {
return 0;
}
};
} else if (kind.equals(StyleConstants.IconElementName)) {
return new IconView(elem);
}
}
return new LabelView(elem) {
@Override
public int getBreakWeight(int axis, float pos, float len) {
return 0;
}