*) added banner that can be displayed like this: http://localhost:8080/Banner.png

possible arguments: textcolor, bgcolor, bordercolor
   example: http://localhost:8000/Banner.png?textcolor=ffffff&bgcolor=121212&bordercolor=ffffff
   take care: YaCy uses CMY color model!
*) there are still some known bugs, but I can't continue coding right now


git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@4149 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
low012 18 years ago
parent 70884da0eb
commit 507ecd8afa

@ -0,0 +1,141 @@
// Banner.java
// -----------------------
// part of YaCy
// (C) by Michael Peter Christen; mc@anomic.de
// first published on http://www.anomic.de
// Frankfurt, Germany, 2004
//
// This File is contributed by Marc Nause
//
// $LastChangedDate: 2007-10-07 $
// $LastChangedRevision: $
// $LastChangedBy: low012 $
//
// 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
//
// Using this software in any meaning (reading, learning, copying, compiling,
// running) means that you agree that the Author(s) is (are) not responsible
// for cost, loss of data or any harm that may be caused directly or indirectly
// by usage of this softare or this documentation. The usage of this software
// is on your own risk. The installation and usage (starting/running) of this
// software may allow other people or application to access your computer and
// any attached devices and is highly dependent on the configuration of the
// software which must be done by the user of the software; the author(s) is
// (are) also not responsible for proper configuration and usage of the
// software, even if provoked by documentation provided together with
// the software.
//
// Any changes to this file according to the GPL as documented in the file
// gpl.txt aside this file in the shipment you received can be done to the
// lines that follows this copyright notice here, but changes must not be
// done inside the copyright notive above. A re-distribution must contain
// the intact and unchanged copyright notice.
// Contributions and changes to the program code must be marked as such.
import de.anomic.http.httpHeader;
import de.anomic.plasma.plasmaGrafics;
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;
/** draw a banner with information about the peer */
public class Banner {
public static ymageMatrix respond(httpHeader header, serverObjects post, serverSwitch env) {
int width = 468;
int height = 60;
String bgcolor = plasmaGrafics.COL_BACKGROUND;
String textcolor = "ffffff";
String bordercolor = "";
if (post != null) {
bgcolor = post.get("bgcolor", bgcolor);
textcolor = post.get("textcolor", textcolor);
bordercolor = post.get("bordercolor", bordercolor);
}
yacySeed seed = yacyCore.seedDB.mySeed();
String name = seed.get(yacySeed.NAME, "-");
name = addTrailingBlanks(name,19).toUpperCase();
String links = seed.get(yacySeed.LCOUNT, "0");
links = addDots(links);
links = addTrailingBlanks(links,19);
String words = seed.get(yacySeed.ICOUNT, "0");
words = addDots(words);
words = addTrailingBlanks(words,19);
String type = "";
if (yacyCore.seedDB.mySeed().isVirgin()) {
type = "VIRGIN";
} else if(yacyCore.seedDB.mySeed().isJunior()) {
type = "JUNIOR";
} else if(yacyCore.seedDB.mySeed().isSenior()) {
type = "SENIOR";
} else if(yacyCore.seedDB.mySeed().isPrincipal()) {
type = "PRINCIPAL";
}
type = addTrailingBlanks(type,19);
String ppm = seed.getPPM() + " PAGES/MINUTE";
ppm = addTrailingBlanks(ppm,19);
String network = env.getConfig("network.unit.name", "unspecified").toUpperCase();
network = addTrailingBlanks(network,19);
String nlinks = yacyCore.seedDB.countActiveURL()+"";
nlinks = addDots(nlinks);
nlinks = addTrailingBlanks(nlinks,19);
String nwords = yacyCore.seedDB.countActiveRWI()+"";
nwords = addDots(nwords);
nwords = addTrailingBlanks(nwords,19);
String nqph = yacyCore.seedDB.countActiveQPM() + " QUERIES/MINUTE";
nqph = addTrailingBlanks(nqph,19);
String nppm = yacyCore.seedDB.countActivePPM() + " PAGES/MINUTE";
nppm = addTrailingBlanks(nppm,19);
return plasmaGrafics.getBannerPicture(width, height, bgcolor, textcolor, bordercolor, name, links, words, type, ppm, network, nlinks, nwords, nqph, nppm);
}
private static String addDots(String word) {
String tmp = "";
int len = word.length();
while(len > 3) {
if(tmp.equals("")) {
tmp = word.substring(len-3,len);
} else {
tmp = word.substring(len-3,len) + "." + tmp;
}
word = word.substring(0,len-3);
len = word.length();
}
word = word + "." + tmp;
return word;
}
private static String addTrailingBlanks(String word, int length) {
if (length > word.length()) {
String blanks = "";
length = length - word.length();
int i = 0;
while(i++ < length) {
blanks += " ";
}
word = blanks + word;
}
return word;
}
}

@ -6,6 +6,8 @@
// Frankfurt, Germany, 2005
// Created 08.10.2005
//
// Contributions by Marc Nause [MN]
//
// $LastChangedDate$
// $LastChangedRevision$
// $LastChangedBy$
@ -119,6 +121,9 @@ public class plasmaGrafics {
private static BufferedImage peerloadPicture = null;
private static long peerloadPictureDate = 0;
private static ymageMatrix bannerPicture = null; // [MN]
//private static long bannerPictureDate = 0; // [MN]
public static ymageMatrix getSearchEventPicture(String eventID) {
plasmaSearchEvent event = plasmaSearchEvent.getEvent(eventID);
if (event == null) return null;
@ -355,4 +360,44 @@ public class plasmaGrafics {
g.drawChars(caption.toCharArray(), 0, caption.length(), x+LEGEND_BOX_SIZE+5,y);
}
//[MN]
public static ymageMatrix getBannerPicture(int width, int height, String bgcolor, String textcolor, String bordercolor, String name, String links, String words, String type, String ppm, String network, String nlinks, String nwords, String nqph, String nppm) {
//if ((bannerPicture == null) || ((System.currentTimeMillis() - bannerDate) > maxAge)) {
drawBannerPicture(width, height, bgcolor, textcolor, bordercolor, name, links, words, type, ppm, network, nlinks, nwords, nqph, nppm);
//}
return bannerPicture;
}
//[MN]
private static void drawBannerPicture(int width, int height, String bgcolor, String textcolor, String bordercolor, String name, String links, String words, String type, String ppm, String network, String nlinks, String nwords, String nqph, String nppm) {
bannerPicture = new ymageMatrix(width, height, bgcolor);
bannerPicture.setMode(ymageMatrix.MODE_SUB);
// draw description
bannerPicture.setColor(textcolor);
ymageToolPrint.print(bannerPicture, 100, 12, 0, "PEER: " +name , -1);
ymageToolPrint.print(bannerPicture, 100, 22, 0, "LINKS: " + links , -1);
ymageToolPrint.print(bannerPicture, 100, 32, 0, "WORDS: " + words , -1);
ymageToolPrint.print(bannerPicture, 100, 42, 0, "TYPE: " + type , -1);
ymageToolPrint.print(bannerPicture, 100, 52, 0, "SPEED: " + ppm , -1);
ymageToolPrint.print(bannerPicture, 285, 12, 0, "NETWORK: " +network , -1);
ymageToolPrint.print(bannerPicture, 285, 22, 0, "LINKS: " + nlinks , -1);
ymageToolPrint.print(bannerPicture, 285, 32, 0, "WORDS: " + nwords , -1);
//ymageToolPrint.print(bannerPicture, 285, 42, 0, "QUERIES: " + nqph , -1);
ymageToolPrint.print(bannerPicture, 285, 52, 0, "SPEED: " + nppm , -1);
if (!bordercolor.equals("")) {
bannerPicture.setColor(bordercolor);
bannerPicture.line(0,0,0,height-1);
bannerPicture.line(0,0,width-1,0);
bannerPicture.line(width-1,0,width-1,height-1);
bannerPicture.line(0,height-1,width-1,height-1);
}
// set timestamp
// bannerPictureDate = System.currentTimeMillis();
}
}
Loading…
Cancel
Save