RPTools.net

Discussion and Support

Skip to content

It is currently Sun Sep 24, 2017 4:08 pm 






Reply to topic  [ 3 posts ] 

Previous topic | Next topic 

  Print view

Author Message
User avatar  Offline
Kobold
 
Joined: Tue May 29, 2012 1:41 am
Posts: 4
 Post subject: Patch for removal of broken code
PostPosted: Thu Jun 28, 2012 9:27 pm 
This patch includes the removal of some a bad distance method which is quite likely part of the java.lang.IllegalArgumentException thrown when using Java 7. Function is removed since a corresponding method exists within the Point2D class.

This fix was originally discussed in this thread.

The following is a patch file for the maptool trunk.
Code:
Index: src/net/rptools/maptool/client/ui/zone/vbl/AreaMeta.java
===================================================================
--- src/net/rptools/maptool/client/ui/zone/vbl/AreaMeta.java   (revision 5862)
+++ src/net/rptools/maptool/client/ui/zone/vbl/AreaMeta.java   (working copy)
@@ -87,7 +87,7 @@
       // TODO: This works ... in concept, but in practice it can create holes that pop outside of their parent bounds
       // for really thin diagonal lines.  At some point this could be moved to a post processing step, after the
       // islands have been placed into their oceans.  But that's an optimization for another day
-//      if (lastPointNode != null && GeometryUtil.getDistance(lastPointNode.point, new Point2D.Float(x, y)) < 1.5) {
+//      if (lastPointNode != null && lastPointNode.point.distance(new Point2D.Float(x, y)) < 1.5) {
 //         skippedPoints++;
 //         return;
 //      }
Index: src/net/rptools/maptool/client/ui/zone/vbl/VisibleAreaSegment.java
===================================================================
--- src/net/rptools/maptool/client/ui/zone/vbl/VisibleAreaSegment.java   (revision 5862)
+++ src/net/rptools/maptool/client/ui/zone/vbl/VisibleAreaSegment.java   (working copy)
@@ -18,7 +18,6 @@
 import java.util.LinkedList;
 import java.util.List;
 
-import net.rptools.lib.GeometryUtil;
 import net.rptools.maptool.util.GraphicsUtil;
 
 public class VisibleAreaSegment implements Comparable<VisibleAreaSegment> {
@@ -40,7 +39,7 @@
    }
 
    public double getDistanceFromOrigin() {
-      return GeometryUtil.getDistance(getCenterPoint(), origin);
+      return origin.distance(getCenterPoint());
    }
 
    public Point2D getCenterPoint() {
@@ -115,8 +114,9 @@
          throw new NullPointerException("compareTo() parameter is null");
 
       double odist = o.getDistanceFromOrigin();
+      double dist = getDistanceFromOrigin();
       // FJE Wouldn't it work to just use the following?
-      //      return getDistanceFromOrigin() - odist;
-      return getDistanceFromOrigin() < odist ? -1 : getDistanceFromOrigin() == odist ? 0 : 1;
+      //      return dist - odist;
+      return dist < odist ? -1 : dist == odist ? 0 : 1;
    }
 }


And the following is for the rptool trunk
Code:
Index: src/net/rptools/lib/GeometryUtil.java
===================================================================
--- src/net/rptools/lib/GeometryUtil.java   (revision 5862)
+++ src/net/rptools/lib/GeometryUtil.java   (working copy)
@@ -95,12 +95,6 @@
       }
    }
 
-   public static double getDistance(Point2D p1, Point2D p2) {
-      double a = p2.getX() - p1.getX();
-      double b = p2.getY() - p1.getY();
-      return Math.abs(Math.sqrt(a+b));
-   }
-   
    public static Set<Line2D> getFrontFaces(PointNode nodeList, Point2D origin) {
       
       Set<Line2D> frontFaces = new HashSet<Line2D>();

If I'm making any mistake about how I'm submitting these patch files, please let me know. This is my first time submitting a patch.

I will also send these patch files to Azhrei.


Top
 Profile  
 
 Offline
Dragon
 
Joined: Sun Sep 04, 2011 6:01 am
Posts: 260
 Post subject: Re: Patch for removal of broken code
PostPosted: Fri Jun 29, 2012 10:38 pm 
Thanks. Patches are preferred as text file attachment. But Azhrei can handle your way of delivery, I know that from experience :-)


Top
 Profile  
 
User avatar  Offline
Site Admin
 
Joined: Mon Jun 12, 2006 12:20 pm
Posts: 12102
Location: Tampa, FL
 Post subject: Re: Patch for removal of broken code
PostPosted: Sat Jun 30, 2012 6:34 pm 
I've received the patch and will commit it once I've looked at it. Just had two wisdom teeth pulled so it may be a day or two before I get to it. :)


Top
 Profile  
 
Display posts from previous:  Sort by  
Reply to topic  [ 3 posts ] 

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:

Who is online

In total there are 2 users online :: 0 registered, 0 hidden and 2 guests (based on users active over the past 5 minutes)
Most users ever online was 243 on Sun Nov 04, 2012 6:14 am

Users browsing this forum: No registered users and 2 guests





Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group

Style based on Andreas08 by Andreas Viklund

Style by Elizabeth Shulman