Сигсерчик, кажется, работает нормально, но теперь мне нужно сделать ViewFactory .
Тестовая строка анализируется таким образом, что мы получаем следующую структуру:
Проанализируется, что мы получаем следующую структуру:
.
Код: Выделить всё
root
| - paragraph
| | - text
| - list
| | - paragraph
| | | - text
| | | - code span
| | | - text
Text is converted to my custom View, which is also OK.
List is converted to my custom CompositeView, which is the main problem, as components on it just do not show up (at все). < /p>
У меня есть следующие классы: < /p>
Код: Выделить всё
class MDListView extends MarkdownContainerView{
public MDListView(MDList e,ViewFactory f){
super(e);
}
public float getPreferredSpan(int axis){
//Returns a correct non-empty rectangle.
}
public Shape getChildAllocation(int index,Shape s){
Rectangle r=s.getBounds();
return new Rectangle(r.x,r.y+(int)(index*getPreferredSpan(Y_AXIS)/getViewCount()),r.width,r.height/getViewCount());
}
public void replace(int offset,int length,View[]views){
super.replace(offset,length,views);
//Some additional logic
}
protected void childAllocation(int index,Rectangle a){
a.setBounds(getChildAllocation(index,a).getBounds());
}
}
< /code>
и < /p>
static abstract class MarkdownContainerView extends CompositeView{
public MarkdownContainerView(Element e){
super(e);
}
public void paint(Graphics g,Shape allocation){
for(int i=0;i
Подробнее здесь: [url]https://stackoverflow.com/questions/79666355/how-do-i-implement-compositeview-so-it-displays-the-components-correctly[/url]