/* SCCS %W%---%G%--%U% */ // Copyright: Copyright (c) 1997 University of Southern California Brain Project. // Copyright: This software may be freely copied provided the toplevel // Copyright: COPYRIGHT file is included with each such copy. // Copyright: Email nsl@java.usc.edu. package nslj.src.display; import java.awt.*; import java.util.*; import nslj.src.lang.*; import nslj.src.system.*; import nslj.src.nsls.struct.Executive; import java.awt.event.*; import java.lang.*; import java.lang.reflect.*; public class NslOutCanvas extends NslCanvas { protected NslSystem system; protected NslModule parentModule; Image buffer; Graphics bufferg; public NslOutCanvas( String full_name, NslHierarchy parent) { super(null,full_name, null); System.err.println("1"); system = Executive.system; parentModule = (NslModule)parent; Rectangle b = getBounds(); System.err.println("1 Width: "+b.width+", Height: "+b.height); buffer = createImage(b.width, b.height); bufferg = buffer.getGraphics(); nslCreateCanvas(); } public NslOutCanvas( String full_name, NslHierarchy parent,NslFrame f, NslVariableInfo varInfo) { super(f,full_name, varInfo); System.err.println("2"); system = Executive.system; parentModule = (NslModule)parent; nslCreateCanvas(); } public NslOutCanvas(String full_name, NslVariableInfo varInfo) { super(null,full_name, varInfo); system = Executive.system; Rectangle b = getBounds(); System.err.println("Width: "+b.width+", Height: "+b.height); buffer = createImage(b.width, b.height); bufferg = buffer.getGraphics(); nslCreateCanvas(); } public void makeInst(String full_name, NslHierarchy parent) { } public NslHierarchy getParentModule() { return parentModule; } public void nslSetColor(NslColor color) { //try { bufferg.setColor(color); //} } public void nslSetColor(String color) { //try { bufferg.setColor(NslColor.getColor(color)); //} } public void nslDrawLine(int x, int y, int w, int h, String color) { //try { bufferg.setColor(NslColor.getColor(color)); bufferg.drawLine(x,y,w,h); //} } public void nslDrawLine(int x, int y, int w, int h) { //try { bufferg.drawLine(x,y,w,h); //} } public void nslFillRect(int x, int y, int w, int h, NslColor color) { //try { bufferg.setColor(color); bufferg.fillRect(x,y,w,h); //} } public void nslFillRect(int x, int y, int w, int h, String color) { //try { bufferg.setColor(NslColor.getColor(color)); bufferg.fillRect(x,y,w,h); //} } public void nslFillRect(int x, int y, int w, int h) { //try { bufferg.fillRect(x,y,w,h); //} } public void nslDrawString(String s, int x, int y, String color) { //try { bufferg.setColor(NslColor.getColor(color)); bufferg.drawString(s,x,y); //} } public void nslDrawString(String s, int x, int y) { //try { bufferg.drawString(s,x,y); //} } public int nslGetWidth() { Rectangle border = getBounds(); return border.width; } public int nslGetHeight() { Rectangle border = getBounds(); return border.height; } public void paint(Graphics g) { nslRefresh(); } public void nslUpdateDisplay() { Graphics g = getGraphics(); try { g.drawImage(buffer, 0, 0, this); paint(g); System.err.println("Updating!"); } finally { g.dispose(); } } public void nslClearDisplay() { Graphics g = getGraphics(); Rectangle b = getBounds(); try { g.clearRect(0, 0, b.width, b.height); paint(g); } finally { g.dispose(); } } public Image nslCreateImageBuffer(int width, int height) { return createImage(width, height); } public void nslDrawImageBuffer(Image image, int left, int top) { Graphics g = getGraphics(); try { g.drawImage(image, left, top, this); } finally { g.dispose(); } } public void nslDrawImageBuffer(Image image, Graphics graph, int left, int top) { graph.drawImage(image, left, top, this); } public void collect() { if (NslSystem.init_run_char=='A') nslCollect(); } public void initCanvas() { Rectangle b = getBounds(); System.err.println("2 Width: "+b.width+","+b.height); try { buffer = createImage(b.width, b.height); } catch (Exception e) { e.printStackTrace(); } System.err.println("2.1 Width: "); try { bufferg = buffer.getGraphics(); } catch (Exception e) { e.printStackTrace(); } System.err.println("2.2 Width: "); nslInitCanvas(); } public void nslCollect() { } public void nslRefresh() { } public void nslCreateCanvas() { } public void nslInitCanvas() { } public void processEvent(AWTEvent event) { /*System.out.println("Event: "+event.toString()); System.out.println("Param: "+event.paramString()); System.out.println("Source: "+event.getSource());*/ } }