From: Doug P. <do...@4h...> - 2012-11-28 02:53:52
|
Hi Kevin - It looks like the assumption is that to even be able to print via that strategy it must fit within one page. The precondition is not being satisfied due to the subordinate component strategies not taking into account margins. So they think it will fit and add it to the list. But because of that 'if' check, never remove. If the other component strategies are fixed so they only add components that fit, then that 'if' check should be deleted (and thus will remove the infinite loop). BTW, your solution won't work either as it doesn't take into account margins nor if an images spans many, many pages. There's logic elsewhere to handle those situations and we should continue to use them. Not sure how soon, but I'll try to create a pull request with this changed. Regards, Doug On Mon, Nov 19, 2012 at 9:26 PM, Kevin Ruland <kr...@su...> wrote: > > This is what I came up with. It's ugly.... > > diff --git > a/core/src/net/sf/openrocket/gui/print/visitor/PageFitPrintStrategy.java > b/core/src/net/sf/openrocket/gui/print/visitor/PageFitPrintStrategy.java > index 10ca735..69f3275 100644 > --- > a/core/src/net/sf/openrocket/gui/print/visitor/PageFitPrintStrategy.java > +++ > b/core/src/net/sf/openrocket/gui/print/visitor/PageFitPrintStrategy.java > @@ -90,7 +90,9 @@ > > Collections.sort(componentToPrint); > > - while (componentToPrint.size() > 0) { > + boolean somethingPrinted = true; > + while (componentToPrint.size() > 0 && somethingPrinted) { > + somethingPrinted = false; > int pageY = marginY; > Boolean anyAddedToRow; > > @@ -113,6 +115,7 @@ > pageY = rowY + dim.height + marginY; > } > entry.remove(); > + somethingPrinted = true; > component.print(g2); > anyAddedToRow = true; > } > @@ -121,7 +124,21 @@ > } while (anyAddedToRow); > > g2.dispose(); > - document.newPage(); > + if ( somethingPrinted ) { > + document.newPage(); > + } > + } > + > + // Now print the big things. > + if ( componentToPrint.size() > 0 ) { > + ListIterator<PrintableComponent> entry = > componentToPrint.listIterator(); > + while( entry.hasNext() ) { > + PrintableComponent component = entry.next(); > + Graphics2D g2 = cb.createGraphics(pageSize.width, > pageSize.height); > + component.print(g2); > + g2.dispose(); > + document.newPage(); > + } > > } > } > > > On 11/19/2012 8:58 PM, Kevin Ruland wrote: > > Hi guys, > > There's an infinte loop in PageFitPrintStrategy.fitPrintComponents() which > is demonstrated by the attached ork file. I believe the particular > situation is that the fins on this rocket are too bit to print on a single > sheet and therefore are not removed from the array componentToPrint. > > I know this was added in release 12.09 and am hoping somebody knows how to > correct it. > > Kevin > > > ------------------------------------------------------------------------------ > Monitor your physical, virtual and cloud infrastructure from a single > web console. Get in-depth insight into apps, servers, databases, vmware, > SAP, cloud infrastructure, etc. Download 30-day Free Trial. > Pricing starts from $795 for 25 servers or applications!http://p.sf.net/sfu/zoho_dev2dev_nov > > > > _______________________________________________ > Openrocket-devel mailing lis...@li...https://lists.sourceforge.net/lists/listinfo/openrocket-devel > > > > > ------------------------------------------------------------------------------ > Monitor your physical, virtual and cloud infrastructure from a single > web console. Get in-depth insight into apps, servers, databases, vmware, > SAP, cloud infrastructure, etc. Download 30-day Free Trial. > Pricing starts from $795 for 25 servers or applications! > http://p.sf.net/sfu/zoho_dev2dev_nov > _______________________________________________ > Openrocket-devel mailing list > Ope...@li... > https://lists.sourceforge.net/lists/listinfo/openrocket-devel > > |