MathGroup Archive 2002

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: MathCanvas JInternalFrame

  • To: mathgroup at smc.vnet.net
  • Subject: [mg36261] Re: [mg36249] MathCanvas JInternalFrame
  • From: Werner Schuster <schuster at deltasoft.at>
  • Date: Thu, 29 Aug 2002 01:37:43 -0400 (EDT)
  • References: <200208280816.EAA18605@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Gary Stump wrote:
 > I am writing a Java application that displays Mathematica output using
 > MathCanvas.  I am having difficulty in that the internal frames
 > (JInternalFrame)in my application are covered by the MathCanvas when
 > the internal frames are moved into the MathCanvas area.  I tried
 > setting the frame's layer to 0, but that didn't work.  Can anyone help
 > me out?

I suppose the problem is, that MathCanvas is an AWT Component, which
causes problem with the other Swing JComponents;

2 possible solutions:
   - get J/Link 2.0, which comes with a Swing version of MathCanvas
(MathGraphicsJPanel if memory serves);

   - if you can't do that, write a Swing replacement for MathCanvas
using Swing; this is pretty simple: you can use the evaluateToImage
methods, which return a byte array containg a GIF Image; if you want
to make it very simple, you just make your control a JPanel that
contains a JLabel, and when you want to set a M_-GraphicsExpression
   (from a Plot,...) you just set the GIF Image as the JLabels Icon;
something like this (jlPlot being the JLabel):

KernelLink kl = StdLink.getLink();
StdLink.requestTransaction();^M
byte [] bGifData = kl.evaluateToImage(sExpression, width,height);
if (bGifData == null || bGifData.length <= 1){
   System.out.println("bGifData empty");
}
Image iPlot = Toolkit.getDefaultToolkit().createImage(bGifData);
iiPlot.setImage(iPlot);
jlPlot.setIcon(iiPlot);
jlPlot.repaint();


murphee




  • Prev by Date: Re: MathCanvas JInternalFrame
  • Next by Date: DSolve for a system of 3 equations
  • Previous by thread: Re: MathCanvas JInternalFrame
  • Next by thread: stange result with complex numbers