- 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"> <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; imageanimindex = 0;
imageloadindex = 0; imageloadindex = 0;
imagecycles = 0; imagecycles = 0;
@ -23,7 +23,7 @@
for (j = 0; j < 6; j++) initanimationphase(j, handle); for (j = 0; j < 6; j++) initanimationphase(j, handle);
} }
function initanimationphase(phase, handle) { function initanimationphase(phase, handle) {
imagearray[phase] = new Image(1024, 576); imagearray[phase] = new Image(1024, 1024);
angle = phase * 60; angle = phase * 60;
imagearray[phase].src = imagestub + angle + "&handle=" + handle; 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> <h3>YaCy Network</h3>
<ul class="SubMenu"> <ul class="SubMenu">
<li><a href="/Network.html" class="MenuItemLink">Network Overview</a></li> <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=1&maxCount=1000" 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=2&maxCount=1000" 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=3&maxCount=1000" class="MenuItemLink">Potential&nbsp;Peers</a></li>
</ul> </ul>
</div> </div>
#(/menu)# #(/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"> <div class="left">
<p> <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> </p>
</div> </div>
<div class="left"> <div class="left">

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

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

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

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

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

@ -223,4 +223,13 @@ public class ConcurrentScoreMap<E> extends AbstractScoreMap<E> implements ScoreM
return r.iterator(); 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());
}
} }

@ -10,7 +10,7 @@
// $LastChangedBy$ // $LastChangedBy$
// //
// LICENSE // LICENSE
// //
// This program is free software; you can redistribute it and/or modify // 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 // it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or // the Free Software Foundation; either version 2 of the License, or
@ -38,15 +38,17 @@ import net.yacy.cora.document.UTF8;
import net.yacy.cora.ranking.ClusteredScoreMap; import net.yacy.cora.ranking.ClusteredScoreMap;
import net.yacy.cora.ranking.ConcurrentScoreMap; import net.yacy.cora.ranking.ConcurrentScoreMap;
import net.yacy.cora.ranking.ScoreMap; import net.yacy.cora.ranking.ScoreMap;
import net.yacy.kelondro.data.word.Word;
import net.yacy.kelondro.index.RowSpaceExceededException; import net.yacy.kelondro.index.RowSpaceExceededException;
import net.yacy.kelondro.logging.Log; import net.yacy.kelondro.logging.Log;
import net.yacy.kelondro.order.Base64Order;
import net.yacy.kelondro.order.ByteOrder; import net.yacy.kelondro.order.ByteOrder;
import net.yacy.kelondro.order.CloneableIterator; import net.yacy.kelondro.order.CloneableIterator;
import net.yacy.kelondro.util.LookAheadIterator; import net.yacy.kelondro.util.LookAheadIterator;
public class MapDataMining extends MapHeap { public class MapDataMining extends MapHeap {
private final static Long LONG0 = Long.valueOf(0); private final static Long LONG0 = Long.valueOf(0);
private final static Float FLOAT0 = Float.valueOf(0.0f); private final static Float FLOAT0 = Float.valueOf(0.0f);
@ -54,51 +56,51 @@ public class MapDataMining extends MapHeap {
private Map<String, ScoreMap<String>> sortClusterMap; // a String-kelondroMScoreCluster - relation private Map<String, ScoreMap<String>> sortClusterMap; // a String-kelondroMScoreCluster - relation
private Map<String, Long> accLong; // to store accumulations of Long cells private Map<String, Long> accLong; // to store accumulations of Long cells
private Map<String, Float> accFloat; // to store accumulations of Float cells private Map<String, Float> accFloat; // to store accumulations of Float cells
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public MapDataMining(final File heapFile, public MapDataMining(final File heapFile,
final int keylength, final int keylength,
final ByteOrder ordering, final ByteOrder ordering,
int buffermax, final int buffermax,
final int cachesize, final int cachesize,
final String[] sortfields, final String[] sortfields,
final String[] longaccfields, final String[] longaccfields,
final String[] floataccfields, final String[] floataccfields,
final Object externalHandler) throws IOException { final Object externalHandler) throws IOException {
super(heapFile, keylength, ordering, buffermax, cachesize, ' '); super(heapFile, keylength, ordering, buffermax, cachesize, ' ');
// create fast ordering clusters and acc fields // create fast ordering clusters and acc fields
this.sortfields = sortfields; this.sortfields = sortfields;
this.longaccfields = longaccfields; this.longaccfields = longaccfields;
this.floataccfields = floataccfields; this.floataccfields = floataccfields;
ScoreMap<String>[] cluster = null; ScoreMap<String>[] cluster = null;
if (sortfields == null) sortClusterMap = null; else { if (sortfields == null) this.sortClusterMap = null; else {
sortClusterMap = new ConcurrentHashMap<String, ScoreMap<String>>(); this.sortClusterMap = new ConcurrentHashMap<String, ScoreMap<String>>();
cluster = new ScoreMap[sortfields.length]; cluster = new ScoreMap[sortfields.length];
for (int i = 0; i < sortfields.length; i++) { for (int i = 0; i < sortfields.length; i++) {
cluster[i] = new ConcurrentScoreMap<String>(); cluster[i] = new ConcurrentScoreMap<String>();
} }
} }
Long[] longaccumulator = null; Long[] longaccumulator = null;
Float[] floataccumulator = null; Float[] floataccumulator = null;
if (longaccfields == null) { if (longaccfields == null) {
accLong = null; this.accLong = null;
} else { } else {
accLong = new ConcurrentHashMap<String, Long>(); this.accLong = new ConcurrentHashMap<String, Long>();
longaccumulator = new Long[longaccfields.length]; longaccumulator = new Long[longaccfields.length];
for (int i = 0; i < longaccfields.length; i++) { for (int i = 0; i < longaccfields.length; i++) {
longaccumulator[i] = LONG0; longaccumulator[i] = LONG0;
} }
} }
if (floataccfields == null) { if (floataccfields == null) {
accFloat = null; this.accFloat = null;
} else { } else {
accFloat = new ConcurrentHashMap<String, Float>(); this.accFloat = new ConcurrentHashMap<String, Float>();
floataccumulator = new Float[floataccfields.length]; floataccumulator = new Float[floataccfields.length];
for (int i = 0; i < floataccfields.length; i++) { for (int i = 0; i < floataccfields.length; i++) {
floataccumulator[i] = FLOAT0; floataccumulator[i] = FLOAT0;
} }
} }
@ -114,12 +116,12 @@ public class MapDataMining extends MapHeap {
mapnameb = it.next(); mapnameb = it.next();
try { try {
map = super.get(mapnameb); map = super.get(mapnameb);
} catch (RowSpaceExceededException e) { } catch (final RowSpaceExceededException e) {
Log.logWarning("MapDataMining", e.getMessage()); Log.logWarning("MapDataMining", e.getMessage());
break; break;
} }
if (map == null) break; if (map == null) break;
if (sortfields != null && cluster != null) for (int i = 0; i < sortfields.length; i++) { if (sortfields != null && cluster != null) for (int i = 0; i < sortfields.length; i++) {
cell = map.get(sortfields[i]); cell = map.get(sortfields[i]);
if (cell != null) cluster[i].set(UTF8.String(mapnameb), ClusteredScoreMap.object2score(cell)); if (cell != null) cluster[i].set(UTF8.String(mapnameb), ClusteredScoreMap.object2score(cell));
@ -133,7 +135,7 @@ public class MapDataMining extends MapHeap {
longaccumulator[i] = Long.valueOf(longaccumulator[i].longValue() + valuel); longaccumulator[i] = Long.valueOf(longaccumulator[i].longValue() + valuel);
} catch (final NumberFormatException e) {} } catch (final NumberFormatException e) {}
} }
if (floataccfields != null && floataccumulator != null) for (int i = 0; i < floataccfields.length; i++) { if (floataccfields != null && floataccumulator != null) for (int i = 0; i < floataccfields.length; i++) {
cell = map.get(floataccfields[i]); cell = map.get(floataccfields[i]);
valued = 0f; valued = 0f;
@ -146,41 +148,41 @@ public class MapDataMining extends MapHeap {
} catch (final IOException e) {} } catch (final IOException e) {}
// fill cluster // 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 // fill acc map
if (longaccfields != null && longaccumulator != null) for (int i = 0; i < longaccfields.length; i++) accLong.put(longaccfields[i], longaccumulator[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++) accFloat.put(floataccfields[i], floataccumulator[i]); if (floataccfields != null && floataccumulator != null) for (int i = 0; i < floataccfields.length; i++) this.accFloat.put(floataccfields[i], floataccumulator[i]);
} }
@Override @Override
public synchronized void clear() { public synchronized void clear() {
super.clear(); super.clear();
if (sortfields == null) sortClusterMap = null; else { if (this.sortfields == null) this.sortClusterMap = null; else {
sortClusterMap = new HashMap<String, ScoreMap<String>>(); this.sortClusterMap = new HashMap<String, ScoreMap<String>>();
for (int i = 0; i < sortfields.length; i++) { for (final String sortfield : this.sortfields) {
sortClusterMap.put(sortfields[i], new ConcurrentScoreMap<String>()); this.sortClusterMap.put(sortfield, new ConcurrentScoreMap<String>());
} }
} }
if (longaccfields == null) { if (this.longaccfields == null) {
accLong = null; this.accLong = null;
} else { } else {
accLong = new HashMap<String, Long>(); this.accLong = new HashMap<String, Long>();
for (int i = 0; i < longaccfields.length; i++) { for (final String longaccfield : this.longaccfields) {
accLong.put(longaccfields[i], LONG0); this.accLong.put(longaccfield, LONG0);
} }
} }
if (floataccfields == null) { if (this.floataccfields == null) {
accFloat = null; this.accFloat = null;
} else { } else {
accFloat = new HashMap<String, Float>(); this.accFloat = new HashMap<String, Float>();
for (int i = 0; i < floataccfields.length; i++) { for (final String floataccfield : this.floataccfields) {
accFloat.put(floataccfields[i], FLOAT0); this.accFloat.put(floataccfield, FLOAT0);
} }
} }
} }
@Override @Override
public synchronized void insert(final byte[] key, final Map<String, String> newMap) throws IOException, RowSpaceExceededException { public synchronized void insert(final byte[] key, final Map<String, String> newMap) throws IOException, RowSpaceExceededException {
assert (key != null); assert (key != null);
@ -188,68 +190,70 @@ public class MapDataMining extends MapHeap {
assert (newMap != null); assert (newMap != null);
// update elementCount // update elementCount
if ((longaccfields != null) || (floataccfields != null)) { if ((this.longaccfields != null) || (this.floataccfields != null)) {
final Map<String, String> oldMap = super.get(key, false); final Map<String, String> oldMap = super.get(key, false);
if (oldMap != null) { if (oldMap != null) {
// element exists, update acc // element exists, update acc
updateAcc(oldMap, false); updateAcc(oldMap, false);
} }
// update accumulators with new values (add) // update accumulators with new values (add)
updateAcc(newMap, true); updateAcc(newMap, true);
} }
super.insert(key, newMap); super.insert(key, newMap);
// update sortCluster // 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) { private void updateAcc(final Map<String, String> map, final boolean add) {
String value; String value;
long valuel; long valuel;
float valued; float valued;
Long longaccumulator; Long longaccumulator;
Float floataccumulator; Float floataccumulator;
if (longaccfields != null) for (int i = 0; i < longaccfields.length; i++) { if (this.longaccfields != null)
value = map.get(longaccfields[i]); for (final String longaccfield : this.longaccfields) {
if (value != null) { value = map.get(longaccfield);
try { if (value != null) {
valuel = Long.parseLong(value); try {
longaccumulator = accLong.get(longaccfields[i]); valuel = Long.parseLong(value);
if (add) { longaccumulator = this.accLong.get(longaccfield);
accLong.put(longaccfields[i], Long.valueOf(longaccumulator.longValue() + valuel)); if (add) {
} else { this.accLong.put(longaccfield, Long.valueOf(longaccumulator.longValue() + valuel));
accLong.put(longaccfields[i], Long.valueOf(longaccumulator.longValue() - valuel)); } else {
} this.accLong.put(longaccfield, Long.valueOf(longaccumulator.longValue() - valuel));
} catch (final NumberFormatException e) {} }
} catch (final NumberFormatException e) {}
}
} }
} if (this.floataccfields != null)
if (floataccfields != null) for (int i = 0; i < floataccfields.length; i++) { for (final String floataccfield : this.floataccfields) {
value = map.get(floataccfields[i]); value = map.get(floataccfield);
if (value != null) { if (value != null) {
try { try {
valued = Float.parseFloat(value); valued = Float.parseFloat(value);
floataccumulator = accFloat.get(floataccfields[i]); floataccumulator = this.accFloat.get(floataccfield);
if (add) { if (add) {
accFloat.put(floataccfields[i], Float.valueOf(floataccumulator.floatValue() + valued)); this.accFloat.put(floataccfield, Float.valueOf(floataccumulator.floatValue() + valued));
} else { } else {
accFloat.put(floataccfields[i], Float.valueOf(floataccumulator.floatValue() - valued)); this.accFloat.put(floataccfield, Float.valueOf(floataccumulator.floatValue() - valued));
} }
} catch (final NumberFormatException e) {} } catch (final NumberFormatException e) {}
}
} }
}
} }
private void updateSortCluster(final String key, final Map<String, String> map) { private void updateSortCluster(final String key, final Map<String, String> map) {
Object cell; Object cell;
ScoreMap<String> cluster; ScoreMap<String> cluster;
for (int i = 0; i < sortfields.length; i++) { for (final String sortfield : this.sortfields) {
cell = map.get(sortfields[i]); cell = map.get(sortfield);
if (cell != null) { if (cell != null) {
cluster = sortClusterMap.get(sortfields[i]); cluster = this.sortClusterMap.get(sortfield);
cluster.set(key, ClusteredScoreMap.object2score(cell)); cluster.set(key, ClusteredScoreMap.object2score(cell));
sortClusterMap.put(sortfields[i], cluster); this.sortClusterMap.put(sortfield, cluster);
} }
} }
} }
@ -257,33 +261,33 @@ public class MapDataMining extends MapHeap {
@Override @Override
public synchronized void delete(final byte[] key) throws IOException { public synchronized void delete(final byte[] key) throws IOException {
if (key == null) return; if (key == null) return;
// update elementCount // update elementCount
if (sortfields != null || longaccfields != null || floataccfields != null) { if (this.sortfields != null || this.longaccfields != null || this.floataccfields != null) {
Map<String, String> map; Map<String, String> map;
try { try {
map = super.get(key, false); map = super.get(key, false);
if (map != null) { if (map != null) {
// update accumulators (subtract) // update accumulators (subtract)
if (longaccfields != null || floataccfields != null) updateAcc(map, false); if (this.longaccfields != null || this.floataccfields != null) updateAcc(map, false);
// remove from sortCluster // 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; map = null;
Log.logException(e); Log.logException(e);
} }
} }
super.delete(key); super.delete(key);
} }
/* would be better but does not work (recursion) /* would be better but does not work (recursion)
@Override @Override
public synchronized void delete(final byte[] key) throws IOException { public synchronized void delete(final byte[] key) throws IOException {
if (key == null) return; if (key == null) return;
// update elementCount // update elementCount
Map<String, String> map = super.remove(key); Map<String, String> map = super.remove(key);
if (map != null && (sortfields != null || longaccfields != null || floataccfields != null)) { if (map != null && (sortfields != null || longaccfields != null || floataccfields != null)) {
@ -299,50 +303,50 @@ public class MapDataMining extends MapHeap {
private void deleteSortCluster(final String key) { private void deleteSortCluster(final String key) {
if (key == null) return; if (key == null) return;
ScoreMap<String> cluster; ScoreMap<String> cluster;
for (int i = 0; i < sortfields.length; i++) { for (final String sortfield : this.sortfields) {
cluster = sortClusterMap.get(sortfields[i]); cluster = this.sortClusterMap.get(sortfield);
cluster.delete(key); 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 // sorted iteration using the sortClusters
if (sortClusterMap == null) return null; if (this.sortClusterMap == null) return null;
final ScoreMap<String> cluster = sortClusterMap.get(field); final ScoreMap<String> cluster = this.sortClusterMap.get(field);
if (cluster == null) return null; // sort field does not exist if (cluster == null) return null; // sort field does not exist
//System.out.println("DEBUG: cluster for field " + field + ": " + cluster.toString()); //System.out.println("DEBUG: cluster for field " + field + ": " + cluster.toString());
return new string2bytearrayIterator(cluster.keys(up)); return new string2bytearrayIterator(cluster.keys(up));
} }
public static class string2bytearrayIterator implements Iterator<byte[]> {
Iterator<String> s; private static class string2bytearrayIterator implements Iterator<byte[]> {
public string2bytearrayIterator(final Iterator<String> s) { private final Iterator<String> s;
private string2bytearrayIterator(final Iterator<String> s) {
this.s = s; this.s = s;
} }
public boolean hasNext() { public boolean hasNext() {
return s.hasNext(); return this.s.hasNext();
} }
public byte[] next() { public byte[] next() {
final String r = s.next(); final String r = this.s.next();
if (r == null) return null; if (r == null) return null;
return UTF8.getBytes(r); return UTF8.getBytes(r);
} }
public void remove() { public void remove() {
s.remove(); this.s.remove();
} }
} }
public synchronized mapIterator maps(final boolean up, final String field) { public synchronized mapIterator maps(final boolean up, final String field) {
return new mapIterator(keys(up, field)); return new mapIterator(keys(up, field));
} }
public synchronized mapIterator maps(final boolean up, final boolean rotating) throws IOException { public synchronized mapIterator maps(final boolean up, final boolean rotating) throws IOException {
return new mapIterator(keys(up, rotating)); return new mapIterator(keys(up, rotating));
} }
@ -350,62 +354,63 @@ public class MapDataMining extends MapHeap {
public synchronized mapIterator maps(final boolean up, final boolean rotating, final byte[] firstKey, final byte[] secondKey) throws IOException { public synchronized mapIterator maps(final boolean up, final boolean rotating, final byte[] firstKey, final byte[] secondKey) throws IOException {
return new mapIterator(keys(up, rotating, firstKey, secondKey)); return new mapIterator(keys(up, rotating, firstKey, secondKey));
} }
public synchronized long getLongAcc(final String field) { 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; if (accumulator == null) return -1;
return accumulator.longValue(); return accumulator.longValue();
} }
public synchronized float getFloatAcc(final String field) { 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; if (accumulator == null) return -1;
return accumulator.floatValue(); return accumulator.floatValue();
} }
@Override @Override
public synchronized int size() { public synchronized int size() {
return super.size(); return super.size();
} }
@Override @Override
public synchronized boolean isEmpty() { public synchronized boolean isEmpty() {
return super.isEmpty(); return super.isEmpty();
} }
@Override @Override
public synchronized void close() { public synchronized void close() {
// close cluster // close cluster
if (sortClusterMap != null) { if (this.sortClusterMap != null) {
for (int i = 0; i < sortfields.length; i++) sortClusterMap.remove(sortfields[i]); for (final String sortfield : this.sortfields)
sortClusterMap = null; this.sortClusterMap.remove(sortfield);
this.sortClusterMap = null;
} }
super.close(); super.close();
} }
public class mapIterator extends LookAheadIterator<Map<String, String>> implements Iterator<Map<String, String>> { public class mapIterator extends LookAheadIterator<Map<String, String>> implements Iterator<Map<String, String>> {
// enumerates Map-Type elements // enumerates Map-Type elements
// the key is also included in every map that is returned; it's key is 'key' // 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; this.keyIterator = keyIterator;
} }
public Map<String, String> next0() { public Map<String, String> next0() {
if (keyIterator == null) return null; if (this.keyIterator == null) return null;
byte[] nextKey; byte[] nextKey;
Map<String, String> map; Map<String, String> map;
while (keyIterator.hasNext()) { while (this.keyIterator.hasNext()) {
nextKey = keyIterator.next(); nextKey = this.keyIterator.next();
try { try {
map = get(nextKey, false); map = get(nextKey, false);
} catch (final IOException e) { } catch (final IOException e) {
Log.logWarning("MapDataMining", e.getMessage()); Log.logWarning("MapDataMining", e.getMessage());
continue; continue;
} catch (RowSpaceExceededException e) { } catch (final RowSpaceExceededException e) {
Log.logException(e); Log.logException(e);
continue; continue;
} }
@ -416,4 +421,36 @@ public class MapDataMining extends MapHeap {
return null; return null;
} }
} // class mapIterator } // 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); if (this.cache != null) this.cache.remove(key);
// remove from file // 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); Entry e = get0(key);
if (e != null && this.rowdef.objectOrder.equal(key, e.getPrimaryKeyBytes())) return e; if (e != null && this.rowdef.objectOrder.equal(key, e.getPrimaryKeyBytes())) return e;
synchronized (this) { 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(); 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); e = get0(key);
assert e == null || this.rowdef.objectOrder.equal(key, e.getPrimaryKeyBytes()); assert e == null || this.rowdef.objectOrder.equal(key, e.getPrimaryKeyBytes());

@ -53,14 +53,14 @@ import net.yacy.visualization.RasterPlotter;
public class NetworkGraph { public class NetworkGraph {
private static int shortestName = 10; private static int shortestName = 10;
private static int longestName = 12; private static int longestName = 30;
public static final String COL_BACKGROUND = "FFFFFF"; public static final String COL_BACKGROUND = "FFFFFF";
private static final String COL_DHTCIRCLE = "006020"; private static final String COL_DHTCIRCLE = "006020";
private static final String COL_HEADLINE = "FFFFFF"; private static final String COL_HEADLINE = "FFFFFF";
private static final String COL_ACTIVE_DOT = "000044"; private static final String COL_ACTIVE_DOT = "000044";
private static final String COL_ACTIVE_LINE = "335544"; private static final String COL_ACTIVE_LINE = "113322";
private static final String COL_ACTIVE_TEXT = "66AA88"; private static final String COL_ACTIVE_TEXT = "226644";
private static final String COL_PASSIVE_DOT = "221111"; private static final String COL_PASSIVE_DOT = "221111";
private static final String COL_PASSIVE_LINE = "443333"; private static final String COL_PASSIVE_LINE = "443333";
private static final String COL_PASSIVE_TEXT = "663333"; 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 if (primarySearches == null) return null; // this was a local search and there are no threads
// get a copy of a recent network picture // 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); //if (eventPicture instanceof ymageMatrix) eventPicture = (ymageMatrix) eventPicture; //new ymageMatrix((ymageMatrix) eventPicture);
// TODO: fix cloning of ymageMatrix pictures // TODO: fix cloning of ymageMatrix pictures
@ -131,13 +131,13 @@ public class NetworkGraph {
final int cx = eventPicture.getWidth() / 2; final int cx = eventPicture.getWidth() / 2;
final int cy = eventPicture.getHeight() / 2 + 20; final int cy = eventPicture.getHeight() / 2 + 20;
int angle; double angle;
// draw in the primary search peers // draw in the primary search peers
for (final RemoteSearch primarySearche : primarySearches) { for (final RemoteSearch primarySearche : primarySearches) {
if (primarySearche == null) continue; if (primarySearche == null) continue;
eventPicture.setColor((primarySearche.isAlive()) ? RasterPlotter.RED : RasterPlotter.GREEN); 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); 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) { for (final RemoteSearch secondarySearche : secondarySearches) {
if (secondarySearche == null) continue; if (secondarySearche == null) continue;
eventPicture.setColor((secondarySearche.isAlive()) ? RasterPlotter.RED : RasterPlotter.GREEN); 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))); 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, true, null, null, -1, -1, -1, false); 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, 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()) { while (i.hasNext()) {
final long[] positions = seedDB.scheme.dhtPositions(i.next()); final long[] positions = seedDB.scheme.dhtPositions(i.next());
for (final long position : positions) { 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); 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 Seed seed,
final String colorDot, final String colorLine, final String colorText, final String colorDot, final String colorLine, final String colorText,
final int coronaangle, 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)*/; 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() < shortestName) shortestName = name.length();
if (name.length() > longestName) longestName = 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); //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; if (linelength > outerradius) linelength = outerradius;
int dotsize = 4 + (int) (seed.getLinkCount() / 2000000L); int dotsize = 2 + (int) (seed.getLinkCount() / 2000000L);
if (dotsize > 18) dotsize = 18; if (dotsize > 18) dotsize = 18;
// draw dot // draw dot
img.setColor(colorDot); img.setColor(colorDot);
@ -321,17 +321,17 @@ public class NetworkGraph {
// draw corona around dot for crawling activity // draw corona around dot for crawling activity
final int ppmx = seed.getPPM() / 40; final int ppmx = seed.getPPM() / 40;
if (coronaangle >= 0 && ppmx > 0) { 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 // draw corona around dot for query activity
final int qphx = ((int) (seed.getQPM() * 4.0)); final int qphx = ((int) (seed.getQPM() * 4.0));
if (coronaangle >= 0 && qphx > 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; final double ca = Math.PI * 2.0 * (coronaangle) / 360.0;
if (strength > 4) strength = 4; if (strength > 4) strength = 4;
// draw a wave around crawling peers // draw a wave around crawling peers

@ -110,7 +110,7 @@ public class PrintTool {
private static final int arcDist = 8; 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 x = cx + (int) ((radius + 1) * Math.cos(RasterPlotter.PI180 * angle));
final int y = cy - (int) ((radius + 1) * Math.sin(RasterPlotter.PI180 * angle)); final int y = cy - (int) ((radius + 1) * Math.sin(RasterPlotter.PI180 * angle));
int yp = y + 3; 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 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 cosa = Math.cos(a);
final double sina = Math.sin(a); final double sina = Math.sin(a);
final int xi = cx + (int) (innerRadius * cosa); 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) { public void arcDot(final int cx, final int cy, final int arcRadius, final double angle, final int dotRadius) {
final double a = PI180 * (angle); final double a = PI180 * angle;
final int x = cx + (int) (arcRadius * Math.cos(a)); final int x = cx + (int) (arcRadius * Math.cos(a));
final int y = cy - (int) (arcRadius * Math.sin(a)); final int y = cy - (int) (arcRadius * Math.sin(a));
dot(x, y, dotRadius, true, 100); 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 colorLine, final int intensityLine,
final String colorDot, final int intensityDot, final int dotDist, final int dotPos, final int dotRadius, final boolean dotFilled) { 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 a1 = PI180 * angle1;
final double a2 = PI180 * (angle2); final double a2 = PI180 * angle2;
final int x1 = cx + (int) (arcRadius * Math.cos(a1)); final int x1 = cx + (int) (arcRadius * Math.cos(a1));
final int y1 = cy - (int) (arcRadius * Math.sin(a1)); final int y1 = cy - (int) (arcRadius * Math.sin(a1));
final int x2 = cx + (int) (arcRadius * Math.cos(a2)); 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 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 x = cx + (int) (arcRadius * Math.cos(a));
final int y = cy - (int) (arcRadius * Math.sin(a)); final int y = cy - (int) (arcRadius * Math.sin(a));
arc(x, y, innerRadius, outerRadius, intensity); 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 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 x = cx + (int) (arcRadius * Math.cos(a));
final int y = cy - (int) (arcRadius * Math.sin(a)); final int y = cy - (int) (arcRadius * Math.sin(a));
arc(x, y, innerRadius, outerRadius, fromArc, toArc); arc(x, y, innerRadius, outerRadius, fromArc, toArc);

Loading…
Cancel
Save