We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Page Index Toggle Pages: 1
Documentation for dataFile() (Read 2061 times)
Documentation for dataFile()
Oct 28th, 2009, 7:29am
 
I have a piece of code that tries to load an image for a 'node' in my visualisation using the node label as the filename. If an image is present it will be used as an icon for that node, otherwise I just use the label as text. This allows me to change the appearance of specific nodes just by dropping in image files - no code needs to be touched.

It all works fine (loadImage() returns null if the image isn't present) but I get a bunch of error messages complaining about the missing file.

This is annoying as the 'missing' files aren't a problem. I knew I could fix this by simply checking for the image file first, but to do that you have to know how loadImage() works. As it turns out there is a public method, dataFile(), that encapsulates this knowledge, so I can simply write:

PImage img = null;
if (dataFile(imageName).exists()) {
 img = loadImage(imageName);
}


This is easy enough, but to find the solution I had to dig through the SVN repository and read the code. It would be a lot easier if this method was documented (and referenced in the methods that access data files).
Re: Documentation for dataFile()
Reply #1 - Oct 28th, 2009, 10:16am
 
I believe such "information hiding" is voluntary, as a number of public fields and methods are, somehow, targeted for more advanced users...
These users doesn't need to read the code (even though it is instructive, interesting and useful) but can look at the complete JavaDoc reference to be found in the Contribute section of the site (or directly at there for the core).

Now, I don't contest your request, it is up to the authors to choose to put that in the main reference or not. I just want to show such reference exists already, even though it can be harder to find! Smiley
Re: Documentation for dataFile()
Reply #2 - Oct 29th, 2009, 1:40am
 
If the Javadoc is intended as the primary resource for 'advanced' users then perhaps this should be more prominently linked from the 'Reference' and 'Learning' pages.

At the moment it looks as though the Language A-Z is the whole language, which is a little bit misleading, and a little bit offputting if you have a problem that you can't solve using this 'beginner' subset.

I think it's a good idea to define such a basic subset of the language so as not to overwhelm newcomers, but a clear link to the full documentation would also help to keep 'geeks' from being put off by what currently looks at first glance to be a 'toy' language.
Re: Documentation for dataFile()
Reply #3 - Oct 29th, 2009, 2:22am
 
Somehow, I agree.
In the past, there were an Abridged reference showing a subset of the API, and an Extended Reference. It was found confusing, so they removed the Abridged reference and only shown the complete one.
I kept a link to the old Extended reference page (linked above) which still exists (probably to avoid breaking links) so I haven't noticed the current Reference page, which is, now, the complete one (you follow Smiley) no longer have a link to the Developer reference.
Pfw!
In short, perhaps it can be a good idea to restore a link to the developer reference in the official API page.
Re: Documentation for dataFile()
Reply #4 - Oct 29th, 2009, 4:12am
 
I can see why having abridged, extended and complete documentation could be confusing. I would just have found it useful to have a prominent link to the complete reference documentation, perhaps with a short description of why there are different documentation 'levels' in the first place. Something like:

Quote:
The subset of the Processing Language described in this language reference should allow you to understand the examples and create your own sophisticated programs. For more advanced users the complete language reference can be found here.
Re: Documentation for dataFile()
Reply #5 - Oct 29th, 2009, 4:29am
 
Please be mindful of the description on dev.processing.org/reference:

"Please note that this reference is not complete, and it probably won't ever be. The “official” reference of supported functions will always be here: http://processing.org/reference/. However, this version may contain additional technical details that you may find useful."

I haven't had time to write proper javadoc for all of the functions. And it's *not* intended as a primary reference for anything. Not advanced users, not Eclipse users, etc. Such caveats are repeated multiple times on that page.
Page Index Toggle Pages: 1