!shadows

Douglas Edric Stanley

2007.05.23

I’m preparing for my presentation on Processing this Sunday at Flash Festival 2007. For this conference I’ve adapted a very sturdy presentation system I started in Lingo way back in 2000. The conversion has been relatively painless, except for the occasional details.

Thanks to Marius Watz and VitaFlo I’ve been able to make a nice Mac OS X full screen application that can open other windows on top of it. Usually Processing runs full-screen applications Java-style, i.e. on top of all other windows, including the dock & menu. But since I want my Applet to be a launching-pad for several websites, videos, and applications, I needed a different solution. Marius’ proposition only removes the menu & dock; this allows for many different solutions for what I want, several of which I’m exploring this week.

But one thing that was bothering me was the operating system’s imposed drop shadows. Mac OS X adds these love-em-or-hate-em shadows for a pseudo(d*3) look, but because of my design choices I wanted them gone. I first tried Window Shade X, but that was lame because it’s a system-wide hack. When you think about it, it’s just a simple application parameter; for example, applications built directly in Apple’s Cocoa environment have drop-shadows as an option that you can just check off from within Interface Builder:

Drop Shadow checkbox in Interface Builder

So after a quick search in Apple Developer Forums on removing drop shadows in Java, I found the following code that is fairly easy to adapt to any Processing Applet :

import com.apple.cocoa.application.NSApplication;
import com.apple.cocoa.application.NSWindow;
import com.apple.cocoa.foundation.NSArray;

public void setShadow(String windowTitle, boolean isShady)
{
  final NSApplication application = NSApplication.sharedApplication();
  final NSArray windows = application.windows();
  Enumeration e = windows.objectEnumerator();
  boolean done = false;
  while (!done && e.hasMoreElements()) {
    NSWindow w = (NSWindow)e.nextElement();
    if (w != null && windowTitle.equals(w.title())) {
      w.setHasShadow(isShady);
      w.invalidateShadow();
      done = true;
    }
  }
}

You just have to include this code into your applet, and then call:

void setup() {

  size(500,500);
  setShadow("", false);

}

There should also be a way to remove shadows via the info.plist, but I wasn’t able to get the right combination.

If you analyze the above code, basically what you have is a hook to the Cocoa platform that looks through all the windows for the one that contains your Java applet. Once you’ve found it, you can easily deactivate its shadows.

Original Comments:

2007-05-27 17:49:14

Etienne

(réponse en français)

Je reviens de Beaubourg où j’ai assisté à ta présentation Processing. Je ne sais pas si l’idée d’intervenir sur Processing dans le cadre du Flash festival est ton idée ou une proposition des organisateurs mais c’est une bonne chose je trouve. C’est quand même très bizarre de voir à Beaubourg des agents d’Adobe venir faire la promotion des nouveaux outils de design (je ne suis pas particulièrement contre Flash et Adobe mais le principe de promotion d’un produit au sein d’une institution artistique soulève quelques questions). Bref. J’ai trouvé très intéressant à la fin l’allusion à l’algorithmisation du monde mais si peu développée (question de temps sans doute). Cette idée aurait pu être la clé de voûte de ta présentation je trouve.