Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

This question already has an answer here:

I enjoy using Mathematica's notebook interfaces, but more specifically the autocompletion in each notebook.

I'm in need of a way to put tons of Mathematica windows on the same page.

It would be an application to organize/structure Mathematica code. The standard windowing system in Windows 7 doesn't work because the Windows both don't save state between shutdowns and the equations don't really overlap in the way I'm looking.

A similar piece of software would be something like Inkscape or PowerPoint, but instead of having all the settings in would just contain Mathematica input or output.

The simplest solution would involve taking text input from an application, and outputting a PNG version of the data to the screen of the application. I would then be able to drag around the different examples.

My Question: Does there exist a way to embedded Mathematica's notebook interface into Java or .NET applications (or entirely other system)?

I could live without autocompletion but the character insertion techniques e.g. \[Infinity] -> ∞ are both incredibly helpful and keeps eyes and head sane. :)

share|improve this question
add comment

marked as duplicate by Ajasja, Sjoerd C. de Vries, rcollyer, Oleksandr R., Artes Feb 8 '13 at 0:33

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1 Answer

up vote 8 down vote accepted

This is not necessarily an answer, but the Mathematica system is very flexible and I think you might be able to accomplish what you're after with Mathematica itself. Look at this code here:

nbWindow = Null;
nb = Notebook[{}];

OPEN[] := Module[{},
   nbWindow = NotebookCreate[Visible -> False];
   nbWindow = NotebookPut[nb];
   SetOptions[nbWindow, Visible -> True,
    DockedCells -> None, Saveable -> False,
    WindowTitle -> "",
    Background -> White, WindowFrame -> "Palette",
    WindowMargins -> {{Automatic, 0}, {Automatic, 0}},
    WindowSize -> {400, 200}, WindowTitle -> title,
    NotebookEventActions :> {
      "WindowClose" :> CLOSE[]
      }]
   ];

CLOSE[] := Module[{},
   If[Head[nbWindow] === NotebookObject,
    nb = NotebookGet[nbWindow];
    NotebookClose[nbWindow];
    nbWindow = Null]
   ];

Row[{Button[open, OPEN[]], Button[close, CLOSE[]]}]

This shows you some of the ways you can manipulate Notebooks. Notice that you can set up UI hooks (such as "WindowClose") and that you can specify the WindowFrame. You can have a notebook show up as a palette window, frameless, etc. You can also specify the location/dimensions of the window.


That code is a slightly cleaned-up simplification of a Mathematica project I was playing around with: an "idea-tracker."

workspace[title_: None] := DynamicModule[{
    CLOSE, nb, lnb, originalSymbol, symbol, 
    frameColor = Lighter[Gray, .85], 
    polarity = ImageApply[#^0.6 &, #] &, 
    backgroundColor = Lighter[Gray, .9]},

   symbol = originalSymbol = Module[
      {g, effect = 0.198`, inflection = 1, spirality = 0, 
       thickness = 0, x = 5.2`, y = 0.`, \[Zeta] = 2},

      g[angle_, scale_: 1, color_: GrayLevel[0]] := 
       Module[{rotate = ((Complex @@ #) E^(I angle) // ({Re[#], 
                Im[#]} &)) &,
         \[Psi]$ = 
          Round[Abs[FractionalPart[\[Zeta]]] 1.`, 0.25`] /. {0.` -> y,
             0.5` -> y/2, 0.25` | 0.75` -> y/4}},

        ParametricPlot[
         scale*rotate[
           (1.` + 
              spirality (Log[\[Theta] + 1.`] - 
                 1.`)) {\[Psi]$ Cos[\[Theta]] + 
                  x Cos[64.` \[Theta]] + ((1 - 
                       effect RandomReal[]) \[Zeta]) (Cos[
                      512.` \[Theta]] + 
                     Cos[(64.` \[Zeta]) \[Theta]]), \[Psi]$ Sin[\[Theta]] \
- x Sin[64.` \[Theta]] + (((1 - 
                    effect RandomReal[]) inflection) \[Zeta]) (Sin[
                  512.` \[Theta]] + Sin[(64.` \[Zeta]) \[Theta]])}
           ]

         , {\[Theta], 0, 2 \[Pi]}, ImageSize -> {50, 50}, 
         PerformanceGoal -> "Quality", 
         PlotStyle -> {{color, Opacity[0.05`], 
            AbsoluteThickness[thickness]}}, 
         PlotRange -> 10*{{-1, 1}, {-1, 1}}, PlotPoints -> 270, 
         Axes -> None]];

      Rasterize[Show[
        g[-(1/4) (2 Pi)/3, 1, Lighter@Blue],
        g[(1/4) (2 Pi)/3, 1, Darker@Blue]]
       , "Image"]
      ];

   lnb = Null;
   nb = Notebook[{}];

   CLOSE[] := {
     polarity = Identity;
     backgroundColor = Lighter[Gray, .9];

     If[Head[lnb] === NotebookObject,
      nb = NotebookGet[lnb];
      If[First[nb] =!= {},

       symbol = Rasterize[
         If[NotebookRead[lnb] =!= {}, NotebookRead[lnb], lnb]
         , "Image", ImageSize -> {50, 50}],
       symbol = originalSymbol
       ];
      NotebookClose[lnb];
      lnb = Null;
      ]
     };

   EventHandler[
    Deploy@
     Grid[{{Dynamic[polarity[symbol]]}}, Frame -> True, 
      FrameStyle -> Dynamic[frameColor],
      Background -> Dynamic[backgroundColor]],
    {
     {"MouseClicked", 1} :> Module[{a, screenWidth, minH, maxH},
       If[Head[NotebookGet[lnb]] === NotebookGet,
         {{{a, screenWidth}, {minH, maxH}}} = 
          "ScreenArea" /. ("ScreenInformation" /. $sysinfo);

         polarity = ColorNegate;
         backgroundColor = Lighter[Red, .9];

         lnb = NotebookCreate[Visible -> False];
         lnb = NotebookPut[nb];
         SetOptions[lnb, Visible -> True,
          DockedCells -> None,
          Saveable -> False, Background -> White,
          WindowFrame -> "Normal",
          WindowMargins -> {{Automatic, 0}, {Automatic, 0}},
          WindowSize -> screenWidth/2,
          WindowTitle -> title,
          NotebookEventActions :> {
            "WindowClose" :> CLOSE[]
            }];
         ];
       ],
     {"MouseClicked", 2} :> CLOSE[],
     "MouseEntered" :> {
       polarity = If[polarity =!= ColorNegate, Identity, polarity];
       backgroundColor = Lighter[Gray, .7];
       $sysinfo = 
            If[ValueQ[$sysinfo], $sysinfo, SystemInformation["Devices"]];
       },
     "MouseExited" :> {
       polarity = 
        If[polarity =!= ColorNegate, ImageApply[#^0.6 &, #] &, 
         polarity];
       frameColor = Lighter[Gray, .85];
       backgroundColor = Lighter[Gray, .9];
       }
     }]
   ];

tetragrammaton[] := 
  DynamicModule[{txt, appearance = "Framed", content},
   content = {
     Style[
      InputField[Dynamic[txt], String, 
       Appearance -> Dynamic[appearance],
       Alignment -> "Center", FrameMargins -> 2, ImageSize -> 400], 
      FontFamily -> Default, FontWeight -> Bold],
     workspace[Dynamic[txt]]};

   Deploy@
      EventHandler[#, {"MouseEntered" :> {appearance = "Framed"}, 
        "MouseExited" :> {appearance = "Frameless"}}] &@
    Framed[Row[content, " "], FrameStyle -> Lighter[Gray, .8]]
   ];

tetragrammaton[]

enter image description here

You type your idea/note in the box and then you click on the little symbol (which is a DynamicModule) to open a "workspace," which is just a blank notebook. Right-clicking on the symbol or closing the notebook will save the notebook within the DynamicModule. If the workspace isn't blank, the swirly symbol is replaced by a thumbnail of the workspace, or if you select something in the workspace before closing it, that selection will be used as the thumbnail. Hypothetical notes.nb:

enter image description here

(The idea is that you can work on ideas in their own individual workspaces without clogging up the main notebook with a bunch of visually-noisy content and section/subsection stuff).

This code is exploratory, incomplete, non-clean, and buggy, and I'm now pursuing a different approach for an "idea tracker." But it shows some of the stuff you can do with the notebook system.

I also recommend you take a look at this thread: Use Mathematica as a terminal

share|improve this answer
1  
I forgot to emphasize this: Implicit in your ability to set the position/size/appearance/event hooks/etc of windows is the idea that you can create your own fairly arbitrary windowing system. For example, you can make it so that when you click a button, a 2x4 grid of windows appears on your screen, and have it so that when you Shift+enter in one of the windows on the left column, the result shows up in the window to its right. Then have it so that clicking the button again saves+closes the grid. etc. etc. etc. –  amr Feb 7 '13 at 20:09
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.