/** * *@return
*/ public FileSet createFirstPool() { if (first != null) { thrownew BuildException();
}
first = new FileSet(); return first;
}
public FileSet createSecondPool() { if (second != null) { thrownew BuildException();
}
second = new FileSet(); return second;
}
@Override publicvoid execute() throws BuildException { if (first == null) { thrownew BuildException("You need to specify firstpool element for this task!"); // NOI18N
}
try {
SortedSet<IconInfo> firstSet = new TreeSet<>(); for (String f : first.getDirectoryScanner(getProject()).getIncludedFiles()) {
File baseDir = first.getDir(getProject());
File file = new File(baseDir, f);
firstSet.add(new IconInfo(file.toURI().toURL(), getProject()));
}
SortedSet<IconInfo> sndSet = new TreeSet<>(); if (second != null) { for (String f : second.getDirectoryScanner(getProject()).getIncludedFiles()) {
File baseDir = second.getDir(getProject());
File file = new File(baseDir, f);
sndSet.add(new IconInfo(file.toURI().toURL(), getProject()));
}
}
if (duplicates != null) {
Set<IconInfo> both = new TreeSet<>(firstSet);
both.addAll(sndSet);
try (BufferedWriter os = new BufferedWriter(new FileWriter(duplicates))) {
IconInfo prev = null; boolean prevPrinted = false; for (IconInfo info : both) {
IconInfo p = prev;
prev = info; if (p == null || p.hash != info.hash) {
prevPrinted = false; continue;
}
if (!prevPrinted) {
os.write(p.toString());
os.newLine();
prevPrinted = true;
}
os.write(info.toString());
os.newLine();
}
}
} if (difference != null) {
SortedSet<IconInfo> union = new TreeSet<>(firstSet);
union.addAll(sndSet);
try (BufferedWriter os = new BufferedWriter(new FileWriter(difference))) { for (IconInfo info : union) { if (!contains(firstSet, info.hash)) {
os.write('+');
os.write(info.toString());
os.newLine(); continue;
} if (!contains(sndSet, info.hash)) {
os.write('-');
os.write(info.toString());
os.newLine(); continue;
}
}
}
}
privatestaticfinalclass IconInfo implements Comparable<IconInfo> { final String name; final String path; finalint hash;
public IconInfo(URL from, Project p) throws IOException { this.path = from.toExternalForm(); int last = this.path.lastIndexOf('/'); assert last >= 0; this.name = this.path.substring(last + 1);
p.log("Parsing " + from, Project.MSG_VERBOSE);
BufferedImage image; int _hash; try { try (InputStream is = from.openStream()) {
image = ImageIO.read(is);
} int w = image.getWidth(); int h = image.getHeight();
_hash = w * 3 + h * 7;
for (int i = 0; i < w; i++) { for (int j = 0; j < h; j++) { int rgb = image.getRGB(i, j);
_hash += (rgb >> 2);
}
}
} catch (IOException | IndexOutOfBoundsException e) {
p.log("Broken icon at " + from, Project.MSG_WARN);
_hash = hash(e);
}
this.hash = _hash;
}
public IconInfo(String name, String path, int hash) { this.name = name; this.path = path; this.hash = hash;
}
@Override publicint hashCode() { return hash;
}
@Override publicboolean equals(Object obj) { if (obj == null) returnfalse; if (getClass() != obj.getClass()) returnfalse; final IconInfo other = (IconInfo) obj;
if (this.path != other.path &&
(this.path == null || !this.path.equals(other.path))) returnfalse; if (this.hash != other.hash) returnfalse; returntrue;
}
public @Override String toString() {
String h = Integer.toHexString(hash); if (h.length() < 8) {
h = "00000000".substring(h.length()) + h;
}
String n = name; if (n.length() < 30) {
n = n + " ".substring(n.length());
}
return MessageFormat.format("{0} {1} {2}", h, n, path);
}
} // end of IconInfo
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.13 Sekunden
(vorverarbeitet am 2026-06-10)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.