Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
*) Banner features a logo now. It does not look nice, but at least it works. Banner is not finished yet.
low01272698fcd36d4
diff --git a/htroot/Banner.java b/htroot/Banner.javaindex c3d63aa6f..d169c2942 100644--- a/htroot/Banner.java+++ b/htroot/Banner.java@@ -46,17 +46,29 @@import de.anomic.http.httpHeader;import de.anomic.plasma.plasmaGrafics;+import de.anomic.plasma.plasmaSwitchboard;+import de.anomic.server.serverCore;+import de.anomic.server.serverDomains;import de.anomic.server.serverObjects;import de.anomic.server.serverSwitch;import de.anomic.ymage.ymageMatrix;import de.anomic.yacy.yacyCore;import de.anomic.yacy.yacySeed;+import java.awt.Image;+import java.awt.image.BufferedImage;+import java.awt.Toolkit;+import java.io.File;+import java.io.IOException;+import java.net.URL;+import javax.imageio.ImageIO;+/** draw a banner with information about the peer */public class Banner {- public static ymageMatrix respond(httpHeader header, serverObjects post, serverSwitch env) {+ public static ymageMatrix respond(httpHeader header, serverObjects post, serverSwitch env) throws IOException {+ final String IMAGE = "env/grafics/yacy.gif";int width = 468;int height = 60;String bgcolor = plasmaGrafics.COL_BACKGROUND;@@ -84,16 +96,16 @@ public class Banner {yacySeed seed = yacyCore.seedDB.mySeed();if (seed != null){- name = seed.get(yacySeed.NAME, "-").toUpperCase();- links = Long.parseLong(seed.get(yacySeed.LCOUNT, "0"));- words = Long.parseLong(seed.get(yacySeed.ICOUNT, "0"));- myppm = seed.getPPM();- myqph = 60d * seed.getQPM();+ name = seed.get(yacySeed.NAME, "-").toUpperCase();+ links = Long.parseLong(seed.get(yacySeed.LCOUNT, "0"));+ words = Long.parseLong(seed.get(yacySeed.ICOUNT, "0"));+ myppm = seed.getPPM();+ myqph = 60d * seed.getQPM();network = env.getConfig("network.unit.name", "unspecified").toUpperCase();- nlinks = yacyCore.seedDB.countActiveURL();- nwords = yacyCore.seedDB.countActiveRWI();- nqpm = yacyCore.seedDB.countActiveQPM();- nppm = yacyCore.seedDB.countActivePPM();+ nlinks = yacyCore.seedDB.countActiveURL();+ nwords = yacyCore.seedDB.countActiveRWI();+ nqpm = yacyCore.seedDB.countActiveQPM();+ nppm = yacyCore.seedDB.countActivePPM();if (yacyCore.seedDB.mySeed().isVirgin()) {type = "VIRGIN";@@ -116,6 +128,15 @@ public class Banner {}}+ if (!plasmaGrafics.logoIsLoaded()) {+ plasmaSwitchboard switchboard = (plasmaSwitchboard)env;+ int port = serverCore.getPortNr(switchboard.getConfig("port", "8080"));+ String host = serverDomains.myPublicLocalIP().getHostAddress();+ BufferedImage logo = ImageIO.read(new URL("http://"+host+":"+port+"/"+IMAGE));+ //BufferedImage logo = ImageIO.read(new File(IMAGE));+ return plasmaGrafics.getBannerPicture(1000, width, height, bgcolor, textcolor, bordercolor, name, links, words, type, myppm, network, nlinks, nwords, nqph, nppm, logo);+ }+return plasmaGrafics.getBannerPicture(1000, width, height, bgcolor, textcolor, bordercolor, name, links, words, type, myppm, network, nlinks, nwords, nqph, nppm);}diff --git a/source/de/anomic/plasma/plasmaGrafics.java b/source/de/anomic/plasma/plasmaGrafics.javaindex 2be362aae..2c25f8a63 100644--- a/source/de/anomic/plasma/plasmaGrafics.java+++ b/source/de/anomic/plasma/plasmaGrafics.java@@ -49,6 +49,7 @@ package de.anomic.plasma;import java.awt.Color;import java.awt.Graphics2D;+import java.awt.Image;import java.awt.RenderingHints;import java.awt.image.BufferedImage;import java.util.Date;@@ -122,6 +123,7 @@ public class plasmaGrafics {private static long peerloadPictureDate = 0;private static ymageMatrix bannerPicture = null; // [MN]+ private static BufferedImage logo = null; // [MN]private static long bannerPictureDate = 0; // [MN]public static ymageMatrix getSearchEventPicture(String eventID) {@@ -363,16 +365,26 @@ public class plasmaGrafics {//[MN]public static ymageMatrix getBannerPicture(long maxAge, int width, int height, String bgcolor, String textcolor, String bordercolor, String name, long links, long words, String type, int ppm, String network, long nlinks, long nwords, double nqph, long nppm) {if ((bannerPicture == null) || ((System.currentTimeMillis() - bannerPictureDate) > maxAge)) {- drawBannerPicture(width, height, bgcolor, textcolor, bordercolor, name, links, words, type, ppm, network, nlinks, nwords, nqph, nppm);+ drawBannerPicture(width, height, bgcolor, textcolor, bordercolor, name, links, words, type, ppm, network, nlinks, nwords, nqph, nppm, logo);+ }+ return bannerPicture;+ }++ //[MN]+ public static ymageMatrix getBannerPicture(long maxAge, int width, int height, String bgcolor, String textcolor, String bordercolor, String name, long links, long words, String type, int ppm, String network, long nlinks, long nwords, double nqph, long nppm, BufferedImage newLogo) {+ if ((bannerPicture == null) || ((System.currentTimeMillis() - bannerPictureDate) > maxAge)) {+ drawBannerPicture(width, height, bgcolor, textcolor, bordercolor, name, links, words, type, ppm, network, nlinks, nwords, nqph, nppm, newLogo);}return bannerPicture;}//[MN]- private static void drawBannerPicture(int width, int height, String bgcolor, String textcolor, String bordercolor, String name, long links, long words, String type, int ppm, String network, long nlinks, long nwords, double nqph, long nppm) {+ private static void drawBannerPicture(int width, int height, String bgcolor, String textcolor, String bordercolor, String name, long links, long words, String type, int ppm, String network, long nlinks, long nwords, double nqph, long nppm, BufferedImage newLogo) {int exprlength = 19;+ logo = newLogo;+bannerPicture = new ymageMatrix(width, height, bgcolor);bannerPicture.setMode(ymageMatrix.MODE_SUB);@@ -390,6 +402,10 @@ public class plasmaGrafics {ymageToolPrint.print(bannerPicture, 285, 42, 0, "QUERIES: " + addTrailingBlanks(nqph + " QUERIES/HOUR", exprlength), -1);ymageToolPrint.print(bannerPicture, 285, 52, 0, "SPEED: " + addTrailingBlanks(nppm + " PAGES/MINUTE", exprlength), -1);+ if (logo != null) {+ bannerPicture.insertBitmap(logo, 2, 2);+ }+if (!bordercolor.equals("")) {bannerPicture.setColor(bordercolor);bannerPicture.line(0,0,0,height-1);@@ -397,10 +413,17 @@ public class plasmaGrafics {bannerPicture.line(width-1,0,width-1,height-1);bannerPicture.line(0,height-1,width-1,height-1);}-+// set timestampbannerPictureDate = System.currentTimeMillis();}++ public static boolean logoIsLoaded() {+ if (logo == null) {+ return false;+ }+ return true;+ }//[MN]/* quoted method because it is not used anywhere (and creates a warning in eclipse)diff --git a/source/de/anomic/ymage/ymageMatrix.java b/source/de/anomic/ymage/ymageMatrix.javaindex e71a3c0bd..bf003bbbc 100644--- a/source/de/anomic/ymage/ymageMatrix.java+++ b/source/de/anomic/ymage/ymageMatrix.java@@ -265,6 +265,27 @@ public class ymageMatrix /*implements Cloneable*/ {arc(x, y, innerRadius, outerRadius, fromArc, toArc);}+ /**+ * inserts an image into the ymageMatrix+ * @param bitmap the bitmap to be inserted+ * @param x the x value of the upper left coordinate in the ymageMatrix where the bitmap will be placed+ * @param y the y value of the upper left coordinate in the ymageMatrix where the bitmap will be placed+ *+ * @author Marc Nause+ */+ public void insertBitmap(BufferedImage bitmap, int x, int y) {+ int heightSrc = bitmap.getHeight();+ int widthSrc = bitmap.getWidth();+ int heightTgt = image.getHeight();+ int widthTgt = image.getWidth();++ for (int i = y; i < heightSrc && i < heightTgt - y; i++) {+ for (int j = x; j < widthSrc && j < widthTgt - x; j++) {+ image.setRGB(j, i, bitmap.getRGB(j, i));+ }+ }+ }+public static void demoPaint(ymageMatrix m) {m.setMode(MODE_SUB);m.setColor(SUBTRACTIVE_CYAN);