Life, Technology, and Meteorology

Author: mike (Page 10 of 26)

I ran across a problem in the latest betas of Seasonality where the graphs would show up blank when printing. It took me awhile to fix this issue, so I thought I would post my solution here in the hopes that it might save someone else time in the future. Here’s a screenshot of print output before the fix:

The problem is that the Seasonality graphs are drawn using Core Graphics routines instead of the higher-level Quartz routines. I did this to squeeze a little more speed out of the drawing code, and also gained more customization with transparency settings and layered drawing. Basically, I grab a CGGraphicsRef using [[NSGraphicsContext currentContext] graphicsPort], and use it to draw all the other elements.

From what I could find online, it seemed that the problem was that while printing, the context isn’t referenced until later than it is when drawing it to screen, so the context doesn’t stick around long enough for the printing code to pick up on it and draw. So either I could find a way to retain the graphics context long enough for the printing to complete, or I could find a new way to draw my view for the printer. I didn’t want to retain a graphics context object because I think that makes the code a little messy, so I tried to find a new way to draw my view.

The first thing that came to mind was to not use all the Core Graphics routines to draw the graphs when printing. That would be a very large code change, and it’s a lot of extra code that isn’t used too frequently. The better solution I found was to draw everything to an NSImage first, and then draw the NSImage to the printer. Here’s some code…

- (void)drawRect:(NSRect)rect {
   NSImage *lockedImage;
   BOOL printing = ![NSGraphicsContext currentContextDrawingToScreen];
   if (printing) {
      lockedImage = [[NSImage alloc] initWithSize:rect.size];
      [lockedImage lockFocus];
   }

   // Get our graphics context.
   CGContextRef cgContext = [[NSGraphicsContext currentContext] graphicsPort];

   // Drawing code here...

   if (printing) {
      [lockedImage unlockFocus];
      [lockedImage drawInRect:rect
                     fromRect:NSMakeRect(0, 0, rect.size.width, rect.size.height)
                    operation:NSCompositeCopy
                     fraction:1.0];
      [lockedImage release];
   }
}

Here’s a screenshot of the output after the fix:

This solution has a small disadvantage, you don’t get the ability to print using the printer’s full resolution. Since Seasonality users don’t print too often, this tradeoff is okay, but it might be an issue to consider for other applications.

Buffalo Snow Storm

I just wrote a post on the Gaucho Software Forums about a snow storm that hit Buffalo a little over 10 days ago. It brought almost 2 feet of snow to the area and caused a lot of damage. I happened to be in the area at the time, so I was tracking the storm pretty closely, and I even took a few pictures of the aftermath. If you’re interested, check out the story here.

The story posting is part of a new weather discussion area I added to the forums. If you have any weather stories to share, feel free to start up a new topic and tell everyone about it. Also, bring along any questions you may have about anything relating to weather.

C4 Followup

A great time was had at C4 this past weekend. My trip started out Friday when I met up with John before the conference. I haven’t seen him since this past June, so it was great to hang out again. We went to this excellent Chinese food restaurant, and he showed me around the area a bit that afternoon.

The conference kicked off Friday evening with Wolf giving an introduction and Gruber following up with what was almost a UI state of the union address. After that everyone piled into a couple of busses to head over to Jaks. There I got a chance to talk with Elliot, who has been beta testing Seasonality now for almost a year. He’s working on a new add-on feature for Seasonality that I’ll post more about later.

Saturday kept the ball rolling with some excellent presentations by Brent, Aaron, Gus, Steve, and Brian. Brent talked about web services, and dropped a few references to Seasonality during his presentation (thanks Brent!). Gus gave a great introduction to Lua, which looks like an awesome embed-able scripting language. I’m toying with the idea of adding Lua support in Seasonality. Aaron gave some tips on how to get started with Cocoa and talked about going after the enterprise market. Steve talked about the programming language he created, Io, and how it handles concurrent programming, which was pretty cool. Finally, Brian gave a pretty good overview of Subversion and where the project is going in the near (and far) future.

 

All this great content was concluded with a panel led by DB. Several topics came up during the talk, like suggestions to Apple from the independent developer standpoint, what technologies and frameworks are under/over utilized, and of course some shouting over DRM. 😉 Afterwards everyone headed over to Gino’s for some grub. Speaking of grub, the food at this conference was much better than WWDC. Jamba Juice was brought in Saturday afternoon, plenty of caffeine was available at all times, and the other meals were excellent.

Since the content of this conference isn’t under NDA like Apple’s WWDC is, there were a lot more people taking photos of the sessions and events. You can check out my photos here. John Gruber got a shot of me looking like I’m about to attack. 🙂 I look a lot friendlier in a photo James Duncan Davidson took of the audience.

 

Thanks go out to Wolf for doing an excellent job of putting the conference together. Here’s hoping for a C4 2.0 next year.

C4

I’m getting ready to head off to C4 tomorrow morning. I was pretty excited when I first heard Wolf was putting together this conference, and signed up the day after he publicly announced it. With people like Wolf, Gruber, Brent, Gus, and DB all presenting there, along with some people I haven’t met (Steve DeKorte and Brian Fitzpatrick), this should be a really good conference. Things have been pretty crazy here the past few months, so it will be good to get away from the usual work and spend some time socializing with other developers.

While I’m in the Chicago area, I’ll also get a chance to spend some time both with John and my cousin, so that will be pretty cool as well. I’m hoping to have some time left-over for photography, but we’ll have to see how it goes. The Chicago Marathon is this Sunday, so that might give me a chance to practice some action photography.

Anyway, if you see me at C4, be sure to say hello.

the Bleat

James Lileks of the Star-Tribune in the twin cities writes:

I have a new program that displays weather information from a variety of cities – such things are plentiful, I know, but this one suits my needs. It’s set up to tell me how things are in Mpls, Fargo, NYC, Scottsdale, and Glockamorra. Right now it’s 96 degrees in Scottsdale. At eight PM.

Sometimes I miss Arizona weather… The warm nights were wonderful. Want to go for a walk or bike ride in the evening? No problem, just walk outside. Don’t bother with a jacket (or even long sleeves). Of course monsoon season is incredible as well.

Seasonality 1.4b1 Public Beta

With the lack of forecasts available in Seasonality 1.3.x, I decided to release a public beta of Seasonality 1.4. This way, international users can get a forecast back as soon as possible. There are a couple of other key features that are available with this update. One is the new moon phase/moonrise/moonset functionality that I talked about in an earlier post. The second is the ability to add custom locations in Seasonality. Since Seasonality no longer depends on the limited number of locations for which Environment Canada provided forecasts, the app can now display weather data for any location. The interface for this is still fairly basic in the beta, but it will be improved before the final release. Another feature in the pipeline for Seasonality 1.4 is the ability to edit locations. Right now you can check out the Location Info Panel (via the Window menu) to show the configuration of your current location. The plan is to make those fields editable in the near future.

This is the first public beta I’ve ever released. I was a little bit nervous putting out a beta release publicly, but so far it’s been going pretty well. There haven’t been any bug reports yet, which is great. I’m guessing there has to be at least one or two minor bugs in there somewhere, but it’s comforting that no-one has noticed anything yet.

Rio Benchmarks

After installing the new Athlon X2 4600+ processor in Rio, I have to say I’m very impressed with the performance gains. Not only was I able to re-install Kubuntu server and get all the necessary packages installed again quickly, but the overall responsiveness of the machine is greatly improved while multitasking. This is especially noticeable with running 2 virtual servers using VMware Server.

So what about the benchmarks? I decided to start with the svnmark that Luis introduced on his blog, and downloaded Subversion 1.3.0 (1.3.2 is available, but the last benchmarks I did previously used 1.3.0). After a couple of runs, I found make -j4 to be the quickest. Here are the numbers:

Mac Pro Quad 3Ghz: 0:53
Dual Core Athlon 64 2.4Ghz: 1:27
Quad 2.5Ghz G5: 1:39
MacBook Pro Dual 1.83Ghz: 2:11
Dual 2.5Ghz G5: 2:35
Single Core Athlon 64 2Ghz (same server before upgrade): 2:59

After running this test and seeing the Athlon X2 compile faster than even a Quad G5, I’m pretty happy. Granted, the OS is Linux and not Mac OS X, but I doubt Linux would be that much more efficient when compiling software using gcc.

So how does it stack up with the forecast processing I need the server to do? Well in this case, I don’t have any solid benchmarks, I’m just running off memory here. The old processor was able to generate and serve a forecast in 0.4 seconds, where the new one can do the same request just under 0.3 seconds–a pretty solid 25% performance gain. This is all sequential code, so this doesn’t take into account the availability of a second processor. The forecast update is also a lot quicker, and with a second core the machine should still be able to handle connections from Seasonality to generate forecasts while updating the forecast database back-end.

« Older posts Newer posts »

© 2026 *Coder Blog

Theme by Anders NorenUp ↑