version 1.2, 2000/07/07 03:02:36 |
version 1.4, 2000/09/07 09:12:28 |
|
|
/** |
/** |
* $OpenXM: OpenXM/src/OpenMath/OXplot.java,v 1.1 2000/07/03 05:57:43 tam Exp $ |
* $OpenXM: OpenXM/src/OpenMath/OXplot.java,v 1.3 2000/07/10 06:48:06 tam Exp $ |
*/ |
*/ |
|
|
import JP.ac.kobe_u.math.tam.OpenXM.*; |
import JP.ac.kobe_u.math.tam.OpenXM.*; |
Line 23 public class OXplot extends OpenXMserver{ |
|
Line 23 public class OXplot extends OpenXMserver{ |
|
plotframe = new Vector(); |
plotframe = new Vector(); |
try{ |
try{ |
while(true){ |
while(true){ |
|
Thread.yield(); |
try{ |
try{ |
OXmessage message = stream.receive(); |
OXmessage message = stream.receive(); |
int ox_tag = message.getTag(); |
int ox_tag = message.getTag(); |
Line 57 public class OXplot extends OpenXMserver{ |
|
Line 58 public class OXplot extends OpenXMserver{ |
|
} |
} |
} |
} |
|
|
class plotframe extends java.awt.Frame{ |
class plotframe extends java.awt.Frame implements java.awt.event.MouseListener{ |
Canvas canvas; |
Canvas canvas; |
int pixels[][]; |
int pixels[][]; |
|
|
Line 66 public class OXplot extends OpenXMserver{ |
|
Line 67 public class OXplot extends OpenXMserver{ |
|
add("Center", new Panel().add(canvas = new Canvas())); |
add("Center", new Panel().add(canvas = new Canvas())); |
canvas.setSize(width,height); |
canvas.setSize(width,height); |
setResizable(false); |
setResizable(false); |
|
canvas.addMouseListener(this); |
|
|
pixels = new int[width][]; |
pixels = new int[height][]; |
for(int i=0;i<pixels.length;i++){ |
for(int i=0;i<pixels.length;i++){ |
pixels[i] = new int[height]; |
pixels[i] = new int[width]; |
|
for(int j=0;j<pixels[i].length;j++){ |
|
pixels[i][j] = 255*j/width; |
|
} |
} |
} |
|
|
pack(); |
pack(); |
Line 77 public class OXplot extends OpenXMserver{ |
|
Line 82 public class OXplot extends OpenXMserver{ |
|
} |
} |
|
|
public void paint(Graphics gr){ |
public void paint(Graphics gr){ |
|
paint(); |
|
} |
|
|
|
public void paint(){ |
Graphics g = canvas.getGraphics(); |
Graphics g = canvas.getGraphics(); |
|
|
for(int x=0;x<pixels.length;x++){ |
for(int y=0;y<pixels.length;y++){ |
for(int y=0;y<pixels[x].length;y++){ |
for(int x=0;x<pixels[y].length;x++){ |
if(pixels[x][y] == 1){ |
g.setColor(new Color(pixels[y][x],pixels[y][x],pixels[y][x])); |
g.setColor(Color.black); |
|
}else{ |
|
g.setColor(Color.white); |
|
} |
|
g.fillRect(x,y,1,1); |
g.fillRect(x,y,1,1); |
} |
} |
} |
} |
} |
} |
|
|
public void pset(int x,int y){ |
public void mouseClicked(java.awt.event.MouseEvent e){ |
pixels[x][y] = 1; |
paint(); |
} |
} |
|
|
|
public void mousePressed(java.awt.event.MouseEvent e){ |
|
} |
|
|
|
public void mouseReleased(java.awt.event.MouseEvent e){ |
|
} |
|
|
|
public void mouseEntered(java.awt.event.MouseEvent e){ |
|
} |
|
|
|
public void mouseExited(java.awt.event.MouseEvent e){ |
|
} |
|
|
|
public void pset(int x,int y,int bright){ |
|
pixels[y][x] = bright; |
|
} |
} |
} |
|
|
private void SM_popCMO(OpenXMconnection stream) throws java.io.IOException{ |
private void SM_popCMO(OpenXMconnection stream) throws java.io.IOException{ |
Line 129 public class OXplot extends OpenXMserver{ |
|
Line 150 public class OXplot extends OpenXMserver{ |
|
argv[i] = (CMO)stack.pop(); |
argv[i] = (CMO)stack.pop(); |
} |
} |
|
|
if(function_name.equals("CREATE") && argc==2){ |
if(function_name.equals("create") && argc==2){ |
stack.push(CREATE(argv)); |
stack.push(CREATE(argv)); |
}else if(function_name.equals("CMO2OMXML") && argc==1){ |
}else if(function_name.equals("pset") && argc==4){ |
//stack.push(CMO2OMXML(argv[0])); |
PSET(argv); |
}else{ |
}else{ |
stack.push(new CMO_ERROR2(new CMO_NULL())); |
stack.push(new CMO_ERROR2(new CMO_NULL())); |
} |
} |
Line 224 public class OXplot extends OpenXMserver{ |
|
Line 245 public class OXplot extends OpenXMserver{ |
|
private CMO CREATE(CMO[] argv){ |
private CMO CREATE(CMO[] argv){ |
plotframe tmp = new plotframe(((CMO_INT32)argv[0]).intValue() |
plotframe tmp = new plotframe(((CMO_INT32)argv[0]).intValue() |
,((CMO_INT32)argv[1]).intValue()); |
,((CMO_INT32)argv[1]).intValue()); |
int i; |
|
|
|
for(i=0;i<plotframe.size();i++){ |
for(int i=0;i<plotframe.size();i++){ |
if(plotframe.elementAt(i) == null){ |
if(plotframe.elementAt(i) == null){ |
plotframe.setElementAt(tmp,i); |
plotframe.setElementAt(tmp,i); |
return new CMO_INT32(i); |
return new CMO_INT32(i); |
Line 234 public class OXplot extends OpenXMserver{ |
|
Line 254 public class OXplot extends OpenXMserver{ |
|
} |
} |
|
|
plotframe.addElement(tmp); |
plotframe.addElement(tmp); |
|
plotframe.trimToSize(); |
|
|
return new CMO_INT32(plotframe.size()); |
return new CMO_INT32(plotframe.size()-1); |
|
} |
|
|
|
private CMO PSET(CMO[] argv){ |
|
plotframe tmp = (plotframe)plotframe.elementAt(((CMO_INT32)argv[0]).intValue()); |
|
|
|
tmp.pset(((CMO_INT32)argv[1]).intValue(), |
|
((CMO_INT32)argv[2]).intValue(), |
|
((CMO_INT32)argv[3]).intValue()); |
|
return new CMO_NULL(); |
} |
} |
|
|
private void debug(String str){ |
private void debug(String str){ |