Works great and has no side effects that I have found. Larry
On 6/5/07, Sascha L. Teichmann <[EMAIL PROTECTED]> wrote: > The NPE comes from BasicStylePanel#findEquivalentItem() > Therefore it would vote for make this one more bullet proof. > > See my new patch. I would leave BasicStyle#getFillPattern() > untouched. > > > Larry Becker schrieb: > > It seem to work when I modify getFillPattern in BasicStyle to include > > the check for null and then initialize the fillPattern as before. > > > > public Paint getFillPattern() { > > if (fillPattern == null) { > > fillPattern = WKTFillPattern.createDiagonalStripePattern(4, > > 2, false, true); > > } > > return fillPattern; > > } > > > > The only side effect is that initially in the Change Styles Rendering > > Tab, the Fill pattern is 0 grey. However when you check the Fill > > pattern check box, it turns solid black and works correctly so I don't > > see this as an issue. > > > > regards, > > Larry > > > > On 6/5/07, Larry Becker <[EMAIL PROTECTED]> wrote: > >> Sascha, > >> > >> I implemented your changes in SkyJUMP to BasicStyle and > >> BasicStylePanel. It worked when I opened a task with colour theming > >> already set up, but when I tried to add a new layer and chose Change > >> Styles, I got: > >> > >> java.lang.NullPointerException > >> at > >> com.vividsolutions.jump.workbench.ui.style.BasicStylePanel.findEquivalentItem(BasicStylePanel.java:483) > >> at > >> com.vividsolutions.jump.workbench.ui.style.BasicStylePanel.setBasicStyle(BasicStylePanel.java:459) > >> at > >> com.vividsolutions.jump.workbench.ui.style.RenderingStylePanel.<init>(RenderingStylePanel.java:189) > >> at > >> com.vividsolutions.jump.workbench.ui.style.ChangeStylesPlugIn.execute(ChangeStylesPlugIn.java:87) > >> > >> regards, > >> Larry > >> > >> On 6/5/07, Paul Austin <[EMAIL PROTECTED]> wrote: > >>> Sascha, > >>> > >>> In your comments you said you added an if statement but used the ?: > >>> operator, I think in this case a proper if {} else {} statement would be > >>> much more readable. I think that the ?: operator should be used > >>> minimally, for example if you were generating HTML and wanted to > >>> optionally include an attribute on a tag. > >>> > >>> + fill = fill == null > >>> + ? fillPatternComboBox.getItemAt(0) > >>> + : findEquivalentItem(fill, fillPatternComboBox); > >>> > >>> BTW does this improvement only improve speed if you have a themed layer > >>> or will it speed up all layers? > >>> > >>> Paul > >>> > >>> ------------------------------------------------------------------------- > >>> This SF.net email is sponsored by DB2 Express > >>> Download DB2 Express C - the FREE version of DB2 express and take > >>> control of your XML. No limits. Just data. Click to get it now. > >>> http://sourceforge.net/powerbar/db2/ > >>> _______________________________________________ > >>> Jump-pilot-devel mailing list > >>> Jump-pilot-devel@lists.sourceforge.net > >>> https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel > >>> > >> > >> -- > >> http://amusingprogrammer.blogspot.com/ > >> > > > > > > Index: src/com/vividsolutions/jump/workbench/ui/style/BasicStylePanel.java > =================================================================== > RCS file: > /cvsroot/jump-pilot/openjump/src/com/vividsolutions/jump/workbench/ui/style/BasicStylePanel.java,v > retrieving revision 1.4 > diff -u -r1.4 BasicStylePanel.java > --- src/com/vividsolutions/jump/workbench/ui/style/BasicStylePanel.java 13 > May 2007 13:24:55 -0000 1.4 > +++ src/com/vividsolutions/jump/workbench/ui/style/BasicStylePanel.java 5 Jun > 2007 17:57:16 -0000 > @@ -457,8 +457,12 @@ > //Because fillPatternComboBox is not editable, we must use > findEquivalentItem, > //otherwise the combobox gets confused and a stack overflow occurs > //if the two items are equal but not == . [Jon Aquino] > - fillPatternComboBox.setSelectedItem(findEquivalentItem( > - basicStyle.getFillPattern(), fillPatternComboBox)); > + > + Object fill = > findEquivalentItem(basicStyle.getFillPattern(), fillPatternComboBox); > + > + if (fill != null) > + > fillPatternComboBox.setSelectedItem(fill); > + > updateControls(); > } > > @@ -477,6 +481,16 @@ > } > > private Object findEquivalentItem(Object item, JComboBox comboBox) { > + > + if (comboBox == null) > + return null; > + > + if (item == null) { > + return comboBox.getItemCount() > 0 > + ? comboBox.getItemAt(0) > + : null; > + } > + > for (int i = 0; i < comboBox.getItemCount(); i++) { > if (item.equals(comboBox.getItemAt(i))) { > return comboBox.getItemAt(i); > > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Jump-pilot-devel mailing list > Jump-pilot-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel > > -- http://amusingprogrammer.blogspot.com/ ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ Jump-pilot-devel mailing list Jump-pilot-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel