// FEATURE - we should handle errors better than this
char msgbuf[JMSG_LENGTH_MAX];
(jerr.pub.format_message)((j_common_ptr)&cinfo, msgbuf);
- Log::log(&GCJ::class$,JvNewStringLatin1(msgbuf));
+ Log::info(&GCJ::class$,JvNewStringLatin1(msgbuf));
jpeg_destroy_decompress(&cinfo);
return;
}
p->width = cinfo.output_width;
p->height = cinfo.output_height;
- p->data = JvNewIntArray(width * height);
+ p->data = JvNewIntArray(p->width * p->height);
while (cinfo.output_scanline < cinfo.output_height) {
- JSAMPLE *dest = (JSAMPLE*) (elements(data) + cinfo.output_scanline * width);
+ JSAMPLE *dest = (JSAMPLE*) (elements(p->data) + cinfo.output_scanline * p->width);
jpeg_read_scanlines(&cinfo,&dest,1);
}
jpeg_finish_decompress(&cinfo);
jpeg_destroy_decompress(&cinfo);
- for(int i=0;i<data->length;i++)
- elements(data)[i] |= 0xff000000; // alpha channel
+ for(int i=0;i<p->data->length;i++)
+ elements(p->data)[i] |= 0xff000000; // alpha channel
}
// C++ new/delete operators (JvMalloc never fails)
drawPicture(source, dx, dy, cx1, cy1, cx2, cy2, 0, false);
}
public void drawGlyph(org.xwt.Font.Glyph source, int dx, int dy, int cx1, int cy1, int cx2, int cy2, int rgb) {
- Win32Picture p = ((Win32Picture)((DefaultGlyph)source).getPicture());
+ Win32Picture p = ((Win32Picture)((Platform.DefaultGlyph)source).getPicture());
p.init();
drawPicture(p, dx, dy, cx1, cy1, cx2, cy2, rgb, true);
}
visual = DefaultVisual(display, screen_num);
char buf[255];
sprintf(buf, "X11 DISPLAY: %s", XDisplayString(display));
- org::xwt::util::Log::log(this->getClass(), JvNewStringLatin1(buf));
+ org::xwt::util::Log::info(this->getClass(), JvNewStringLatin1(buf));
sprintf(buf, "X11 SHM: %s", shm_supported ? "enabled" : "disabled");
- org::xwt::util::Log::log(this->getClass(), JvNewStringLatin1(buf));
+ org::xwt::util::Log::info(this->getClass(), JvNewStringLatin1(buf));
sprintf(buf, "X11 Visual: %x %x %x bits: %i visualid: %i depth: %i",
visual->red_mask, visual->green_mask, visual->blue_mask, visual->bits_per_rgb, visual->visualid, colorDepth);
- org::xwt::util::Log::log(this->getClass(), JvNewStringLatin1(buf));
+ org::xwt::util::Log::info(this->getClass(), JvNewStringLatin1(buf));
// FIXME: don't know why (True, False) is the best solution...
if(XmuLookupStandardColormap(display, screen_num, visual->visualid, colorDepth, XA_RGB_BEST_MAP, True, False) == 0)
colormap_info = best_map_info;
sprintf(buf, " red_max / red_mult: %x %x", colormap_info->red_max, colormap_info->red_mult);
- org::xwt::util::Log::log(this->getClass(), JvNewStringLatin1(buf));
+ org::xwt::util::Log::info(this->getClass(), JvNewStringLatin1(buf));
sprintf(buf, " green_max / green_mult: %x %x", colormap_info->green_max, colormap_info->green_mult);
- org::xwt::util::Log::log(this->getClass(), JvNewStringLatin1(buf));
+ org::xwt::util::Log::info(this->getClass(), JvNewStringLatin1(buf));
sprintf(buf, " blue_max / blue_mult: %x %x", colormap_info->blue_max, colormap_info->blue_mult);
- org::xwt::util::Log::log(this->getClass(), JvNewStringLatin1(buf));
+ org::xwt::util::Log::info(this->getClass(), JvNewStringLatin1(buf));
sprintf(buf, " base_pixel: %x", colormap_info->base_pixel);
- org::xwt::util::Log::log(this->getClass(), JvNewStringLatin1(buf));
+ org::xwt::util::Log::info(this->getClass(), JvNewStringLatin1(buf));
}
cx2 = Math.min(dx + source.width, cx2);
cy2 = Math.min(dy + source.height, cy2);
if (cx1 >= cx2 || cy1 >= cy2) return;
- slowDrawPicture(((DefaultGlyph)source).getPicture(), dx, dy, cx1, cy1, cx2, cy2, rgb, true);
+ slowDrawPicture(((Platform.DefaultGlyph)source).getPicture(), dx, dy, cx1, cy1, cx2, cy2, rgb, true);
}
public void drawPicture(Picture source, int dx, int dy, int cx1, int cy1, int cx2, int cy2) {
cx1 = Math.max(dx, cx1);
int index = 0;
while(true) {
// everything to the left is before us so add that to the index
- index += size(left[slot]);
+ index += sizeof(left[slot]);
// we are before anything on the right
while(left[parent[slot]] == slot) slot = parent[slot];
// we end of the first node who isn't on the left, go to the node that has as its child
private final int rightmost(int slot) { return right[slot] <= 0 ? slot : rightmost(right[slot]); }
private final int next(int slot) { return right[slot] <= 0 ? -1 * right[slot] : leftmost(right[slot]); }
private final int prev(int slot) { return left[slot] <= 0 ? -1 * left[slot] : rightmost(left[slot]); }
- private final int size(int slot) { return slot <= 0 ? 0 : size[slot]; }
+ private final int sizeof(int slot) { return slot <= 0 ? 0 : size[slot]; }
private final int root(int slot) { return parent[slot] == 0 ? slot : root(parent[slot]); }
else if (left[p] == b) left[p] = d;
else if (right[p] == b) right[p] = d;
else throw new Error("rotate called with invalid parent");
- size[b] = 1 + size(left[b]) + size(right[b]);
- size[d] = 1 + size(left[d]) + size(right[d]);
+ size[b] = 1 + sizeof(left[b]) + sizeof(right[b]);
+ size[d] = 1 + sizeof(left[d]) + sizeof(right[d]);
}
private void balance(int slot, int p) {
if (slot <= 0) return;
- size[slot] = 1 + size(left[slot]) + size(right[slot]);
- if (size(left[slot]) - 1 > 2 * size(right[slot])) rotate(false, slot, p);
- else if (size(left[slot]) * 2 < size(right[slot]) - 1) rotate(true, slot, p);
+ size[slot] = 1 + sizeof(left[slot]) + sizeof(right[slot]);
+ if (sizeof(left[slot]) - 1 > 2 * sizeof(right[slot])) rotate(false, slot, p);
+ else if (sizeof(left[slot]) * 2 < sizeof(right[slot]) - 1) rotate(true, slot, p);
}
// Insert /////////////////////////////////////////////////////////////////////////
private void insert(int index, int arg, int slot, int p, boolean replace, boolean wentLeft) {
- int diff = slot <= 0 ? 0 : index - size(left[slot]);
+ int diff = slot <= 0 ? 0 : index - sizeof(left[slot]);
if (slot > 0 && diff != 0) {
if (diff < 0) insert(index, arg, left[slot], slot, replace, true);
- else insert(index - size(left[slot]) - 1, arg, right[slot], slot, replace, false);
+ else insert(index - sizeof(left[slot]) - 1, arg, right[slot], slot, replace, false);
balance(slot, p);
return;
}
// Retrieval //////////////////////////////////////////////////////////////////////
private int get(int index, int slot) {
- int diff = index - size(left[slot]);
+ int diff = index - sizeof(left[slot]);
if (diff > 0) return get(diff - 1, right[slot]);
else if (diff < 0) return get(index, left[slot]);
else return slot;
// Deletion //////////////////////////////////////////////////////////////////////
private int delete(int index, int slot, int p) {
- int diff = index - size(left[slot]);
+ int diff = index - sizeof(left[slot]);
if (diff < 0) {
int ret = delete(index, left[slot], slot);
balance(slot, p);
// node to be deleted has two children, so we replace it with its left child's rightmost descendant
} else {
- int left_childs_rightmost = delete(size(left[slot]) - 1, left[slot], slot);
+ int left_childs_rightmost = delete(sizeof(left[slot]) - 1, left[slot], slot);
left[left_childs_rightmost] = left[slot];
right[left_childs_rightmost] = right[slot];
if(left[slot] > 0) parent[left[slot]] = left_childs_rightmost;
private static final int BROWN = 33;
private static final int GRAY = 37;
- private static String color(int color, boolean bright, String s) {
+ private static String colorize(int color, boolean bright, String s) {
if (!Log.color) return s;
return
"\033[40;" + (bright?"1;":"") + color + "m" +
private static synchronized void log(Object o, Object message, int level) {
if (firstMessage && !logDates) {
firstMessage = false;
- System.err.println(color(GREEN, false, "==========================================================================="));
+ System.err.println(colorize(GREEN, false, "==========================================================================="));
diag(Log.class, "Logging enabled at " + new java.util.Date());
if (color) diag(Log.class, "logging messages in " +
- color(BLUE, true, "c") +
- color(RED, true, "o") +
- color(CYAN, true, "l") +
- color(GREEN, true, "o") +
- color(PURPLE, true, "r"));
+ colorize(BLUE, true, "c") +
+ colorize(RED, true, "o") +
+ colorize(CYAN, true, "l") +
+ colorize(GREEN, true, "o") +
+ colorize(PURPLE, true, "r"));
}
String classname;
if (classname.length() > (logDates ? 14 : 20)) classname = classname.substring(0, (logDates ? 14 : 20));
while (classname.length() < (logDates ? 14 : 20)) classname = " " + classname;
classname = classname + (classname.trim().length() == 0 ? " " : ": ");
- classname = color(GRAY, true, classname);
+ classname = colorize(GRAY, true, classname);
classname = classname.replace('$', '.');
if (logDates) {
if (lastDate == null || d.getYear() != lastDate.getYear() || d.getMonth() != lastDate.getMonth() || d.getDay() != lastDate.getDay()) {
String now = new java.text.SimpleDateFormat("EEE dd MMM yyyy").format(d);
System.err.println();
- System.err.println(color(GRAY, false, "=== " + now + " =========================================================="));
+ System.err.println(colorize(GRAY, false, "=== " + now + " =========================================================="));
}
java.text.DateFormat df = new java.text.SimpleDateFormat("[EEE HH:mm:ss] ");
classname = df.format(d) + classname;
while((s = br.readLine()) != null) m += s + "\n";
log(o, m.substring(0, m.length() - 1), level);
} catch (IOException e) {
- System.err.println(color(RED, true, "Logger: exception thrown by ByteArrayInputStream -- this should not happen"));
+ System.err.println(colorize(RED, true, "Logger: exception thrown by ByteArrayInputStream -- this should not happen"));
}
return;
}
while(str.indexOf('\t') != -1)
str = str.substring(0, str.indexOf('\t')) + " " + str.substring(str.indexOf('\t') + 1);
- classname = color(GRAY, false, classname);
+ classname = colorize(GRAY, false, classname);
int levelcolor = GRAY;
boolean bright = true;
switch (level) {
}
while(str.indexOf('\n') != -1) {
- System.err.println(classname + color(levelcolor, bright, str.substring(0, str.indexOf('\n'))));
+ System.err.println(classname + colorize(levelcolor, bright, str.substring(0, str.indexOf('\n'))));
classname = logDates ? " " : " ";
- classname = color(GRAY,false,classname);
+ classname = colorize(GRAY,false,classname);
str = str.substring(str.indexOf('\n') + 1);
}
- System.err.println(classname + color(levelcolor, bright, str));
+ System.err.println(classname + colorize(levelcolor, bright, str));
}
public static void recursiveLog(String indent, String name, Object o) throws JSExn {