Custom drawing and cacheing
Custom drawing and cacheing
- Subject: Custom drawing and cacheing
- From: Candide Kemmler <email@hidden>
- Date: Thu, 28 Jun 2001 12:38:42 +0200
Hi,
I would like to port a geographical mapping software I wrote originally
in Java to MacOS X. Of course, I'd prefer to use the Java-Cocoa
interface, so I'm trying to learn just that.
Basically, the first thing to do is to have a map drawn in a window. The
program gets the map data through a URL, parses the data, and eventually
draws the data.
Until now, I've tried 2 things: 1) extending NSView; 2) extending
NSImageRep.
1) extending NSView: works, but the whole things is redrawn every time
the window is resized.
2) extending NSImageRep. Since the data I get is not exactly a "file
type", but just raw data, I'm enclined to use the NSData way of
instantiating an NSImage (or NSImageRep). I tried subclassing
NSImageRep, to override its draw () method. I made the canInitWithData
(NSData data) return true. But then I thought the NSData needed to be
something special I could rely on to determine if its type is correct
(so my custom imageRep can parse it); so I wrote a subclass to NSData
which I called mapData. And there I got strange errors not at all
related with java but with a mapping thing related with a "Bridge to
Objective-C" or something... I tried several other things, but that's
not really interesting.
2 questions:
- does someone know how I could begin to do what I want ?
- what's the real status of java in cocoa. Seems like it really depends
on some of Objective-C's features. I fell several times on strange
errors that I can not relate to Java...
thanks !
Candide