removed CMY color model from ymage classes and re-introduced RGB color model

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@4249 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 17 years ago
parent b46bcaa5d8
commit c57eb76b13

@ -183,7 +183,7 @@
</div>
<div id="left">
<a href="NetworkPicture.png?width=768&height=576&bgcolor=000000"><img src="NetworkPicture.png?width=768&height=576&bgcolor=000000" alt="The yacy Network" /></a>
<a href="NetworkPicture.png?width=768&height=576&bgcolor=FFFFFF"><img src="NetworkPicture.png?width=768&height=576&bgcolor=FFFFFF" alt="The yacy Network" /></a>
</div>
<div id="left">
<table border="0">

@ -73,9 +73,9 @@ public class PeerLoadPicture {
// too small values lead to an error, too big to huge CPU/memory consumption,
// resulting in possible DOS.
if (width < 400) width = 400;
if (width < 40) width = 40;
if (width > 1920) width = 1920;
if (height < 300) height = 300;
if (height < 30) height = 30;
if (height > 1440) height = 1440;
return plasmaGrafics.getPeerLoadPicture(
5000,

@ -51,7 +51,6 @@ import de.anomic.ymage.ymageToolPrint;
public class imagetest {
public static ymageMatrix respond(httpHeader header, serverObjects post, serverSwitch env) {
/*
BufferedImage bi = new BufferedImage(640, 400, BufferedImage.TYPE_INT_RGB);
@ -84,24 +83,24 @@ public class imagetest {
for (int i = 20; i < 100; i++) r.setPixel(i, 34, new int[]{0, 0, 255});
return bi;
*/
ymageMatrix img = new ymageMatrix(800, 600, ymageMatrix.MODE_SUB, "000000");
img.setColor(ymageMatrix.SUBTRACTIVE_BLACK);
ymageMatrix img = new ymageMatrix(800, 600, ymageMatrix.MODE_SUB, "FFFFFF");
img.setColor(ymageMatrix.GREY);
for (int y = 0; y < 600; y = y + 50) ymageToolPrint.print(img, 0, 6 + y, 0, "" + y, -1);
for (int x = 0; x < 800; x = x + 50) ymageToolPrint.print(img, x, 6 , 0, "" + x, -1);
img.setColor(ymageMatrix.SUBTRACTIVE_RED);
img.setColor(ymageMatrix.RED);
img.dot(550, 110, 90, true);
img.setColor(ymageMatrix.SUBTRACTIVE_GREEN);
img.setColor(ymageMatrix.GREEN);
img.dot(480, 200, 90, true);
img.setColor(ymageMatrix.SUBTRACTIVE_BLUE);
img.setColor(ymageMatrix.BLUE);
img.dot(620, 200, 90, true);
img.setColor(ymageMatrix.SUBTRACTIVE_RED);
img.setColor(ymageMatrix.RED);
img.arc(300, 270, 30, 70, 0, 360);
img.setColor("330000");
img.arc(220, 110, 50, 90, 30, 110);
img.arc(210, 120, 50, 90, 30, 110);
img.setColor(ymageMatrix.SUBTRACTIVE_BLACK);
ymageToolPrint.print(img, 50, 110, 0, "BROADCAST MESSAGE #772: NODE %882 BLACK abcefghijklmnopqrstuvwxyz", -1);
img.setColor(ymageMatrix.SUBTRACTIVE_GREEN);
img.setColor(ymageMatrix.GREY);
ymageToolPrint.print(img, 50, 110, 0, "BROADCAST MESSAGE #772: NODE %882 GREY abcefghijklmnopqrstuvwxyz", -1);
img.setColor(ymageMatrix.GREEN);
ymageToolPrint.print(img, 50, 120, 0, "BROADCAST MESSAGE #772: NODE %882 GREEN abcefghijklmnopqrstuvwxyz", -1);
for (long i = 0; i < 256; i++) {
img.setColor(i);
@ -124,7 +123,7 @@ public class imagetest {
for (int i = 0; i <= 360; i++) {
img.arc(550, 400, 40, 41 + i/9, 0, i);
}
img.setColor(ymageMatrix.SUBTRACTIVE_BLACK);
img.setColor(ymageMatrix.GREY);
int angle;
for (byte c = (byte) 'A'; c <= 'Z'; c++) {
angle = (c - (byte) 'A') * 360 / ((byte) 'Z' - (byte) 'A');

@ -65,21 +65,21 @@ public class plasmaGrafics {
private static int shortestName = 10;
private static int longestName = 12;
public static final String COL_BACKGROUND = "080808"; /*"FFFFE0"*/
private static final String COL_DHTCIRCLE = "400030"; /*"008020"*/
private static final long COL_HEADLINE = ymageMatrix.SUBTRACTIVE_BLACK;
private static final String COL_ACTIVE_DOT = "181808";
private static final String COL_ACTIVE_LINE = "604040";
private static final String COL_ACTIVE_TEXT = "b080b0";
private static final String COL_PASSIVE_DOT = "101010";
private static final String COL_PASSIVE_LINE = "404040";
private static final String COL_PASSIVE_TEXT = "a0a0a0";
private static final String COL_POTENTIAL_DOT = "041010";
private static final String COL_POTENTIAL_LINE = "104040";
private static final String COL_POTENTIAL_TEXT = "80b0b0";
private static final String COL_WE_DOT = "206060";
private static final String COL_WE_LINE = "b0f0f0";
private static final String COL_WE_TEXT = "f0f0f0";
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_PASSIVE_DOT = "221111";
private static final String COL_PASSIVE_LINE = "443333";
private static final String COL_PASSIVE_TEXT = "663333";
private static final String COL_POTENTIAL_DOT = "002200";
private static final String COL_POTENTIAL_LINE = "224422";
private static final String COL_POTENTIAL_TEXT = "336633";
private static final String COL_WE_DOT = "FF0000";
private static final String COL_WE_LINE = "FFAAAA";
private static final String COL_WE_TEXT = "FFCCCC";
private static final Color COL_BORDER = new Color( 0, 0, 0);
private static final Color COL_NORMAL_TEXT = new Color( 0, 0, 0);
@ -147,7 +147,7 @@ public class plasmaGrafics {
// draw in the primary search peers
for (int j = 0; j < primarySearches.length; j++) {
eventPicture.setColor((primarySearches[j].isAlive()) ? ymageMatrix.SUBTRACTIVE_RED : ymageMatrix.SUBTRACTIVE_GREEN);
eventPicture.setColor((primarySearches[j].isAlive()) ? ymageMatrix.RED : ymageMatrix.GREEN);
hash = primarySearches[j].target().hash;
angle = (int) (360 * yacySeed.dhtPosition(hash));
eventPicture.arcLine(cx, cy, cr - 20, cr, angle);
@ -156,7 +156,7 @@ public class plasmaGrafics {
// draw in the secondary search peers
if (secondarySearches != null) {
for (int j = 0; j < secondarySearches.length; j++) {
eventPicture.setColor((secondarySearches[j].isAlive()) ? ymageMatrix.SUBTRACTIVE_RED : ymageMatrix.SUBTRACTIVE_GREEN);
eventPicture.setColor((secondarySearches[j].isAlive()) ? ymageMatrix.RED : ymageMatrix.GREEN);
hash = secondarySearches[j].target().hash;
angle = (int) (360 * yacySeed.dhtPosition(hash));
eventPicture.arcLine(cx, cy, cr - 10, cr, angle - 1);
@ -167,7 +167,7 @@ public class plasmaGrafics {
// draw in the search target
plasmaSearchQuery query = event.getQuery();
Iterator i = query.queryHashes.iterator();
eventPicture.setColor(ymageMatrix.SUBTRACTIVE_BLACK);
eventPicture.setColor(ymageMatrix.GREY);
while (i.hasNext()) {
hash = (String) i.next();
angle = (int) (360 * yacySeed.dhtPosition(hash));

@ -48,7 +48,7 @@ import javax.imageio.ImageIO;
public class ymageCaptcha extends ymageMatrix {
public ymageCaptcha(int width, int height, byte displayMode, String code) {
super(width, height, displayMode, SUBTRACTIVE_WHITE);
super(width, height, displayMode, "FFFFFF");
this.create(code);
}

@ -155,24 +155,30 @@ public class ymageChart extends ymageMatrix {
public static void main(String[] args) {
System.setProperty("java.awt.headless", "true");
ymageChart ip = new ymageChart(660, 240, "FFFFFF", "000000", 30, 30, 20, 20, "PEER PERFORMANCE GRAPH: PAGES/MINUTE and USED MEMORY");
ip.declareDimension(DIMENSION_BOTTOM, 60, 60, -600, "000000", "CCCCCC", "TIME/SECONDS");
boolean invers = false;
String bg = (invers) ? "000000" : "FFFFFF";
String fg = (invers) ? "FFFFFF" : "000000";
String scale = (invers) ? "333333" : "CCCCCC";
String green = (invers) ? "008800" : "008800";
String blue = (invers) ? "0000FF" : "0000FF";
ymageChart ip = new ymageChart(660, 240, bg, fg, 30, 30, 20, 20, "PEER PERFORMANCE GRAPH: PAGES/MINUTE and USED MEMORY");
ip.declareDimension(DIMENSION_BOTTOM, 60, 60, -600, fg, scale, "TIME/SECONDS");
//ip.declareDimension(DIMENSION_TOP, 10, 40, "000000", null, "count");
ip.declareDimension(DIMENSION_LEFT, 50, 40, 0, "008800", null , "PPM [PAGES/MINUTE]");
ip.declareDimension(DIMENSION_RIGHT, 100, 20, 0, "0000FF", "CCCCCC", "MEMORY/MEGABYTE");
ip.setColor("008800");
ip.declareDimension(DIMENSION_LEFT, 50, 40, 0, green, scale , "PPM [PAGES/MINUTE]");
ip.declareDimension(DIMENSION_RIGHT, 100, 20, 0, blue, scale, "MEMORY/MEGABYTE");
ip.setColor(green);
ip.chartDot(DIMENSION_BOTTOM, DIMENSION_LEFT, -160, 100, 5);
ip.chartLine(DIMENSION_BOTTOM, DIMENSION_LEFT, -160, 100, -130, 200);
ip.setColor("0000FF");
ip.setColor(blue);
ip.chartDot(DIMENSION_BOTTOM, DIMENSION_RIGHT, -50, 300, 2);
ip.chartLine(DIMENSION_BOTTOM, DIMENSION_RIGHT, -80, 100, -50, 300);
//ip.print(100, 100, 0, "TEXT", true);
//ip.print(100, 100, 0, "1234", false);
//ip.print(100, 100, 90, "TEXT", true);
//ip.print(100, 100, 90, "1234", false);
File file = new File("/Users/admin/Desktop/testimage.png");
try {
FileOutputStream fos = new FileOutputStream(new File("/Users/admin/Desktop/testimage.png"));
FileOutputStream fos = new FileOutputStream(file);
ImageIO.write(ip.getImage(), "png", fos);
fos.close();
} catch (IOException e) {}

@ -47,7 +47,7 @@ public class ymageDemoApplet extends Applet implements Runnable {
public void update(Graphics g) {
Dimension d = getSize();
offGraphics = new ymageMatrix(d.width, d.height, ymageMatrix.MODE_REPLACE, ymageMatrix.SUBTRACTIVE_WHITE);
offGraphics = new ymageMatrix(d.width, d.height, ymageMatrix.MODE_REPLACE, "FFFFFF");
paintFrame(offGraphics);
g.drawImage(offGraphics.getImage(), 0, 0, null);
}
@ -61,7 +61,7 @@ public class ymageDemoApplet extends Applet implements Runnable {
public void paintFrame(ymageMatrix m) {
ymageMatrix.demoPaint(m);
int y = (int) (System.currentTimeMillis() / 10 % 300);
m.setColor(ymageMatrix.SUBTRACTIVE_BLACK);
m.setColor(ymageMatrix.GREY);
ymageToolPrint.print(m, 0, y, 0, "Hello World", -1);
}

@ -124,11 +124,11 @@ public class ymageGraph {
}
}
public static final long color_back = ymageMatrix.SUBTRACTIVE_WHITE;
public static final long color_text = ymageMatrix.SUBTRACTIVE_BLACK;
private static final long color_dot = 0x6633AA;
public static final long color_back = 0xFFFFFF;
public static final long color_text = 0xAAAAAA;
private static final long color_dot = 0x11CC11;
private static final long color_line = 0x333333;
private static final long color_lineend = 0x555555;
private static final long color_lineend = 0x666666;
public ymageMatrix draw(int width, int height, int leftborder, int rightborder, int topborder, int bottomborder) {
ymageMatrix image = new ymageMatrix(width, height, ymageMatrix.MODE_SUB, color_back);

@ -37,24 +37,24 @@ import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.awt.image.WritableRaster;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import javax.imageio.ImageIO;
import de.anomic.server.serverMemory;
public class ymageMatrix /*implements Cloneable*/ {
public class ymageMatrix {
// colors regarding CMY Color Model
public static final long SUBTRACTIVE_CYAN = 0xFF0000;
public static final long SUBTRACTIVE_MAGENTA = 0x00FF00;
public static final long SUBTRACTIVE_YELLOW = 0x0000FF;
public static final long SUBTRACTIVE_BLACK = 0xFFFFFF;
public static final long SUBTRACTIVE_WHITE = 0x000000;
public static final long SUBTRACTIVE_RED = 0x007F7F;
public static final long SUBTRACTIVE_GREEN = 0x7F007F;
public static final long SUBTRACTIVE_BLUE = 0x7F7F00;
// colors regarding RGB Color Model
public static final long RED = 0xFF0000;
public static final long GREEN = 0x00FF00;
public static final long BLUE = 0x0000FF;
public static final long GREY = 0x888888;
public static final byte MODE_REPLACE = 0;
public static final byte MODE_ADD = 1;
public static final byte MODE_SUB = 2;
@ -65,7 +65,7 @@ public class ymageMatrix /*implements Cloneable*/ {
private byte defaultMode;
public ymageMatrix(int width, int height, byte drawMode, String backgroundColor) {
this(width, height, drawMode, colNum(backgroundColor));
this(width, height, drawMode, Long.parseLong(backgroundColor, 16));
}
public ymageMatrix(int width, int height, byte drawMode, long backgroundColor) {
@ -76,44 +76,35 @@ public class ymageMatrix /*implements Cloneable*/ {
this.defaultMode = drawMode;
image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
Graphics2D gr = image.createGraphics();
gr.setBackground(Color.white);
//gr.clearRect(0, 0, width, height);
grid = image.getRaster();
// fill grid with background color
byte bgR, bgG, bgB;
if (drawMode == MODE_SUB) {
bgR = (byte) (0xFF - (backgroundColor >> 16));
bgG = (byte) (0xFF - ((backgroundColor >> 8) & 0xff));
bgB = (byte) (0xFF - (backgroundColor & 0xff));
} else {
bgR = (byte) (backgroundColor >> 16);
bgG = (byte) ((backgroundColor >> 8) & 0xff);
bgB = (byte) (backgroundColor & 0xff);
}
int bgR, bgG, bgB;
/*if (drawMode == MODE_SUB) {
bgR = (int) (0xFF - (backgroundColor >> 16));
bgG = (int) (0xFF - ((backgroundColor >> 8) & 0xff));
bgB = (int) (0xFF - (backgroundColor & 0xff));
} else {*/
bgR = (int) (backgroundColor >> 16);
bgG = (int) ((backgroundColor >> 8) & 0xff);
bgB = (int) (backgroundColor & 0xff);
//}
Graphics2D gr = image.createGraphics();
gr.setBackground(new Color(bgR, bgG, bgB));
gr.clearRect(0, 0, width, height);
/*
int[] c = new int[]{bgR, bgG, bgB};
for (int i = 0; i < width; i++) {
for (int j = 0; j < height; j++) {
grid.setPixel(i, j, c);
}
}
*/
}
public BufferedImage getImage() {
return this.image;
}
private static long colNum(String col) {
return Long.parseLong(col, 16);
//return Integer.parseInt(col.substring(0,2), 16) << 16 | Integer.parseInt(col.substring(2,4), 16) << 8 | Integer.parseInt(col.substring(4,6), 16);
}
/*
public Object clone() {
return new ymageMatrix(this);
}
*/
public int getWidth() {
return width;
}
@ -123,25 +114,38 @@ public class ymageMatrix /*implements Cloneable*/ {
}
public void setColor(long c) {
defaultCol[0] = (int) (c >> 16);
defaultCol[1] = (int) ((c >> 8) & 0xff);
defaultCol[2] = (int) (c & 0xff);
if (this.defaultMode == MODE_SUB) {
int r = (int) (c >> 16);
int g = (int) ((c >> 8) & 0xff);
int b = (int) (c & 0xff);
defaultCol[0] = (g + b) / 2;
defaultCol[1] = (r + b) / 2;
defaultCol[2] = (r + g) / 2;
} else {
defaultCol[0] = (int) (c >> 16);
defaultCol[1] = (int) ((c >> 8) & 0xff);
defaultCol[2] = (int) (c & 0xff);
}
}
public void setColor(String s) {
setColor(colNum(s));
}
/*
public void setMode(byte m) {
this.defaultMode = m;
setColor(Long.parseLong(s, 16));
}
*/
public void plot(int x, int y) {
if ((x < 0) || (x >= width)) return;
if ((y < 0) || (y >= height)) return;
//int n = 3 * (x + y * width);
if (this.defaultMode == MODE_REPLACE) {
grid.setPixel(x, y, defaultCol);
} else if (this.defaultMode == MODE_ADD) {
int[] c = new int[3];
c = grid.getPixel(x, y, c);
int r = (0xff & c[0]) + defaultCol[0]; if (r > 255) r = 255;
int g = (0xff & c[1]) + defaultCol[1]; if (g > 255) g = 255;
int b = (0xff & c[2]) + defaultCol[2]; if (b > 255) b = 255;
grid.setPixel(x, y, new int[]{r, g, b});
} else if (this.defaultMode == MODE_SUB) {
int[] c = new int[3];
c = grid.getPixel(x, y, c);
@ -311,25 +315,16 @@ public class ymageMatrix /*implements Cloneable*/ {
}
public static void demoPaint(ymageMatrix m) {
m.setColor(SUBTRACTIVE_CYAN);
m.line(0, 10, 100, 10); ymageToolPrint.print(m, 0, 5, 0, "Cyan", -1);
m.line(50, 0, 50, 300);
m.setColor(SUBTRACTIVE_MAGENTA);
m.line(0, 30, 100, 30); ymageToolPrint.print(m, 0, 25, 0, "Magenta", -1);
m.line(55, 0, 55, 300);
m.setColor(SUBTRACTIVE_YELLOW);
m.line(0, 50, 100, 50); ymageToolPrint.print(m, 0, 45, 0, "Yellow", -1);
m.line(60, 0, 60, 300);
m.setColor(SUBTRACTIVE_BLACK);
m.line(0, 70, 100, 70); ymageToolPrint.print(m, 0, 65, 0, "Black", -1);
m.setColor(GREY);
m.line(0, 70, 100, 70); ymageToolPrint.print(m, 0, 65, 0, "Grey", -1);
m.line(65, 0, 65, 300);
m.setColor(SUBTRACTIVE_RED);
m.setColor(RED);
m.line(0, 90, 100, 90); ymageToolPrint.print(m, 0, 85, 0, "Red", -1);
m.line(70, 0, 70, 300);
m.setColor(SUBTRACTIVE_GREEN);
m.setColor(GREEN);
m.line(0, 110, 100, 110); ymageToolPrint.print(m, 0, 105, 0, "Green", -1);
m.line(75, 0, 75, 300);
m.setColor(SUBTRACTIVE_BLUE);
m.setColor(BLUE);
m.line(0, 130, 100, 130); ymageToolPrint.print(m, 0, 125, 0, "Blue", -1);
m.line(80, 0, 80, 300);
}
@ -338,13 +333,14 @@ public class ymageMatrix /*implements Cloneable*/ {
// go into headless awt mode
System.setProperty("java.awt.headless", "true");
ymageMatrix m = new ymageMatrix(200, 300, MODE_SUB, SUBTRACTIVE_WHITE);
ymageMatrix m = new ymageMatrix(200, 300, MODE_SUB, "FFFFFF");
demoPaint(m);
File file = new File("/Users/admin/Desktop/testimage.png");
try {
ImageIO.write(m.getImage(), "png", new java.io.File(args[0]));
} catch (java.io.IOException e) {
e.printStackTrace();
}
FileOutputStream fos = new FileOutputStream(file);
ImageIO.write(m.getImage(), "png", fos);
fos.close();
} catch (IOException e) {}
// open file automatically, works only on Mac OS X
/*

Loading…
Cancel
Save