So, that should fix it ....

Added an 'if (fillPattern == null)' to the GUI and removed
the ultra expensive pattern creation from BasicStyle.

The construction of 100,000 BasicStyle objects now take
0.267 secs. before it took 27.357 seconds.

Find attached patches against BasicStyle and BasicStylePanel.

If you like them I would commit them to the core.

regards, Sascha

Sascha L. Teichmann schrieb:
> I'll try to remove the GUI dependencies for
> a preset fill pattern, but I also want to make
> BasicStyle more light weighted. I'll have a look at
> it later.
> 
> - Sascha
> 
> Larry Becker schrieb:
>> Hi Sascha,
>>
>>    Great work!  You have found the cause of another annoying slowdown.
>>  I first noticed this doing the burlulc benchark with Colour Theming.
>> It really needs to be fixed.  I noticed that it is fixed in Kosmo
>> already, however their model is probably different.
>>
>>   Fixing BasicStyle to use a more lightweight fill pattern
>> construction method would be a good idea.  I'm not sure why we can't
>> just have every new instance point to the same default copy stashed
>> somewhere.
>>
>> regards,
>> Larry
>>
>> On 6/5/07, Sascha L. Teichmann <[EMAIL PROTECTED]> wrote:
>>> Hi together!
>>>
>>> I was wondering why it takes so long to enable
>>> Colour Theming when working with layers with a
>>> higher number of features.
>>>
>>> If you open the "Changes Styles", choose tab
>>> "Colour Theming" and check "Enable colour theming".
>>>
>>> If I do this with a 36,000+ polygon shape file it
>>> takes about 24(!) seconds before I can go on.
>>> (AMD 1.2 GHz/Athlon-T-Bird, GNU/Linux, Java6)
>>>
>>> I profiled it a bit and found out that almost
>>> the whole time is spend with constructing simple
>>> BasicStyle [1] objects. In this concrete case the problem
>>> can be solved if you reuse already created BasicStyle objects.
>>> After this fix the 24 secs go down to 0.001 secs!!!
>>> I can send a patch which does this.
>>>
>>> The main problem is the expensive construction of
>>> the BasicStyle objects. When they are created
>>> a WKTFillPattern is created too. Always! Even if it
>>> is not used! The construction of such a fill pattern
>>> involves a lot of string parsing with a WKTReader,
>>> math, etc. A little bit heavy weighted in my opinion.
>>> Jon has a comment in BasicStyle that says it is done
>>> to make the GUI happy. This has to be done better!
>>> Because BasicStyle objects are constructed very often
>>> in *JUMP I cannot estimate the overall performance
>>> lost coming with this issue.
>>>
>>> Comments?
>>>
>>> - Sascha
>>>
>>> [1] com.vividsolutions.jump.workbench.ui.renderer.style.BasicStyle
>>>
>>> -------------------------------------------------------------------------
>>> 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
>>> [email protected]
>>> https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel
>>>
>>
> 
> -------------------------------------------------------------------------
> 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
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel
Index: src/com/vividsolutions/jump/workbench/ui/renderer/style/BasicStyle.java
===================================================================
RCS file: 
/cvsroot/jump-pilot/openjump/src/com/vividsolutions/jump/workbench/ui/renderer/style/BasicStyle.java,v
retrieving revision 1.1
diff -u -r1.1 BasicStyle.java
--- src/com/vividsolutions/jump/workbench/ui/renderer/style/BasicStyle.java     
16 Jun 2005 22:53:48 -0000      1.1
+++ src/com/vividsolutions/jump/workbench/ui/renderer/style/BasicStyle.java     
5 Jun 2007 16:27:42 -0000
@@ -56,18 +56,23 @@
     private boolean renderingLinePattern = false;
     private boolean renderingFillPattern = false;
 
+               public static final Color       DEFAULT_FILL_COLOR  = new 
Color(0, 0, 0, 255);
+               public static final Color       DEFAULT_LINE_COLOR  = 
DEFAULT_FILL_COLOR;
+               public static final BasicStroke DEFAULT_FILL_STROKE = new 
BasicStroke(1);
+
     //The important thing here is the initial alpha. [Jon Aquino]
-    private Color fillColor = new Color(0, 0, 0, 255);
-    private Color lineColor = new Color(0, 0, 0, 255);
+    private Color fillColor = DEFAULT_FILL_COLOR;
+    private Color lineColor = DEFAULT_LINE_COLOR;
+
     private BasicStroke lineStroke;
-    private Stroke fillStroke = new BasicStroke(1);
+    private Stroke fillStroke = DEFAULT_FILL_STROKE;
     private boolean enabled = true;
     private String linePattern = "3";
 
     //Set fill pattern to something, so that the BasicStylePanel combobox won't
     //start empty. [Jon Aquino]
-    private Paint fillPattern = WKTFillPattern.createDiagonalStripePattern(4,
-            2, false, true);
+               // Fixing the GUI is a better idea! [s-l-teichmann]
+    private Paint fillPattern;
 
     public BasicStyle(Color fillColor) {
         setFillColor(fillColor);
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 16:27:29 -0000
@@ -457,8 +457,14 @@
         //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 = basicStyle.getFillPattern();
+                               fill = fill == null
+                                       ? fillPatternComboBox.getItemAt(0)
+                                       : findEquivalentItem(fill, 
fillPatternComboBox);
+
+                               fillPatternComboBox.setSelectedItem(fill);
+
         updateControls();
     }
 
-------------------------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel

Reply via email to