/** * $OpenXM: OpenXM/src/OpenMath/OXplot.java,v 1.7 2000/11/09 06:50:16 tam Exp $ */ import ORG.openxm.tam.*; import java.util.Stack; import java.util.Vector; import java.awt.*; public class OXplot extends OpenXMserver{ private Stack stack = new Stack(); private Vector plotframe = new Vector(); protected boolean debug = true; final int version = 200011090; public OXplot(String hostname,int ControlPort,int DataPort){ super(hostname,ControlPort,DataPort); } public void computeProcess(OpenXMstream stream){ debug("OXplot started."); stack = new Stack(); plotframe = new Vector(); try{ while(true){ Thread.yield(); try{ OXmessage message = stream.receive(); int ox_tag = message.getTag(); switch(ox_tag){ case OXmessage.OX_COMMAND: StackMachine((SM)message.getBody(),stream); break; case OXmessage.OX_DATA: stack.push(message.getBody()); debug("push: "+ stack.peek()); break; } }catch(RuntimeException e){ System.err.println(e.getMessage()); e.printStackTrace(); debug("error occured. stack was cleared."); stack = new Stack(); } } }catch(java.io.IOException e){ System.err.println(e.getMessage()); e.printStackTrace(); System.err.println("error occured, and recovering processes seems to be impossible."); }catch(Exception e){ System.err.println(e.getMessage()); e.printStackTrace(); System.err.println("error occured, and recovering processes seems to be impossible."); }finally{ System.err.println("breaking..."); } } private void SM_popCMO(OpenXMstream stream) throws java.io.IOException{ try{ if(stack.empty()){ stream.send(new CMO_NULL()); }else{ debug("sending CMO: "+ stack.peek()); stream.send((CMO)stack.pop()); debug("test"); } }catch(MathcapViolation e){ try{ stream.send(new CMO_ERROR2(new CMO_STRING("MathcapViolation: "+ e.getMessage()))); }catch(MathcapViolation tmp){} } } private void SM_executeFunction() throws java.io.IOException{ String function_name; CMO[] argv; int argc; if(!(stack.peek() instanceof CMO_STRING)){ stack.push(new CMO_ERROR2(new CMO_NULL())); return; } function_name = ((CMO_STRING)stack.pop()).getString(); argc = ((CMO_INT32)stack.pop()).intValue(); argv = new CMO[argc]; for(int i=0;i= pixels[0].length){ return; } if(offset_y + y < 0 || offset_y + y >= pixels.length){ return; } pixels[offset_y + y][offset_x + x] = bright; } }