Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
added web structure image see http://localhost:8080/WatchWebStructure_p.html
orbitera585b4d41b51
diff --git a/htroot/WatchCrawler_p.html b/htroot/WatchCrawler_p.htmlindex 784108152..6282d0314 100644--- a/htroot/WatchCrawler_p.html+++ b/htroot/WatchCrawler_p.html@@ -7,7 +7,9 @@<script type="text/javascript" src="/js/xml.js"></script><script type="text/javascript" src="/js/html.js"></script><script type="text/javascript" src="/js/WatchCrawler.js"></script></head>-<body id="watchCrawler"> #%env/templates/header.template%#+<body id="watchCrawler">+#%env/templates/header.template%#+#%env/templates/submenuCrawler.template%#<h2>Crawler Monitor</h2><p> Next update in <span id="nextUpdate" onclick="changeInterval()"></span> seconds. <img src="/env/grafics/empty.gif" name="ajax" alt="empty"/></p>diff --git a/htroot/WatchWebStructure_p.html b/htroot/WatchWebStructure_p.htmlnew file mode 100644index 000000000..f262a6a4f--- /dev/null+++ b/htroot/WatchWebStructure_p.html@@ -0,0 +1,15 @@+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">+<html xmlns="http://www.w3.org/1999/xhtml">+<head>+<title>YaCy '#[clientname]#': Web Structure</title>+#%env/templates/metas.template%#+</head>+<body id="WebStructure">+#%env/templates/header.template%#+#%env/templates/submenuCrawler.template%#+<h2>Web Structure</h2>+<img src="WebStructurePicture_p.png">++#%env/templates/footer.template%#+</body>+</html>diff --git a/htroot/WatchWebStructure_p.java b/htroot/WatchWebStructure_p.javanew file mode 100644index 000000000..b86c2a581--- /dev/null+++ b/htroot/WatchWebStructure_p.java@@ -0,0 +1,14 @@++import de.anomic.http.httpHeader;+import de.anomic.plasma.plasmaSwitchboard;+import de.anomic.server.serverObjects;+import de.anomic.server.serverSwitch;+++public class WatchWebStructure_p {+ public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch env) {+ plasmaSwitchboard sb = (plasmaSwitchboard) env;+ serverObjects prop = new serverObjects();+ return prop;+ }+}diff --git a/htroot/WebStructurePicture_p.java b/htroot/WebStructurePicture_p.javanew file mode 100644index 000000000..019cf1bae--- /dev/null+++ b/htroot/WebStructurePicture_p.java@@ -0,0 +1,132 @@+// WebStructurePicture.java+// (C) 2007 by Michael Peter Christen; [email protected], Frankfurt a. M., Germany+// first published 22.05.2007 on http://yacy.net+//+// This is a part of YaCy, a peer-to-peer based web search engine+//+// $LastChangedDate: 2006-04-02 22:40:07 +0200 (So, 02 Apr 2006) $+// $LastChangedRevision: 1986 $+// $LastChangedBy: orbiter $+//+// LICENSE+//+// This program is free software; you can redistribute it and/or modify+// it under the terms of the GNU General Public License as published by+// the Free Software Foundation; either version 2 of the License, or+// (at your option) any later version.+//+// This program is distributed in the hope that it will be useful,+// but WITHOUT ANY WARRANTY; without even the implied warranty of+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+// GNU General Public License for more details.+//+// You should have received a copy of the GNU General Public License+// along with this program; if not, write to the Free Software+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA++import java.net.MalformedURLException;+import java.util.ArrayList;+import java.util.Iterator;+import java.util.Map;++import de.anomic.http.httpHeader;+import de.anomic.kelondro.kelondroBase64Order;+import de.anomic.net.URL;+import de.anomic.plasma.plasmaSwitchboard;+import de.anomic.plasma.plasmaURL;+import de.anomic.plasma.plasmaWebStructure;+import de.anomic.server.serverObjects;+import de.anomic.server.serverSwitch;+import de.anomic.ymage.ymageGraph;+import de.anomic.ymage.ymageMatrix;++public class WebStructurePicture_p {++ private static final double maxlongd = (double) Long.MAX_VALUE;++ public static ymageMatrix respond(httpHeader header, serverObjects post, serverSwitch env) {+ plasmaSwitchboard sb = (plasmaSwitchboard) env;++ int width = 768;+ int height = 576;+ int depth = 3;+ String host = null;++ if (post != null) {+ width = post.getInt("width", 768);+ height = post.getInt("height", 576);+ depth = post.getInt("depth", 3);+ host = post.get("host", null);+ }++ //too small values lead to an error, too big to huge CPU/memory consumption, resulting in possible DOS.+ if (width < 320 ) width = 320;+ if (width > 1920) width = 1920;+ if (height < 240) height = 240;+ if (height > 1920) height = 1920;+ if (depth > 8) depth = 8;+ if (depth < 1) depth = 1;++ // find start point+ if (host == null) {+ // find domain with most references+ host = sb.webStructure.hostWithMaxReferences();+ }+ // find start hash+ String hash = null;+ try {+ hash = plasmaURL.urlHash(new URL("http://" + host)).substring(6);+ } catch (MalformedURLException e) {e.printStackTrace();}+ assert (sb.webStructure.references(hash) != null);++ // recursively find domains, up to a specific depth+ ymageGraph graph = new ymageGraph();+ place(graph, sb.webStructure, hash, host, 0.0, 0.0, 0, depth);+ //graph.print();++ return graph.draw(width, height, 20, 20, 20, 20);++ }++ private static final void place(ymageGraph graph, plasmaWebStructure structure, String centerhash, String centerhost, double x, double y, int nextlayer, int maxlayer) {+ // returns the host string+ assert centerhost != null;+ ymageGraph.coordinate center = graph.getPoint(centerhost);+ if (center == null) center = graph.addPoint(centerhost, x, y, nextlayer);+ if (nextlayer == maxlayer) return;+ nextlayer++;+ Map next = structure.references(centerhash);+ Map.Entry entry;+ String targethash, targethost;+ // first set points to next hosts+ Iterator i = next.entrySet().iterator();+ ArrayList targets = new ArrayList();+ while (i.hasNext()) {+ entry = (Map.Entry) i.next();+ targethash = (String) entry.getKey();+ targethost = structure.resolveDomHash2DomString(targethash);+ if (targethost == null) continue;+ targets.add(new String[] {targethash, targethost});+ if (graph.getPoint(targethost) != null) continue;+ // set a new point. It is placed on a circle around the host point+ double angle = ((double) kelondroBase64Order.enhancedCoder.cardinal((targethash + "____").getBytes())) / maxlongd * 2 * Math.PI;+ System.out.println("ANGLE = " + angle);+ double radius = 1.0 / ((double) (1 << nextlayer));+ graph.addPoint(targethost, x + radius * Math.cos(angle), y + radius * Math.sin(angle), nextlayer);+ }+ // recursively set next hosts+ i = targets.iterator();+ String[] target;+ while (i.hasNext()) {+ target = (String[]) i.next();+ targethash = target[0];+ targethost = target[1];+ ymageGraph.coordinate c = graph.getPoint(targethost);+ assert c != null;+ place(graph, structure, targethash, targethost, c.x, c.y, nextlayer, maxlayer);+ graph.setBorder(centerhost, targethost);+ }+ return;+ }++}diff --git a/htroot/env/templates/submenuCrawler.template b/htroot/env/templates/submenuCrawler.templatenew file mode 100644index 000000000..63467593c--- /dev/null+++ b/htroot/env/templates/submenuCrawler.template@@ -0,0 +1,7 @@+<div class="SubMenu">+<h3>Crawler Monitor Menu</h3>+<ul class="SubMenu">+<li><a href="/WatchCrawler_p.html" class="MenuItemLink lock">Crawler Queues</a></li>+<li><a href="/WatchWebStructure_p.html" class="MenuItemLink lock">Web Structure</a></li>+</ul>+</div>\ No newline at end of filediff --git a/htroot/imagetest.java b/htroot/imagetest.javaindex e1004a66d..004dd6cd9 100644--- a/htroot/imagetest.java+++ b/htroot/imagetest.java@@ -88,8 +88,8 @@ public class imagetest {img.setMode(ymageMatrix.MODE_SUB);img.setColor(ymageMatrix.SUBTRACTIVE_BLACK);- for (int y = 0; y < 600; y = y + 50) ymageToolPrint.print(img, 0, 6 + y, 0, "" + y, true);- for (int x = 0; x < 800; x = x + 50) ymageToolPrint.print(img, x, 6 , 0, "" + x, true);+ for (int y = 0; y < 600; y = y + 50) ymageToolPrint.print(img, 0, 6 + y, 0, "" + y, -1);+ for (int x = 0; x < 800; x = x + 50) ymageToolPrint.print(img, x, 6 , 0, "" + x, -1);img.setColor(ymageMatrix.SUBTRACTIVE_RED);img.dot(550, 110, 90, true);img.setColor(ymageMatrix.SUBTRACTIVE_GREEN);@@ -102,9 +102,9 @@ public class imagetest {img.arc(220, 110, 50, 90, 30, 110);img.arc(210, 120, 50, 90, 30, 110);img.setColor(ymageMatrix.SUBTRACTIVE_BLACK);- ymageToolPrint.print(img, 50, 110, 0, "BROADCAST MESSAGE #772: NODE %882 BLACK abcefghijklmnopqrstuvwxyz", true);+ ymageToolPrint.print(img, 50, 110, 0, "BROADCAST MESSAGE #772: NODE %882 BLACK abcefghijklmnopqrstuvwxyz", -1);img.setColor(ymageMatrix.SUBTRACTIVE_GREEN);- ymageToolPrint.print(img, 50, 120, 0, "BROADCAST MESSAGE #772: NODE %882 GREEN abcefghijklmnopqrstuvwxyz", true);+ ymageToolPrint.print(img, 50, 120, 0, "BROADCAST MESSAGE #772: NODE %882 GREEN abcefghijklmnopqrstuvwxyz", -1);for (long i = 0; i < 256; i++) {img.setColor(i);img.dot(10 + 14 * (int) (i / 16), 200 + 14 * (int) (i % 16), 6, true);diff --git a/htroot/xml/webstructure.java b/htroot/xml/webstructure.javaindex 23ba36d23..a254d88c1 100644--- a/htroot/xml/webstructure.java+++ b/htroot/xml/webstructure.java@@ -1,3 +1,30 @@+// webstructure.java+// (C) 2007 by Michael Peter Christen; [email protected], Frankfurt a. M., Germany+// first published 22.05.2007 on http://yacy.net+//+// This is a part of YaCy, a peer-to-peer based web search engine+//+// $LastChangedDate: 2006-04-02 22:40:07 +0200 (So, 02 Apr 2006) $+// $LastChangedRevision: 1986 $+// $LastChangedBy: orbiter $+//+// LICENSE+//+// This program is free software; you can redistribute it and/or modify+// it under the terms of the GNU General Public License as published by+// the Free Software Foundation; either version 2 of the License, or+// (at your option) any later version.+//+// This program is distributed in the hope that it will be useful,+// but WITHOUT ANY WARRANTY; without even the implied warranty of+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+// GNU General Public License for more details.+//+// You should have received a copy of the GNU General Public License+// along with this program; if not, write to the Free Software+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA++package xml;import java.util.Iterator;@@ -14,8 +41,7 @@ public class webstructure {public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch env) {serverObjects prop = new serverObjects();plasmaSwitchboard sb = (plasmaSwitchboard) env;- plasmaWebStructure structure = sb.webStructure;- Iterator i = structure.structureEntryIterator();+ Iterator i = sb.webStructure.structureEntryIterator();int c = 0, d;plasmaWebStructure.structureEntry sentry;Map.Entry refentry;@@ -32,7 +58,7 @@ public class webstructure {refloop: while (k.hasNext()) {refentry = (Map.Entry) k.next();refhash = (String) refentry.getKey();- refdom = structure.resolveDomHash2DomString(refhash);+ refdom = sb.webStructure.resolveDomHash2DomString(refhash);if (refdom == null) continue refloop;prop.put("domains_" + c + "_citations_" + d + "_refhash", refhash);prop.put("domains_" + c + "_citations_" + d + "_refdom", refdom);@@ -44,6 +70,7 @@ public class webstructure {c++;}prop.put("domains", c);+ prop.put("maxref", plasmaWebStructure.maxref);// return rewrite propertiesreturn prop;diff --git a/htroot/xml/webstructure.xml b/htroot/xml/webstructure.xmlindex 87f04c1f6..79acdc859 100644--- a/htroot/xml/webstructure.xml+++ b/htroot/xml/webstructure.xml@@ -1,6 +1,6 @@<?xml version="1.0"?><webstructure>-<domains reference="forward" count="#[domains]#">+<domains reference="forward" count="#[domains]#" maxref="#[maxref]#">#{domains}#<domain host="#[domain]#" id="#[hash]#" date="#[date]#">#{citations}#diff --git a/source/de/anomic/plasma/plasmaGrafics.java b/source/de/anomic/plasma/plasmaGrafics.javaindex 54d1b2b20..d419a427d 100644--- a/source/de/anomic/plasma/plasmaGrafics.java+++ b/source/de/anomic/plasma/plasmaGrafics.java@@ -252,9 +252,9 @@ public class plasmaGrafics {// draw descriptionnetworkPicture.setColor(COL_HEADLINE);networkPicture.setMode(ymageMatrix.MODE_SUB);- ymageToolPrint.print(networkPicture, 2, 8, 0, "THE YACY NETWORK", true);- ymageToolPrint.print(networkPicture, 2, 16, 0, "DRAWING OF " + totalCount + " SELECTED PEERS", true);- ymageToolPrint.print(networkPicture, width - 2, 8, 0, "SNAPSHOT FROM " + new Date().toString().toUpperCase(), false);+ ymageToolPrint.print(networkPicture, 2, 8, 0, "THE YACY NETWORK", -1);+ ymageToolPrint.print(networkPicture, 2, 16, 0, "DRAWING OF " + totalCount + " SELECTED PEERS", -1);+ ymageToolPrint.print(networkPicture, width - 2, 8, 0, "SNAPSHOT FROM " + new Date().toString().toUpperCase(), 1);// set timestampnetworkPictureDate = System.currentTimeMillis();diff --git a/source/de/anomic/plasma/plasmaWebStructure.java b/source/de/anomic/plasma/plasmaWebStructure.javaindex 7a3a32c24..039ab815c 100644--- a/source/de/anomic/plasma/plasmaWebStructure.java+++ b/source/de/anomic/plasma/plasmaWebStructure.java@@ -45,6 +45,7 @@ public class plasmaWebStructure {public static int maxCRLDump = 500000;public static int maxCRGDump = 200000;+ public static int maxref = 10; // maximum number of references, to avoid overflow when a large link farm occurs (i.e. wikipedia)private StringBuffer crg; // global citation referencesprivate serverLog log;@@ -147,7 +148,7 @@ public class plasmaWebStructure {}}- public static TreeMap refstr2map(String refs) {+ private static TreeMap refstr2map(String refs) {if ((refs == null) || (refs.length() <= 8)) return new TreeMap();TreeMap map = new TreeMap();String c;@@ -188,6 +189,7 @@ public class plasmaWebStructure {}public TreeMap references(String domhash) {+ // returns a map with a domhash(String):refcount(Integer) relationassert domhash.length() == 6;SortedMap tailMap = structure.tailMap(domhash);if ((tailMap == null) || (tailMap.size() == 0)) return new TreeMap();@@ -214,6 +216,8 @@ public class plasmaWebStructure {private void learn(URL url, StringBuffer reference /*string of b64(12digits)-hashes*/) {String domhash = plasmaURL.urlHash(url).substring(6);++ // parse the new reference string and join it with the stored referencesTreeMap refs = references(domhash);assert reference.length() % 12 == 0;String dom;@@ -226,8 +230,27 @@ public class plasmaWebStructure {}refs.put(dom, new Integer(++c));}- structure.put(domhash + "," + url.getHost(), map2refstr(refs));+ // check if the maxref is exceeded+ if (refs.size() > maxref) {+ // shrink the references: the entry with the smallest number of references is removed+ int minrefcount = Integer.MAX_VALUE;+ String minrefkey = null;+ Iterator i = refs.entrySet().iterator();+ Map.Entry entry;+ while (i.hasNext()) {+ entry = (Map.Entry) i.next();+ if (((Integer) entry.getValue()).intValue() < minrefcount) {+ minrefcount = ((Integer) entry.getValue()).intValue();+ minrefkey = (String) entry.getKey();+ }+ }+ // remove the smallest+ if (minrefkey != null) refs.remove(minrefkey);+ }++ // store the map back to the structure+ structure.put(domhash + "," + url.getHost(), map2refstr(refs));}public void saveWebStructure() {@@ -238,6 +261,23 @@ public class plasmaWebStructure {}}+ public String hostWithMaxReferences() {+ // find domain with most references+ Iterator i = structure.entrySet().iterator();+ int refsize, maxref = 0;+ String maxhost = null;+ Map.Entry entry;+ while (i.hasNext()) {+ entry = (Map.Entry) i.next();+ refsize = ((String) entry.getValue()).length();+ if (refsize > maxref) {+ maxref = refsize;+ maxhost = ((String) entry.getKey()).substring(7);+ }+ }+ return maxhost;+ }+public Iterator structureEntryIterator() {// iterates objects of type structureEntryreturn new structureIterator();diff --git a/source/de/anomic/ymage/ymageCaptcha.java b/source/de/anomic/ymage/ymageCaptcha.javaindex e958b4adf..998ccf877 100644--- a/source/de/anomic/ymage/ymageCaptcha.java+++ b/source/de/anomic/ymage/ymageCaptcha.java@@ -71,7 +71,7 @@ public class ymageCaptcha extends ymageMatrix {for(int i=0;i<chars;i++){y = random.nextInt((int)(height/2)) + (int)(height/4);setColor(((random.nextInt(128)+64)<<16) + ((random.nextInt(128)+64)<<8) + random.nextInt(128)+64);- ymageToolPrint.print(this, widthPerChar*i+random.nextInt((int)(widthPerChar/2)) , y , 0, code.substring(i,i+1), true);+ ymageToolPrint.print(this, widthPerChar*i+random.nextInt((int)(widthPerChar/2)) , y , 0, code.substring(i,i+1), -1);}//adding some noisediff --git a/source/de/anomic/ymage/ymageChart.java b/source/de/anomic/ymage/ymageChart.javaindex 31defb9f9..dc04ba03e 100644--- a/source/de/anomic/ymage/ymageChart.java+++ b/source/de/anomic/ymage/ymageChart.java@@ -67,7 +67,7 @@ public class ymageChart extends ymageMatrix {this.topborder = topborder;this.bottomborder = bottomborder;if (name != null) {- ymageToolPrint.print(this, width / 2 - name.length() * 3, 6, 0, name, true);+ ymageToolPrint.print(this, width / 2 - name.length() * 3, 6, 0, name, -1);}}@@ -111,12 +111,12 @@ public class ymageChart extends ymageMatrix {}setColor(colorNaming);line(x, y - 3, x, y + 3);- ymageToolPrint.print(this, x, (top) ? y - 3 : y + 9, 0, Integer.toString(s), true);+ ymageToolPrint.print(this, x, (top) ? y - 3 : y + 9, 0, Integer.toString(s), -1);x += pixelperscale;s += scale;}setColor(colorNaming);- ymageToolPrint.print(this, width - rightborder, (top) ? y - 9 : y + 15, 0, name, false);+ ymageToolPrint.print(this, width - rightborder, (top) ? y - 9 : y + 15, 0, name, 1);line(leftborder - 4, y, width - rightborder + 4, y);}@@ -135,12 +135,12 @@ public class ymageChart extends ymageMatrix {line(x - 3, y, x + 3, y);s1 = Integer.toString(s);if (s1.length() > s1max) s1max = s1.length();- ymageToolPrint.print(this, (left) ? leftborder - 4 : width - rightborder + 4, y, 0, s1, (!left));+ ymageToolPrint.print(this, (left) ? leftborder - 4 : width - rightborder + 4, y, 0, s1, (left) ? 1 : -1);y -= pixelperscale;s += scale;}setColor(colorNaming);- ymageToolPrint.print(this, (left) ? x - s1max * 6 - 6 : x + s1max * 6 + 9, topborder, 90, name, false);+ ymageToolPrint.print(this, (left) ? x - s1max * 6 - 6 : x + s1max * 6 + 9, topborder, 90, name, 1);line(x, topborder - 4, x, height - bottomborder + 4);}diff --git a/source/de/anomic/ymage/ymageDemoApplet.java b/source/de/anomic/ymage/ymageDemoApplet.javaindex e01fae869..05d3b4c0d 100644--- a/source/de/anomic/ymage/ymageDemoApplet.java+++ b/source/de/anomic/ymage/ymageDemoApplet.java@@ -62,7 +62,7 @@ public class ymageDemoApplet extends Applet implements Runnable {ymageMatrix.demoPaint(m);int y = (int) (System.currentTimeMillis() / 10 % 300);m.setColor(ymageMatrix.SUBTRACTIVE_BLACK);- ymageToolPrint.print(m, 0, y, 0, "Hello World", true);+ ymageToolPrint.print(m, 0, y, 0, "Hello World", -1);}}diff --git a/source/de/anomic/ymage/ymageGraph.java b/source/de/anomic/ymage/ymageGraph.javanew file mode 100644index 000000000..e0f0da796--- /dev/null+++ b/source/de/anomic/ymage/ymageGraph.java@@ -0,0 +1,142 @@+package de.anomic.ymage;++import java.util.HashMap;+import java.util.HashSet;+import java.util.Iterator;+import java.util.Map;++/* this class does not really draw graphes, it is only a container for graph coordinates.+ * all coordinates are given in a artificial corrdinate system, in the range from+ * -1 to +1. The lower left point of the graph has the coordinate -1, -1 and the upper+ * right is 1,1+ * 0,0 is the center of the graph+ */++public class ymageGraph {++ // a ymageGraph is a set of points and borders between the points+ // to reference the points, they must all have a nickname++ HashMap points;+ HashSet borders;+ double leftmost, rightmost, topmost, bottommost;++ public ymageGraph() {+ points = new HashMap();+ borders = new HashSet();+ leftmost = 1.0;+ rightmost = -1.0;+ topmost = -1.0;+ bottommost = 1.0;+ }++ public coordinate getPoint(String name) {+ return (coordinate) points.get(name);+ }++ public coordinate[] getBorder(String name) {+ int p = name.indexOf("$");+ if (p < 0) return null;+ coordinate from = getPoint(name.substring(0, p));+ coordinate to = getPoint(name.substring(p + 1));+ if ((from == null) || (to == null)) return null;+ return new coordinate[] {from, to};+ }++ public coordinate addPoint(String name, double x, double y, int layer) {+ coordinate newc = new coordinate(x, y, layer);+ coordinate oldc = (coordinate) points.put(name, newc);+ assert oldc == null; // all add shall be unique+ if (x > rightmost) rightmost = x;+ if (x < leftmost) leftmost = x;+ if (y > topmost) topmost = y;+ if (y < bottommost) bottommost = y;+ return newc;+ }++ public boolean hasBorder(String fromPoint, String toPoint) {+ return borders.contains(fromPoint + "-" + toPoint);+ }++ public void setBorder(String fromPoint, String toPoint) {+ coordinate from = (coordinate) points.get(fromPoint);+ coordinate to = (coordinate) points.get(toPoint);+ assert from != null;+ assert to != null;+ borders.add(fromPoint + "$" + toPoint);+ }++ public class coordinate {+ public double x, y;+ public int layer;+ public coordinate(double x, double y, int layer) {+ assert x >= -1;+ assert x <= 1;+ assert y >= -1;+ assert y <= 1;+ this.x = x;+ this.y = y;+ this.layer = layer;+ }+ }++ public void print() {+ // for debug purpose: print out all coordinates+ Iterator i = points.entrySet().iterator();+ Map.Entry entry;+ String name;+ coordinate c;+ while (i.hasNext()) {+ entry = (Map.Entry) i.next();+ name = (String) entry.getKey();+ c = (coordinate) entry.getValue();+ System.out.println("point(" + c.x + ", " + c.y + ", " + c.layer + ") [" + name + "]");+ }+ i = borders.iterator();+ while (i.hasNext()) {+ System.out.println("border(" + i.next() + ")");+ }+ }++ private static final long color_back = ymageMatrix.SUBTRACTIVE_WHITE;+ private static final long color_dot = 0x4444AA;+ private static final long color_line = 0x333333;+ private static final long color_text = ymageMatrix.SUBTRACTIVE_BLACK;++ public ymageMatrix draw(int width, int height, int leftborder, int rightborder, int topborder, int bottomborder) {+ ymageMatrix image = new ymageMatrix(width, height, color_back);+ double xfactor = (width - leftborder - rightborder) / (rightmost - leftmost);+ double yfactor = (height - topborder - bottomborder) / (topmost - bottommost);+ image.setMode(ymageMatrix.MODE_SUB);++ Iterator i = points.entrySet().iterator();+ Map.Entry entry;+ String name;+ coordinate c;+ int x, y;+ while (i.hasNext()) {+ entry = (Map.Entry) i.next();+ name = (String) entry.getKey();+ c = (coordinate) entry.getValue();+ x = (int) (leftborder + (c.x - leftmost) * xfactor);+ y = (int) (height - bottomborder - (c.y - bottommost) * yfactor);+ image.setColor(color_dot);+ image.dot(x, y, 5, true);+ image.setColor(color_text);+ ymageToolPrint.print(image, x, y + 10, 0, name.toUpperCase(), 0);+ }+ i = borders.iterator();+ coordinate[] border;+ image.setColor(color_line);+ while (i.hasNext()) {+ border = getBorder((String) i.next());+ if (border == null) continue;+ image.line(+ (int) (leftborder + (border[0].x - leftmost) * xfactor),+ (int) (height - bottomborder - (border[0].y - bottommost) * yfactor),+ (int) (leftborder + (border[1].x - leftmost) * xfactor),+ (int) (height - bottomborder - (border[1].y - bottommost) * yfactor));+ }+ return image;+ }+}diff --git a/source/de/anomic/ymage/ymageMatrix.java b/source/de/anomic/ymage/ymageMatrix.javaindex 36ac9cff2..4619cd672 100644--- a/source/de/anomic/ymage/ymageMatrix.java+++ b/source/de/anomic/ymage/ymageMatrix.java@@ -255,25 +255,25 @@ public class ymageMatrix /*implements Cloneable*/ {public static void demoPaint(ymageMatrix m) {m.setMode(MODE_SUB);m.setColor(SUBTRACTIVE_CYAN);- m.line(0, 10, 100, 10); ymageToolPrint.print(m, 0, 5, 0, "Cyan", true);+ m.line(0, 10, 100, 10); ymageToolPrint.print(m, 0, 5, 0, "Cyan", -1);m.line(50, 0, 50, 300);m.setColor(SUBTRACTIVE_MAGENTA);- m.line(0, 30, 100, 30); ymageToolPrint.print(m, 0, 25, 0, "Magenta", true);+ m.line(0, 30, 100, 30); ymageToolPrint.print(m, 0, 25, 0, "Magenta", -1);m.line(55, 0, 55, 300);m.setColor(SUBTRACTIVE_YELLOW);- m.line(0, 50, 100, 50); ymageToolPrint.print(m, 0, 45, 0, "Yellow", true);+ m.line(0, 50, 100, 50); ymageToolPrint.print(m, 0, 45, 0, "Yellow", -1);m.line(60, 0, 60, 300);m.setColor(SUBTRACTIVE_BLACK);- m.line(0, 70, 100, 70); ymageToolPrint.print(m, 0, 65, 0, "Black", true);+ m.line(0, 70, 100, 70); ymageToolPrint.print(m, 0, 65, 0, "Black", -1);m.line(65, 0, 65, 300);m.setColor(SUBTRACTIVE_RED);- m.line(0, 90, 100, 90); ymageToolPrint.print(m, 0, 85, 0, "Red", true);+ m.line(0, 90, 100, 90); ymageToolPrint.print(m, 0, 85, 0, "Red", -1);m.line(70, 0, 70, 300);m.setColor(SUBTRACTIVE_GREEN);- m.line(0, 110, 100, 110); ymageToolPrint.print(m, 0, 105, 0, "Green", true);+ m.line(0, 110, 100, 110); ymageToolPrint.print(m, 0, 105, 0, "Green", -1);m.line(75, 0, 75, 300);m.setColor(SUBTRACTIVE_BLUE);- m.line(0, 130, 100, 130); ymageToolPrint.print(m, 0, 125, 0, "Blue", true);+ m.line(0, 130, 100, 130); ymageToolPrint.print(m, 0, 125, 0, "Blue", -1);m.line(80, 0, 80, 300);}diff --git a/source/de/anomic/ymage/ymageToolPrint.java b/source/de/anomic/ymage/ymageToolPrint.javaindex c70cad8d7..41573862a 100644--- a/source/de/anomic/ymage/ymageToolPrint.java+++ b/source/de/anomic/ymage/ymageToolPrint.java@@ -43,14 +43,17 @@ public class ymageToolPrint {}}- public static void print(ymageMatrix matrix, int x, int y, int angle, String message, boolean alignLeft) {+ public static void print(ymageMatrix matrix, int x, int y, int angle, String message, int align) {+ // align = -1 : left+ // align = 1 : right+ // align = 0 : centerint xx = 0, yy = 0;if (angle == 0) {- xx = (alignLeft) ? x : x - 6 * message.length();+ xx = (align == -1) ? x : (align == 1) ? x - 6 * message.length() : x - 3 * message.length();yy = y;} else if (angle == 90) {xx = x;- yy = (alignLeft) ? y : y + 6 * message.length();+ yy = (align == -1) ? y : (align == 1) ? y + 6 * message.length() : y + 3 * message.length();}for (int i = 0; i < message.length(); i++) {print(matrix, xx, yy, angle, message.charAt(i));@@ -72,7 +75,7 @@ public class ymageToolPrint {int xp = x - 3 * message.length();if ((angle > (90 + arcDist)) && (angle < (270 - arcDist))) xp = x - 6 * message.length();if ((angle < (90 - arcDist)) || (angle > (270 + arcDist))) xp = x;- print(matrix, xp, yp, 0, message, true);+ print(matrix, xp, yp, 0, message, -1);}