You are brilliant, We are Hiring. Find out more...
Palantir Tech Blog

Archive for January, 2007

Music for coding

Thursday, January 25th, 2007

It’s amazing to me how much the music I’m listening to defines my energy level and output. Couple that with the open office environment we have at Palantir, and I end spending a good portion of the work day listening to music on my headphones. I often use different music for coding than debugging, as the tempo of the two activities feels very different to me. As my coworkers know, I’m a total beat-head and lover of drum machines, but even within that, I like to mix it up a bit. Here’s a quick list of the internet radio I like to listen to while coding:

  • HBR1 - the crazy Germans at HBR1 give us Psytrance on tap, probably the most driving of all the genres. The I.D.M. Tranceponder Stream stream is pretty consistently driving and great to code to.
  • Proton Radio - really good house music. Probably the best on the web. Consistently good to code to, slightly less energetic than the HBR1 pystrance streams. [stream link here].
  • SomaFM - an grand old institution of internet radio, SomaFM is operated out of San Francisco and has streams for every taste. People like Brien, who like things a bit more chill, love their famous flagship stream, Groove Salad. Their trance stream, known as Tag’s Trance Trip is similar to HBR1’s channels, but slightly less psy and a bit more classically trance-ish. There’s a are 11 different streams coming out of SomaFM, all worth checking out.
  • Digitally Imported Radio - they have a whole bunch of streams, without fancy names, split by genre. I’m personally a fan of their house and breaks streams, but there are many more.
  • BreaksFM - Breaks out of the UK. This station has some great underground, really big breaks. Occasionally, there’s a little too much talking by the DJ over the stream, but the music so exceptional, it more than makes up for it. Stream links: Channel 1 Channel 2.

Swing hack: making transparent components disappear

Wednesday, January 10th, 2007

We encounter overlapping components a lot in our application, in situations ranging from a huge drag-and-drop panel across the main frame to small, unavoidable collisions in some of our smaller components. These overlaps almost always involve a transparent component that is used to paint something cool to the screen. Since the final layout looks visually good, it’s easy to think Swing is feeling good. However, this usually isn’t true.

Even though a component is transparent, Swing may still think it occupies some area. You can test this by creating a large transparent panel over a text box and calling SwingUtilities.getDeepestComponentAt(frame, textbox_midx, textbox_midy). You’d expect it to return the textbox; however, it actually returns the transparent panel! Whoa, that’s kind of silly, but what does it matter? The most noticeable loss is the cursor of the textbox. The cursor of the transparent panel will show up instead, even though it’s visually wrong. Other losses would be anything that relies on getDeepestComponentAt, findComponentAt, etc. to return an accurate result.

So how do we make a transparent component disappear to Swing? We were using the hack described by Alex Potochkin in “A well-behaved GlassPane,” for a while, but it turns out things like Container.findComponentAt() actually use Component.contains(). Setting it to a constant false has the effect of hiding all child components as well as the transparent component itself. A better Swing hack might be one that reports a point (x, y) contained in a parent component if it is contained in any child component. That’s what I have below. Just override JComponent.contains() and you’re set!

Here’s a code snippet illustrating the point:


Hello World - we are Palantir Technologies

Wednesday, January 3rd, 2007
Tech Blog Logo

Welcome to the Palantir TechBlog. Here’s a place for our engineers to sound off about all things technical. For now, it will be mostly related to general software engineering topics with a focus on development of enterprise software in Java. This will lead us to talk about SQL, Unix, Swing tricks, scaling Java, development practices and a host of other attendant topics related to what we do.

To be clear: we’re not a J2EE shop, we’re building enterprise class software from the ground up out of Java. So what does that mean? We’re building large scale data systems that have a server component and desktop client component. Which means that we sort of touch on everything end-to-end, from making Swing performant and pretty to building custom database code to model some of the very interesting things that we’re dealing with.

Please feel free to comment, we’d love to hear from you.