Zbyszek Malec
5/18/2007 12:11:00 PM
Dnia 18 May 2007 01:14:55 -0700, Verne napisa3(a):
> int termNumber = 0;
> private void placeBlocks(DObject obj, int deep){
> deep+=1;
> Vector v = obj.getAllChildren();
Musi bya Vector? Nie mo?e bya ArrayList? Zyska3by? pare milisekund. Je?li
to jest 1.5 to dodatkowo lista generyczna, czyli:
List<DObject> children = obj.getAllChildren();
> DObject next = null;
> for(ListIterator it = v.listIterator();it.hasNext();){
> next = (DObject)it.next();
Je?eli to jest java 1.5 to proponuje:
for(DObject child : children) {
> if(next.getAllChildren().size() == 0){
>
> next.setx((SPACEX + next.getWidth()) * (termNumber) +
> next.getWidth()/2);
> next.sety((deep+1) * (next.getHeight() + SPACEY));
> next.setFormated(true);
> termNumber++;
> continue;
> }
> placeBlocks(next,deep);
> }
> if(obj.areAllChildsFormated() && !obj.isFormated()){
> obj.setx(obj.getChildsMidddleX());
> obj.sety(obj.getChildsMidddleY() - obj.getHeight() - SPACEY);
> obj.setFormated(true);
> }
> }
Dalej nie pokaza3e? jak malujesz. W ka?dym razie kiedy wywo3ujesz t?
metode? Za ka?dym odmalowaniem? Ja bym sobie zrobi3 jaki? wewnetrzny bufor
do malowania (BufferedImage) i przy zmianie struktury drzewa odmalowywa3bym
ten bufor, a w metodzie odmalowywania komponentu wrzuca3bym ten bufor na
ekran. W ten sposób nie powiene? miea wiekszych problemów z wydajno?ci?.
--
Zbyszek Malec Ustronie 104
jid: zbyszanna@chrome.pl