Thread: [Polycasso-commit] SF.net SVN: polycasso:[245] trunk/polycasso/src/com/mebigfatguy/polycasso (Page 2)
Brought to you by:
dbrosius
|
From: <dbr...@us...> - 2011-08-13 06:12:21
|
Revision: 245
http://polycasso.svn.sourceforge.net/polycasso/?rev=245&view=rev
Author: dbrosius
Date: 2011-08-13 06:12:14 +0000 (Sat, 13 Aug 2011)
Log Message:
-----------
fix the calculation of the changed area
Modified Paths:
--------------
trunk/polycasso/src/com/mebigfatguy/polycasso/DefaultFeedback.java
trunk/polycasso/src/com/mebigfatguy/polycasso/Improver.java
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/DefaultFeedback.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/DefaultFeedback.java 2011-08-07 02:14:13 UTC (rev 244)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/DefaultFeedback.java 2011-08-13 06:12:14 UTC (rev 245)
@@ -79,17 +79,6 @@
score = calculateXMajorScore(testBuffer, previousScore, changedArea);
}
- // uncomment to test whether the grid based scoring is accurate
- // if (Math.random() < 0.05) {
- // long realScore = calculateGridScore(testBuffer, 0, 0, width, height);
- // if (realScore != score.getDelta()) {
- // System.out.println("ERROR: Real: " + realScore + " calc: " + score.getDelta());
- // Score s = calculateYMajorScore(testBuffer, null, null);
- // System.out.println("Full Recalc: " + s.getDelta());
- // calculateScore(testImage, previousScore, changedArea);
- // }
- // }
-
return score;
}
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/Improver.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/Improver.java 2011-08-07 02:14:13 UTC (rev 244)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/Improver.java 2011-08-13 06:12:14 UTC (rev 245)
@@ -63,6 +63,9 @@
* @return the list of polygons
*/
public List<PolygonData> getData() {
+ if (polygons == null) {
+ return new ArrayList<PolygonData>();
+ }
return Collections.<PolygonData>unmodifiableList(polygons);
}
@@ -137,7 +140,7 @@
System.arraycopy(polygon.ypoints, insPos, polygon.ypoints, insPos + 1, numCopyPts);
polygon.ypoints[insPos] = y;
polygon.invalidate();
- changedArea.union(polygon.getBounds());
+ changedArea = changedArea.union(polygon.getBounds());
polygons.set(idx, pd);
} else {
@@ -161,7 +164,7 @@
System.arraycopy(polygon.ypoints, delPos+1, polygon.ypoints, delPos, numPtCopy);
polygon.npoints--;
polygon.invalidate();
- changedArea.union(polygon.getBounds());
+ changedArea = changedArea.union(polygon.getBounds());
polygons.set(idx, pd);
} else {
randomCompleteChange();
@@ -186,7 +189,7 @@
clipToRange(0, imageSize.width, polygon.xpoints[movePos]);
clipToRange(0, imageSize.height, polygon.ypoints[movePos]);
polygon.invalidate();
- changedArea.union(polygon.getBounds());
+ changedArea = changedArea.union(polygon.getBounds());
polygons.set(idx, pd);
}
break;
@@ -206,7 +209,7 @@
polygon.ypoints[rectifyPos] = polygon.ypoints[targetPos];
}
polygon.invalidate();
- changedArea.union(polygon.getBounds());
+ changedArea = changedArea.union(polygon.getBounds());
polygons.set(idx, pd);
}
break;
@@ -240,7 +243,7 @@
polygon.ypoints[i] += (polygon.ypoints[i] < midY) ? shrinkFactor : -shrinkFactor;
}
polygon.invalidate();
- changedArea.union(polygon.getBounds());
+ changedArea = changedArea.union(polygon.getBounds());
polygons.set(idx, pd);
}
break;
@@ -262,7 +265,7 @@
polygon.ypoints[i] = clipToRange(0, imageSize.height, polygon.ypoints[i]);
}
polygon.invalidate();
- changedArea.union(polygon.getBounds());
+ changedArea = changedArea.union(polygon.getBounds());
polygons.set(idx, pd);
}
break;
@@ -283,7 +286,7 @@
polygon.ypoints[i] = clipToRange(0, imageSize.height, polygon.ypoints[i]);
}
polygon.invalidate();
- changedArea.union(polygon.getBounds());
+ changedArea = changedArea.union(polygon.getBounds());
polygons.set(idx, pd);
}
break;
@@ -363,7 +366,7 @@
} else {
changedArea = polygons.get(idx).getPolygon().getBounds();
polygons.set(idx, copyData[idx]);
- changedArea.union(polygons.get(idx).getPolygon().getBounds());
+ changedArea = changedArea.union(polygons.get(idx).getPolygon().getBounds());
}
}
}
@@ -382,7 +385,7 @@
} else {
changedArea = polygons.get(idx).getPolygon().getBounds();
polygons.set(idx, copyData[idx]);
- changedArea.union(polygons.get(idx).getPolygon().getBounds());
+ changedArea = changedArea.union(polygons.get(idx).getPolygon().getBounds());
}
}
}
@@ -422,7 +425,7 @@
int idx = r.nextInt(polygons.size());
changedArea = polygons.get(idx).getPolygon().getBounds();
PolygonData randomPoly = PolygonData.randomPoly(imageSize, settings.getMaxPoints());
- changedArea.union(randomPoly.getPolygon().getBounds());
+ changedArea = changedArea.union(randomPoly.getPolygon().getBounds());
polygons.set(idx, randomPoly);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2012-04-21 00:23:31
|
Revision: 250
http://polycasso.svn.sourceforge.net/polycasso/?rev=250&view=rev
Author: dbrosius
Date: 2012-04-21 00:23:24 +0000 (Sat, 21 Apr 2012)
Log Message:
-----------
merge from github
Modified Paths:
--------------
trunk/polycasso/src/com/mebigfatguy/polycasso/RandomImageFinder.java
trunk/polycasso/src/com/mebigfatguy/polycasso/URLFetcher.java
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/RandomImageFinder.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/RandomImageFinder.java 2012-03-18 02:35:10 UTC (rev 249)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/RandomImageFinder.java 2012-04-21 00:23:24 UTC (rev 250)
@@ -38,7 +38,7 @@
private static final String ROOTURL = "http://search.lycos.com";
private static final String URL = ROOTURL + "/images/?q={0}";
private static final Pattern IMAGE_HTML_PATTERN = Pattern.compile("\\<a href=\"(/image-preview\\?image=.*)\"");
- private static final Pattern IMAGE_PATTERN = Pattern.compile("<a href=\"([^\"]*)\" title=\"Full-size Image\">");
+ private static final Pattern IMAGE_PATTERN = Pattern.compile("<a href=\"([^\"]*)\" title=\"Full-size image\">");
private static final int NAMELEN = 3;
private static final int ATTEMPTS = 5;
@@ -67,6 +67,7 @@
return findImageAt(MessageFormat.format(URL, new String(ranName)), settings);
} catch (IOException ioe) {
+ ioe.printStackTrace();
}
}
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/URLFetcher.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/URLFetcher.java 2012-03-18 02:35:10 UTC (rev 249)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/URLFetcher.java 2012-04-21 00:23:24 UTC (rev 250)
@@ -70,7 +70,10 @@
proxy = Proxy.NO_PROXY;
}
con = (HttpURLConnection)u.openConnection(proxy);
- con.addRequestProperty("User-Agent", "Mozilla/4.76");
+ con.addRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.6 (KHTML, like Gecko) Chrome/20.0.1092.0 Safari/536.6");
+ con.addRequestProperty("Accept-Charset", "UTF-8");
+ con.addRequestProperty("Accept-Language", "en-US,en");
+ con.addRequestProperty("Accept", "text/html,image/*");
con.setDoInput(true);
con.setDoOutput(false);
con.connect();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|