uDIG
  1. uDIG
  2. UDIG-1374

Inaccurate value for the line width in Change Style dialog

    Details

      Description

      The error occurs in Change Style dialog at the Line width combo. The selected value often becomes -1.

      For example, if I select 5 in the width combo, then click apply, the line changes OK.
      But then if I click to configure something else, the width line combo value becomes -1.

      I figured there's something wrong with SLDs.width(Stroke) method in UDIG, as it always returns -1 and the Stroke parameter is OK.

        Issue Links

          Activity

          Hide
          Jody Garnett added a comment -
          That is not cool; -1 is the value used to indicate that no line width was found :-( You may need to set a debugger breakpoint and see exactly where it is failing.
          Show
          Jody Garnett added a comment - That is not cool; -1 is the value used to indicate that no line width was found :-( You may need to set a debugger breakpoint and see exactly where it is failing.
          Hide
          Maria Comanescu added a comment -
          I set a breakpoint in method *setStroke*, class StrokeViewer.java(net.refractions.udig.style.sld) at line:
          SLDs.width(line);

          Description of line parameter
          Show
          Maria Comanescu added a comment - I set a breakpoint in method *setStroke*, class StrokeViewer.java(net.refractions.udig.style.sld) at line: SLDs.width(line); Description of line parameter
          Hide
          Maria Comanescu added a comment -
          I appologize for the previous comment, I pressed Add by mistake :)

          So, I set a breakpoint in method setStroke, class StrokeViewer.java (net.refractions.udig.style.sld package) at line:

          SLDs.width(line); (line 223 in my code)

          The line parameter looks like this in Variables description:
          org.geotools.styling.StrokeImpl:
          Color #FF00FF
          Width 3.0
          Opacity 0.75
          LineCap butt
          LineJoin miter
          Dash Array [F@155b814
          Dash Offset 0.0
          Fill Graphic null
          Stroke Graphic null

          The width is set (3.0) .
          Still the result of expression "SLDs.width(line)" is -1.

          Now, SLDs class extends SLD class, which I have in gt2-main.jar
          So the width function in SLD looks like this:

          public static int width(Stroke stroke) {
                  if (stroke == null) {
                      return NOTFOUND;
                  }

                  return intValue(stroke.getWidth());
              }

              public static int intValue(Expression expr) {
                  return Filters.asInt(expr);
              }

          I guess the error occurs when the Filters.asInt(expr) method attempts to get an int value out of an expression containing "3.0" literal, which is more like double literal :)

          Fix method:
          I replaced in StrokeViewer.java line "SLDs.width(line)" with "this.width = Filters.asDouble(line.getWidth())" and it works fine.

          In my udig code I found 4 "SLD.width" method calls:
          - 2 in StrokeViewer.java (net.refractions.udig.style.sld)
          - 2 in Drawing.java (net.refractions.udig.ui)
          I replaced them all.

          So, I think there are two methods to fix this: either change udig code or change SLD class in geotools; but I'm not sure which one is the best fix
          Show
          Maria Comanescu added a comment - I appologize for the previous comment, I pressed Add by mistake :) So, I set a breakpoint in method setStroke, class StrokeViewer.java (net.refractions.udig.style.sld package) at line: SLDs.width(line); (line 223 in my code) The line parameter looks like this in Variables description: org.geotools.styling.StrokeImpl: Color #FF00FF Width 3.0 Opacity 0.75 LineCap butt LineJoin miter Dash Array [ F@155b814 Dash Offset 0.0 Fill Graphic null Stroke Graphic null The width is set (3.0) . Still the result of expression "SLDs.width(line)" is -1. Now, SLDs class extends SLD class, which I have in gt2-main.jar So the width function in SLD looks like this: public static int width(Stroke stroke) {         if (stroke == null) {             return NOTFOUND;         }         return intValue(stroke.getWidth());     }     public static int intValue(Expression expr) {         return Filters.asInt(expr);     } I guess the error occurs when the Filters.asInt(expr) method attempts to get an int value out of an expression containing "3.0" literal, which is more like double literal :) Fix method: I replaced in StrokeViewer.java line "SLDs.width(line)" with "this.width = Filters.asDouble(line.getWidth())" and it works fine. In my udig code I found 4 "SLD.width" method calls: - 2 in StrokeViewer.java (net.refractions.udig.style.sld) - 2 in Drawing.java (net.refractions.udig.ui) I replaced them all. So, I think there are two methods to fix this: either change udig code or change SLD class in geotools; but I'm not sure which one is the best fix
          Hide
          Jody Garnett added a comment -
          Maria the problem is actually using a double for width; the specification calls for integer.

          For now I will fix up SLD.width( Expression ) code of Use expr.evaulate( null, Integer.class ) - this will let the expression subsystem convert from Double to Integer for us.
          Show
          Jody Garnett added a comment - Maria the problem is actually using a double for width; the specification calls for integer. For now I will fix up SLD.width( Expression ) code of Use expr.evaulate( null, Integer.class ) - this will let the expression subsystem convert from Double to Integer for us.

            People

            • Assignee:
              Unassigned
              Reporter:
              Maria Comanescu
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: