- fixed network graphic

- debuged evaluation tables
- changed cache settings in template engine
- some speed hacks
- changed int angles for peer positions in network graphic to double angles

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@8124 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 13 years ago
parent 6dad227bdf
commit 35a9e8f307

@ -11,7 +11,7 @@
<script type="text/javascript">
<!--
imagestub = "NetworkPicture.png?width=1024&height=576&bgcolor=FFFFFF&ct=5000&coronaangle=";
imagestub = "NetworkPicture.png?width=1024&height=1024&bgcolor=FFFFFF&ct=9000&coronaangle=";
imageanimindex = 0;
imageloadindex = 0;
imagecycles = 0;
@ -23,7 +23,7 @@
for (j = 0; j < 6; j++) initanimationphase(j, handle);
}
function initanimationphase(phase, handle) {
imagearray[phase] = new Image(1024, 576);
imagearray[phase] = new Image(1024, 1024);
angle = phase * 60;
imagearray[phase].src = imagestub + angle + "&handle=" + handle;
}
@ -71,9 +71,9 @@ To see a list of all APIs, please visit the <a href="http://www.yacy-websuche.de
<h3>YaCy Network</h3>
<ul class="SubMenu">
<li><a href="/Network.html" class="MenuItemLink">Network Overview</a></li>
<li><a href="/Network.html?page=1" class="MenuItemLink">Active&nbsp;Peers</a></li>
<li><a href="/Network.html?page=2" class="MenuItemLink">Passive&nbsp;Peers</a></li>
<li><a href="/Network.html?page=3" class="MenuItemLink">Potential&nbsp;Peers</a></li>
<li><a href="/Network.html?page=1&maxCount=1000" class="MenuItemLink">Active&nbsp;Peers</a></li>
<li><a href="/Network.html?page=2&maxCount=1000" class="MenuItemLink">Passive&nbsp;Peers</a></li>
<li><a href="/Network.html?page=3&maxCount=1000" class="MenuItemLink">Potential&nbsp;Peers</a></li>
</ul>
</div>
#(/menu)#
@ -229,7 +229,7 @@ To see a list of all APIs, please visit the <a href="http://www.yacy-websuche.de
<div class="left">
<p>
<a href="NetworkPicture.png?width=1024&amp;height=576&amp;bgcolor=FFFFFF"><img id="NetworkPicture" src="NetworkPicture.png?width=1024&amp;height=576&amp;bgcolor=FFFFFF&amp;coronaangle=0" alt="The YaCy Network" width="1024" height="576" /></a>
<a href="NetworkPicture.png?width=1024&amp;height=1024&amp;bgcolor=FFFFFF"><img id="NetworkPicture" src="NetworkPicture.png?width=1024&amp;height=1024&amp;bgcolor=FFFFFF&amp;coronaangle=0" alt="The YaCy Network" width="1024" height="1024" /></a>
</p>
</div>
<div class="left">

@ -230,7 +230,7 @@ public class Network {
} else {
// generate table
final int page = (post == null ? 1 : post.getInt("page", 1));
final int maxCount = (post == null ? 1000 : post.getInt("maxCount", 1000));
final int maxCount = (post == null ? 9000 : post.getInt("maxCount", 9000));
int conCount = 0;
if (sb.peers == null) {
prop.put("table", 0);//no remote senior/principal proxies known"
@ -302,7 +302,7 @@ public class Network {
prop.putHTML("regexerror_wrongregex", pse.getPattern());
}
}
if(e != null) {
if (e != null) {
while (e.hasNext() && conCount < maxCount) {
seed = e.next();
assert seed != null;
@ -445,7 +445,7 @@ public class Network {
} // while
}
if (iAmActive) { sb.peers.removeMySeed(); }
prop.putNum("table_list", conCount);
prop.put("table_list", conCount);
prop.put("table", 1);
prop.putNum("table_num", conCount);
prop.putNum("table_total", ((page == 1) && (iAmActive)) ? (size + 1) : size );

@ -65,7 +65,7 @@ public class NetworkPicture {
int height = 576;
int passiveLimit = 1440; // minutes; 1440 = 1 day; 720 = 12 hours; 1440 = 24 hours, 10080 = 1 week;
int potentialLimit = 1440;
int maxCount = 1000;
int maxCount = 9000;
String bgcolor = NetworkGraph.COL_BACKGROUND;
boolean corona = true;
int coronaangle = 0;

@ -121,6 +121,8 @@ public final class HTTPDFileHandler {
private static final serverClassLoader provider = new serverClassLoader(/*this.getClass().getClassLoader()*/);
private static serverSwitch switchboard = null;
private static Switchboard sb = Switchboard.getSwitchboard();
private final static byte[] UNRESOLVED_PATTERN = ASCII.getBytes("-UNRESOLVED_PATTERN-");
private static File htRootPath = null;
private static File htDocsPath = null;
@ -976,7 +978,7 @@ public final class HTTPDFileHandler {
// send page in chunks and parse SSIs
final ByteBuffer o = new ByteBuffer();
// apply templates
TemplateEngine.writeTemplate(fis, o, templatePatterns, ASCII.getBytes("-UNRESOLVED_PATTERN-"));
TemplateEngine.writeTemplate(fis, o, templatePatterns, UNRESOLVED_PATTERN);
fis.close();
HTTPDemon.sendRespondHeader(conProp, out,
httpVersion, 200, null, mimeType, -1,

@ -122,30 +122,30 @@ import net.yacy.kelondro.util.FileUtils;
*/
public final class TemplateEngine {
public final static byte hashChar = (byte)'#';
public final static byte[] slashChar = {(byte)'/'};
public final static byte pcChar = (byte)'%';
public final static byte[] dpdpa = "::".getBytes();
private final static byte hashChar = (byte)'#';
private final static byte[] slashChar = {(byte)'/'};
private final static byte pcChar = (byte)'%';
private final static byte[] dpdpa = "::".getBytes();
public final static byte lbr = (byte)'[';
public final static byte rbr = (byte)']';
public final static byte[] pOpen = {hashChar, lbr};
public final static byte[] pClose = {rbr, hashChar};
private final static byte lbr = (byte)'[';
private final static byte rbr = (byte)']';
private final static byte[] pOpen = {hashChar, lbr};
private final static byte[] pClose = {rbr, hashChar};
public final static byte lcbr = (byte)'{';
public final static byte rcbr = (byte)'}';
public final static byte[] mOpen = {hashChar, lcbr};
public final static byte[] mClose = {rcbr, hashChar};
private final static byte lcbr = (byte)'{';
private final static byte rcbr = (byte)'}';
private final static byte[] mOpen = {hashChar, lcbr};
private final static byte[] mClose = {rcbr, hashChar};
public final static byte lrbr = (byte)'(';
public final static byte rrbr = (byte)')';
public final static byte[] aOpen = {hashChar, lrbr};
public final static byte[] aClose = {rrbr, hashChar};
private final static byte lrbr = (byte)'(';
private final static byte rrbr = (byte)')';
private final static byte[] aOpen = {hashChar, lrbr};
private final static byte[] aClose = {rrbr, hashChar};
public final static byte[] iOpen = {hashChar, pcChar};
public final static byte[] iClose = {pcChar, hashChar};
private final static byte[] iOpen = {hashChar, pcChar};
private final static byte[] iClose = {pcChar, hashChar};
public final static byte[] ul = "_".getBytes();
private final static byte[] ul = "_".getBytes();
private final static byte[] alternative_which = ASCII.getBytes(" type=\"alternative\" which=\"");
private final static byte[] multi_num = ASCII.getBytes(" type=\"multi\" num=\"");
@ -206,7 +206,7 @@ public final class TemplateEngine {
*/
private final static byte[] writeTemplate(final InputStream in, final OutputStream out, final Map<String, String> pattern, final byte[] dflt, final byte[] prefix) throws IOException {
final PushbackInputStream pis = new PushbackInputStream(in, 100);
final ByteArrayOutputStream keyStream = new ByteArrayOutputStream(512);
final ByteArrayOutputStream keyStream = new ByteArrayOutputStream(4048);
byte[] key;
byte[] multi_key;
byte[] replacement;
@ -241,6 +241,7 @@ public final class TemplateEngine {
try{
num=Integer.parseInt(pattern.get(patternKey)); // Key contains the iteration number as string
}catch(final NumberFormatException e){
Log.logException(e);
num=0;
}
}

@ -148,7 +148,7 @@ public final class ClusteredScoreMap<E> extends AbstractScoreMap<E> implements R
l = Long.parseLong(s);
}
// fix out-of-ranges
if (l > Integer.MAX_VALUE) return Integer.MAX_VALUE;
if (l > Integer.MAX_VALUE) return Integer.MAX_VALUE; //(int) (l & (Integer.MAX_VALUE));
if (l < 0) {
System.out.println("string2score: negative score for input " + s);
return 0;

@ -223,4 +223,13 @@ public class ConcurrentScoreMap<E> extends AbstractScoreMap<E> implements ScoreM
return r.iterator();
}
public static void main(final String[] args) {
final ConcurrentScoreMap<String> a = new ConcurrentScoreMap<String>();
a.set("a", 55);
a.set("b", 3);
a.set("c", 80);
final Iterator<String> i = a.keys(true);
while (i.hasNext()) System.out.println(i.next());
}
}

@ -38,8 +38,10 @@ import net.yacy.cora.document.UTF8;
import net.yacy.cora.ranking.ClusteredScoreMap;
import net.yacy.cora.ranking.ConcurrentScoreMap;
import net.yacy.cora.ranking.ScoreMap;
import net.yacy.kelondro.data.word.Word;
import net.yacy.kelondro.index.RowSpaceExceededException;
import net.yacy.kelondro.logging.Log;
import net.yacy.kelondro.order.Base64Order;
import net.yacy.kelondro.order.ByteOrder;
import net.yacy.kelondro.order.CloneableIterator;
import net.yacy.kelondro.util.LookAheadIterator;
@ -59,7 +61,7 @@ public class MapDataMining extends MapHeap {
public MapDataMining(final File heapFile,
final int keylength,
final ByteOrder ordering,
int buffermax,
final int buffermax,
final int cachesize,
final String[] sortfields,
final String[] longaccfields,
@ -73,8 +75,8 @@ public class MapDataMining extends MapHeap {
this.floataccfields = floataccfields;
ScoreMap<String>[] cluster = null;
if (sortfields == null) sortClusterMap = null; else {
sortClusterMap = new ConcurrentHashMap<String, ScoreMap<String>>();
if (sortfields == null) this.sortClusterMap = null; else {
this.sortClusterMap = new ConcurrentHashMap<String, ScoreMap<String>>();
cluster = new ScoreMap[sortfields.length];
for (int i = 0; i < sortfields.length; i++) {
cluster[i] = new ConcurrentScoreMap<String>();
@ -84,18 +86,18 @@ public class MapDataMining extends MapHeap {
Long[] longaccumulator = null;
Float[] floataccumulator = null;
if (longaccfields == null) {
accLong = null;
this.accLong = null;
} else {
accLong = new ConcurrentHashMap<String, Long>();
this.accLong = new ConcurrentHashMap<String, Long>();
longaccumulator = new Long[longaccfields.length];
for (int i = 0; i < longaccfields.length; i++) {
longaccumulator[i] = LONG0;
}
}
if (floataccfields == null) {
accFloat = null;
this.accFloat = null;
} else {
accFloat = new ConcurrentHashMap<String, Float>();
this.accFloat = new ConcurrentHashMap<String, Float>();
floataccumulator = new Float[floataccfields.length];
for (int i = 0; i < floataccfields.length; i++) {
floataccumulator[i] = FLOAT0;
@ -114,7 +116,7 @@ public class MapDataMining extends MapHeap {
mapnameb = it.next();
try {
map = super.get(mapnameb);
} catch (RowSpaceExceededException e) {
} catch (final RowSpaceExceededException e) {
Log.logWarning("MapDataMining", e.getMessage());
break;
}
@ -146,37 +148,37 @@ public class MapDataMining extends MapHeap {
} catch (final IOException e) {}
// fill cluster
if (sortfields != null && cluster != null) for (int i = 0; i < sortfields.length; i++) sortClusterMap.put(sortfields[i], cluster[i]);
if (sortfields != null && cluster != null) for (int i = 0; i < sortfields.length; i++) this.sortClusterMap.put(sortfields[i], cluster[i]);
// fill acc map
if (longaccfields != null && longaccumulator != null) for (int i = 0; i < longaccfields.length; i++) accLong.put(longaccfields[i], longaccumulator[i]);
if (floataccfields != null && floataccumulator != null) for (int i = 0; i < floataccfields.length; i++) accFloat.put(floataccfields[i], floataccumulator[i]);
if (longaccfields != null && longaccumulator != null) for (int i = 0; i < longaccfields.length; i++) this.accLong.put(longaccfields[i], longaccumulator[i]);
if (floataccfields != null && floataccumulator != null) for (int i = 0; i < floataccfields.length; i++) this.accFloat.put(floataccfields[i], floataccumulator[i]);
}
@Override
public synchronized void clear() {
super.clear();
if (sortfields == null) sortClusterMap = null; else {
sortClusterMap = new HashMap<String, ScoreMap<String>>();
for (int i = 0; i < sortfields.length; i++) {
sortClusterMap.put(sortfields[i], new ConcurrentScoreMap<String>());
if (this.sortfields == null) this.sortClusterMap = null; else {
this.sortClusterMap = new HashMap<String, ScoreMap<String>>();
for (final String sortfield : this.sortfields) {
this.sortClusterMap.put(sortfield, new ConcurrentScoreMap<String>());
}
}
if (longaccfields == null) {
accLong = null;
if (this.longaccfields == null) {
this.accLong = null;
} else {
accLong = new HashMap<String, Long>();
for (int i = 0; i < longaccfields.length; i++) {
accLong.put(longaccfields[i], LONG0);
this.accLong = new HashMap<String, Long>();
for (final String longaccfield : this.longaccfields) {
this.accLong.put(longaccfield, LONG0);
}
}
if (floataccfields == null) {
accFloat = null;
if (this.floataccfields == null) {
this.accFloat = null;
} else {
accFloat = new HashMap<String, Float>();
for (int i = 0; i < floataccfields.length; i++) {
accFloat.put(floataccfields[i], FLOAT0);
this.accFloat = new HashMap<String, Float>();
for (final String floataccfield : this.floataccfields) {
this.accFloat.put(floataccfield, FLOAT0);
}
}
}
@ -188,7 +190,7 @@ public class MapDataMining extends MapHeap {
assert (newMap != null);
// update elementCount
if ((longaccfields != null) || (floataccfields != null)) {
if ((this.longaccfields != null) || (this.floataccfields != null)) {
final Map<String, String> oldMap = super.get(key, false);
if (oldMap != null) {
// element exists, update acc
@ -202,7 +204,7 @@ public class MapDataMining extends MapHeap {
super.insert(key, newMap);
// update sortCluster
if (sortClusterMap != null) updateSortCluster(UTF8.String(key), newMap);
if (this.sortClusterMap != null) updateSortCluster(UTF8.String(key), newMap);
}
private void updateAcc(final Map<String, String> map, final boolean add) {
@ -211,45 +213,47 @@ public class MapDataMining extends MapHeap {
float valued;
Long longaccumulator;
Float floataccumulator;
if (longaccfields != null) for (int i = 0; i < longaccfields.length; i++) {
value = map.get(longaccfields[i]);
if (value != null) {
try {
valuel = Long.parseLong(value);
longaccumulator = accLong.get(longaccfields[i]);
if (add) {
accLong.put(longaccfields[i], Long.valueOf(longaccumulator.longValue() + valuel));
} else {
accLong.put(longaccfields[i], Long.valueOf(longaccumulator.longValue() - valuel));
}
} catch (final NumberFormatException e) {}
if (this.longaccfields != null)
for (final String longaccfield : this.longaccfields) {
value = map.get(longaccfield);
if (value != null) {
try {
valuel = Long.parseLong(value);
longaccumulator = this.accLong.get(longaccfield);
if (add) {
this.accLong.put(longaccfield, Long.valueOf(longaccumulator.longValue() + valuel));
} else {
this.accLong.put(longaccfield, Long.valueOf(longaccumulator.longValue() - valuel));
}
} catch (final NumberFormatException e) {}
}
}
}
if (floataccfields != null) for (int i = 0; i < floataccfields.length; i++) {
value = map.get(floataccfields[i]);
if (value != null) {
try {
valued = Float.parseFloat(value);
floataccumulator = accFloat.get(floataccfields[i]);
if (add) {
accFloat.put(floataccfields[i], Float.valueOf(floataccumulator.floatValue() + valued));
} else {
accFloat.put(floataccfields[i], Float.valueOf(floataccumulator.floatValue() - valued));
}
} catch (final NumberFormatException e) {}
if (this.floataccfields != null)
for (final String floataccfield : this.floataccfields) {
value = map.get(floataccfield);
if (value != null) {
try {
valued = Float.parseFloat(value);
floataccumulator = this.accFloat.get(floataccfield);
if (add) {
this.accFloat.put(floataccfield, Float.valueOf(floataccumulator.floatValue() + valued));
} else {
this.accFloat.put(floataccfield, Float.valueOf(floataccumulator.floatValue() - valued));
}
} catch (final NumberFormatException e) {}
}
}
}
}
private void updateSortCluster(final String key, final Map<String, String> map) {
Object cell;
ScoreMap<String> cluster;
for (int i = 0; i < sortfields.length; i++) {
cell = map.get(sortfields[i]);
for (final String sortfield : this.sortfields) {
cell = map.get(sortfield);
if (cell != null) {
cluster = sortClusterMap.get(sortfields[i]);
cluster = this.sortClusterMap.get(sortfield);
cluster.set(key, ClusteredScoreMap.object2score(cell));
sortClusterMap.put(sortfields[i], cluster);
this.sortClusterMap.put(sortfield, cluster);
}
}
}
@ -259,19 +263,19 @@ public class MapDataMining extends MapHeap {
if (key == null) return;
// update elementCount
if (sortfields != null || longaccfields != null || floataccfields != null) {
if (this.sortfields != null || this.longaccfields != null || this.floataccfields != null) {
Map<String, String> map;
try {
map = super.get(key, false);
if (map != null) {
// update accumulators (subtract)
if (longaccfields != null || floataccfields != null) updateAcc(map, false);
if (this.longaccfields != null || this.floataccfields != null) updateAcc(map, false);
// remove from sortCluster
if (sortfields != null) deleteSortCluster(UTF8.String(key));
if (this.sortfields != null) deleteSortCluster(UTF8.String(key));
}
} catch (RowSpaceExceededException e) {
} catch (final RowSpaceExceededException e) {
map = null;
Log.logException(e);
}
@ -299,42 +303,42 @@ public class MapDataMining extends MapHeap {
private void deleteSortCluster(final String key) {
if (key == null) return;
ScoreMap<String> cluster;
for (int i = 0; i < sortfields.length; i++) {
cluster = sortClusterMap.get(sortfields[i]);
for (final String sortfield : this.sortfields) {
cluster = this.sortClusterMap.get(sortfield);
cluster.delete(key);
sortClusterMap.put(sortfields[i], cluster);
this.sortClusterMap.put(sortfield, cluster);
}
}
public synchronized Iterator<byte[]> keys(final boolean up, /* sorted by */ final String field) {
private synchronized Iterator<byte[]> keys(final boolean up, /* sorted by */ final String field) {
// sorted iteration using the sortClusters
if (sortClusterMap == null) return null;
final ScoreMap<String> cluster = sortClusterMap.get(field);
if (this.sortClusterMap == null) return null;
final ScoreMap<String> cluster = this.sortClusterMap.get(field);
if (cluster == null) return null; // sort field does not exist
//System.out.println("DEBUG: cluster for field " + field + ": " + cluster.toString());
return new string2bytearrayIterator(cluster.keys(up));
}
public static class string2bytearrayIterator implements Iterator<byte[]> {
private static class string2bytearrayIterator implements Iterator<byte[]> {
Iterator<String> s;
private final Iterator<String> s;
public string2bytearrayIterator(final Iterator<String> s) {
private string2bytearrayIterator(final Iterator<String> s) {
this.s = s;
}
public boolean hasNext() {
return s.hasNext();
return this.s.hasNext();
}
public byte[] next() {
final String r = s.next();
final String r = this.s.next();
if (r == null) return null;
return UTF8.getBytes(r);
}
public void remove() {
s.remove();
this.s.remove();
}
}
@ -352,13 +356,13 @@ public class MapDataMining extends MapHeap {
}
public synchronized long getLongAcc(final String field) {
final Long accumulator = accLong.get(field);
final Long accumulator = this.accLong.get(field);
if (accumulator == null) return -1;
return accumulator.longValue();
}
public synchronized float getFloatAcc(final String field) {
final Float accumulator = accFloat.get(field);
final Float accumulator = this.accFloat.get(field);
if (accumulator == null) return -1;
return accumulator.floatValue();
}
@ -376,9 +380,10 @@ public class MapDataMining extends MapHeap {
@Override
public synchronized void close() {
// close cluster
if (sortClusterMap != null) {
for (int i = 0; i < sortfields.length; i++) sortClusterMap.remove(sortfields[i]);
sortClusterMap = null;
if (this.sortClusterMap != null) {
for (final String sortfield : this.sortfields)
this.sortClusterMap.remove(sortfield);
this.sortClusterMap = null;
}
super.close();
@ -388,24 +393,24 @@ public class MapDataMining extends MapHeap {
// enumerates Map-Type elements
// the key is also included in every map that is returned; it's key is 'key'
Iterator<byte[]> keyIterator;
private final Iterator<byte[]> keyIterator;
public mapIterator(final Iterator<byte[]> keyIterator) {
private mapIterator(final Iterator<byte[]> keyIterator) {
this.keyIterator = keyIterator;
}
public Map<String, String> next0() {
if (keyIterator == null) return null;
if (this.keyIterator == null) return null;
byte[] nextKey;
Map<String, String> map;
while (keyIterator.hasNext()) {
nextKey = keyIterator.next();
while (this.keyIterator.hasNext()) {
nextKey = this.keyIterator.next();
try {
map = get(nextKey, false);
} catch (final IOException e) {
Log.logWarning("MapDataMining", e.getMessage());
continue;
} catch (RowSpaceExceededException e) {
} catch (final RowSpaceExceededException e) {
Log.logException(e);
continue;
}
@ -416,4 +421,36 @@ public class MapDataMining extends MapHeap {
return null;
}
} // class mapIterator
public static void main(final String[] args) {
try {
final MapDataMining db = new MapDataMining(new File("/tmp/MapDataMinig.test.db"), Word.commonHashLength, Base64Order.enhancedCoder, 1024 * 512, 500, new String[] {"X"}, new String[] {"X"}, new String[] {}, null);
final Map<String, String> m1 = new HashMap<String, String>(); m1.put("X", Long.toString(System.currentTimeMillis()));
db.put("abcdefghijk1".getBytes(), m1);
final Map<String, String> m2 = new HashMap<String, String>(); m2.put("X", Long.toString(System.currentTimeMillis() - 1000));
db.put("abcdefghijk2".getBytes(), m2);
final Map<String, String> m3 = new HashMap<String, String>(); m3.put("X", Long.toString(System.currentTimeMillis() + 2000));
db.put("abcdefghijk3".getBytes(), m3);
final Iterator<byte[]> i1 = db.keys(true, "X");
byte[] k;
while (i1.hasNext()) {
k = i1.next();
System.out.println(new String(k));
}
final Iterator<Map<String, String>> i2 = db.maps(false, "X");
Map<String, String> e;
while (i2.hasNext()) {
e = i2.next();
System.out.println(e);
}
System.exit(0);
} catch (final IOException e) {
e.printStackTrace();
}
}
}

@ -194,7 +194,7 @@ public class MapHeap implements Map<byte[], Map<String, String>> {
if (this.cache != null) this.cache.remove(key);
// remove from file
this.blob.delete(key);
if (this.blob != null) this.blob.delete(key);
}
}

@ -470,7 +470,7 @@ public class Table implements Index, Iterable<Row.Entry> {
Entry e = get0(key);
if (e != null && this.rowdef.objectOrder.equal(key, e.getPrimaryKeyBytes())) return e;
synchronized (this) {
assert this.file.size() == this.index.size() : "file.size() = " + this.file.size() + ", index.size() = " + this.index.size() + ", file = " + filename();
//assert this.file.size() == this.index.size() : "file.size() = " + this.file.size() + ", index.size() = " + this.index.size() + ", file = " + filename();
assert this.table == null || this.table.size() == this.index.size() : "table.size() = " + this.table.size() + ", index.size() = " + this.index.size() + ", file = " + filename();
e = get0(key);
assert e == null || this.rowdef.objectOrder.equal(key, e.getPrimaryKeyBytes());

@ -53,14 +53,14 @@ import net.yacy.visualization.RasterPlotter;
public class NetworkGraph {
private static int shortestName = 10;
private static int longestName = 12;
private static int longestName = 30;
public static final String COL_BACKGROUND = "FFFFFF";
private static final String COL_DHTCIRCLE = "006020";
private static final String COL_HEADLINE = "FFFFFF";
private static final String COL_ACTIVE_DOT = "000044";
private static final String COL_ACTIVE_LINE = "335544";
private static final String COL_ACTIVE_TEXT = "66AA88";
private static final String COL_ACTIVE_LINE = "113322";
private static final String COL_ACTIVE_TEXT = "226644";
private static final String COL_PASSIVE_DOT = "221111";
private static final String COL_PASSIVE_LINE = "443333";
private static final String COL_PASSIVE_TEXT = "663333";
@ -122,7 +122,7 @@ public class NetworkGraph {
if (primarySearches == null) return null; // this was a local search and there are no threads
// get a copy of a recent network picture
final RasterPlotter eventPicture = getNetworkPicture(seedDB, 120000, 640, 480, 300, 300, 1000, coronaangle, -1, Switchboard.getSwitchboard().getConfig(SwitchboardConstants.NETWORK_NAME, "unspecified"), Switchboard.getSwitchboard().getConfig("network.unit.description", "unspecified"), COL_BACKGROUND, cyc);
final RasterPlotter eventPicture = getNetworkPicture(seedDB, 120000, 640, 480, 300, 300, 9000, coronaangle, -1, Switchboard.getSwitchboard().getConfig(SwitchboardConstants.NETWORK_NAME, "unspecified"), Switchboard.getSwitchboard().getConfig("network.unit.description", "unspecified"), COL_BACKGROUND, cyc);
//if (eventPicture instanceof ymageMatrix) eventPicture = (ymageMatrix) eventPicture; //new ymageMatrix((ymageMatrix) eventPicture);
// TODO: fix cloning of ymageMatrix pictures
@ -131,13 +131,13 @@ public class NetworkGraph {
final int cx = eventPicture.getWidth() / 2;
final int cy = eventPicture.getHeight() / 2 + 20;
int angle;
double angle;
// draw in the primary search peers
for (final RemoteSearch primarySearche : primarySearches) {
if (primarySearche == null) continue;
eventPicture.setColor((primarySearche.isAlive()) ? RasterPlotter.RED : RasterPlotter.GREEN);
angle = cyc + (int) (360.0 * (((double) FlatWordPartitionScheme.std.dhtPosition(UTF8.getBytes(primarySearche.target().hash), null)) / ((double) Long.MAX_VALUE)));
angle = cyc + (360.0 * (((double) FlatWordPartitionScheme.std.dhtPosition(UTF8.getBytes(primarySearche.target().hash), null)) / ((double) Long.MAX_VALUE)));
eventPicture.arcLine(cx, cy, cr - 20, cr, angle, true, null, null, -1, -1, -1, false);
}
@ -146,9 +146,9 @@ public class NetworkGraph {
for (final RemoteSearch secondarySearche : secondarySearches) {
if (secondarySearche == null) continue;
eventPicture.setColor((secondarySearche.isAlive()) ? RasterPlotter.RED : RasterPlotter.GREEN);
angle = cyc + (int) (360.0 * (((double) FlatWordPartitionScheme.std.dhtPosition(UTF8.getBytes(secondarySearche.target().hash), null)) / ((double) Long.MAX_VALUE)));
eventPicture.arcLine(cx, cy, cr - 10, cr, angle - 1, true, null, null, -1, -1, -1, false);
eventPicture.arcLine(cx, cy, cr - 10, cr, angle + 1, true, null, null, -1, -1, -1, false);
angle = cyc + (360.0 * (((double) FlatWordPartitionScheme.std.dhtPosition(UTF8.getBytes(secondarySearche.target().hash), null)) / ((double) Long.MAX_VALUE)));
eventPicture.arcLine(cx, cy, cr - 10, cr, angle - 1.0, true, null, null, -1, -1, -1, false);
eventPicture.arcLine(cx, cy, cr - 10, cr, angle + 1.0, true, null, null, -1, -1, -1, false);
}
}
@ -159,7 +159,7 @@ public class NetworkGraph {
while (i.hasNext()) {
final long[] positions = seedDB.scheme.dhtPositions(i.next());
for (final long position : positions) {
angle = cyc + (int) (360.0 * (((double) position) / ((double) Long.MAX_VALUE)));
angle = cyc + (360.0 * (((double) position) / ((double) Long.MAX_VALUE)));
eventPicture.arcLine(cx, cy, cr - 20, cr, angle, true, null, null, -1, -1, -1, false);
}
}
@ -299,15 +299,15 @@ public class NetworkGraph {
final Seed seed,
final String colorDot, final String colorLine, final String colorText,
final int coronaangle,
final int cyc) {
final double cyc) {
final String name = seed.getName().toUpperCase() /*+ ":" + seed.hash + ":" + (((double) ((int) (100 * (((double) yacySeed.dhtPosition(seed.hash)) / ((double) yacySeed.maxDHTDistance))))) / 100.0)*/;
if (name.length() < shortestName) shortestName = name.length();
if (name.length() > longestName) longestName = name.length();
final int angle = cyc + (int) (360.0 * (((double) FlatWordPartitionScheme.std.dhtPosition(ASCII.getBytes(seed.hash), null)) / ((double) Long.MAX_VALUE)));
final double angle = cyc + (360.0d * (((double) FlatWordPartitionScheme.std.dhtPosition(ASCII.getBytes(seed.hash), null)) / ((double) Long.MAX_VALUE)));
//System.out.println("Seed " + seed.hash + " has distance " + seed.dhtDistance() + ", angle = " + angle);
int linelength = 20 + outerradius * (20 * (name.length() - shortestName) / (longestName - shortestName) + Math.abs(seed.hash.hashCode() % 20)) / 60;
int linelength = 20 + outerradius * (20 * (name.length() - shortestName) / (longestName - shortestName) + Math.abs(seed.hash.hashCode() % 20)) / 80;
if (linelength > outerradius) linelength = outerradius;
int dotsize = 4 + (int) (seed.getLinkCount() / 2000000L);
int dotsize = 2 + (int) (seed.getLinkCount() / 2000000L);
if (dotsize > 18) dotsize = 18;
// draw dot
img.setColor(colorDot);
@ -321,17 +321,17 @@ public class NetworkGraph {
// draw corona around dot for crawling activity
final int ppmx = seed.getPPM() / 40;
if (coronaangle >= 0 && ppmx > 0) {
drawCorona(img, centerX, centerY, innerradius, angle, dotsize, ppmx, coronaangle, true, false, 24, 24, 24); // color = 0..63
drawCorona(img, centerX, centerY, innerradius, angle, dotsize, ppmx, coronaangle, true, false, 2, 2, 2); // color = 0..63
}
// draw corona around dot for query activity
final int qphx = ((int) (seed.getQPM() * 4.0));
if (coronaangle >= 0 && qphx > 0) {
drawCorona(img, centerX, centerY, innerradius, angle, dotsize, qphx, coronaangle, false, true, 20, 63, 20); // color = 0..63
drawCorona(img, centerX, centerY, innerradius, angle, dotsize, qphx, coronaangle, false, true, 10, 40, 10); // color = 0..63
}
}
private static void drawCorona(final RasterPlotter img, final int centerX, final int centerY, final int innerradius, final int angle, final int dotsize, int strength, final int coronaangle, final boolean inside, final boolean split, final int r, final int g, final int b) {
private static void drawCorona(final RasterPlotter img, final int centerX, final int centerY, final int innerradius, final double angle, final int dotsize, int strength, final int coronaangle, final boolean inside, final boolean split, final int r, final int g, final int b) {
final double ca = Math.PI * 2.0 * (coronaangle) / 360.0;
if (strength > 4) strength = 4;
// draw a wave around crawling peers

@ -110,7 +110,7 @@ public class PrintTool {
private static final int arcDist = 8;
public static void arcPrint(final RasterPlotter matrix, final int cx, final int cy, final int radius, final int angle, final String message) {
public static void arcPrint(final RasterPlotter matrix, final int cx, final int cy, final int radius, final double angle, final String message) {
final int x = cx + (int) ((radius + 1) * Math.cos(RasterPlotter.PI180 * angle));
final int y = cy - (int) ((radius + 1) * Math.sin(RasterPlotter.PI180 * angle));
int yp = y + 3;

@ -335,9 +335,9 @@ public class RasterPlotter {
}
}
public void arcLine(final int cx, final int cy, final int innerRadius, final int outerRadius, final int angle, final boolean in,
public void arcLine(final int cx, final int cy, final int innerRadius, final int outerRadius, final double angle, final boolean in,
final String colorLine, final String colorDot, final int dotDist, final int dotPos, final int dotRadius, final boolean dotFilled) {
final double a = PI180 * (angle);
final double a = PI180 * angle;
final double cosa = Math.cos(a);
final double sina = Math.sin(a);
final int xi = cx + (int) (innerRadius * cosa);
@ -360,18 +360,18 @@ public class RasterPlotter {
}
}
public void arcDot(final int cx, final int cy, final int arcRadius, final int angle, final int dotRadius) {
final double a = PI180 * (angle);
public void arcDot(final int cx, final int cy, final int arcRadius, final double angle, final int dotRadius) {
final double a = PI180 * angle;
final int x = cx + (int) (arcRadius * Math.cos(a));
final int y = cy - (int) (arcRadius * Math.sin(a));
dot(x, y, dotRadius, true, 100);
}
public void arcConnect(final int cx, final int cy, final int arcRadius, final int angle1, final int angle2, final boolean in,
public void arcConnect(final int cx, final int cy, final int arcRadius, final double angle1, final double angle2, final boolean in,
final String colorLine, final int intensityLine,
final String colorDot, final int intensityDot, final int dotDist, final int dotPos, final int dotRadius, final boolean dotFilled) {
final double a1 = PI180 * (angle1);
final double a2 = PI180 * (angle2);
final double a1 = PI180 * angle1;
final double a2 = PI180 * angle2;
final int x1 = cx + (int) (arcRadius * Math.cos(a1));
final int y1 = cy - (int) (arcRadius * Math.sin(a1));
final int x2 = cx + (int) (arcRadius * Math.cos(a2));
@ -387,17 +387,17 @@ public class RasterPlotter {
}
}
public void arcArc(final int cx, final int cy, final int arcRadius, final int angle,
public void arcArc(final int cx, final int cy, final int arcRadius, final double angle,
final int innerRadius, final int outerRadius, final int intensity) {
final double a = PI180 * (angle);
final double a = PI180 * angle;
final int x = cx + (int) (arcRadius * Math.cos(a));
final int y = cy - (int) (arcRadius * Math.sin(a));
arc(x, y, innerRadius, outerRadius, intensity);
}
public void arcArc(final int cx, final int cy, final int arcRadius, final int angle,
public void arcArc(final int cx, final int cy, final int arcRadius, final double angle,
final int innerRadius, final int outerRadius, final int fromArc, final int toArc) {
final double a = PI180 * (angle);
final double a = PI180 * angle;
final int x = cx + (int) (arcRadius * Math.cos(a));
final int y = cy - (int) (arcRadius * Math.sin(a));
arc(x, y, innerRadius, outerRadius, fromArc, toArc);

Loading…
Cancel
Save