seekerm
Posts: 11
Joined: Tue Dec 27, 2011 12:43 am

Re: PiCard - GUI SD Preparation Tool

Sun Jan 01, 2012 6:41 pm

In order to recommend some way some more details may be helpfull(like the way you want to use it).

liamfraser280
Posts: 354
Joined: Tue Oct 04, 2011 6:53 pm
Contact: Website

Re: PiCard - GUI SD Preparation Tool

Sun Jan 01, 2012 6:45 pm

seekerm said:


In order to recommend some way some more details may be helpfull(like the way you want to use it).



Ahh yes sorry! Rushed that post a little....

I'd like to be able to set a languages in the preferences (or get the system default) and then where I currently have "Main Menu" be able to say stringTable.MainMenu and then that will return the correct translation of "Main Menu" depending on the language. Or something similar to that . Would also be good if the tranlsator did not have to edit any java source code.

Thanks,

Liam.

seekerm
Posts: 11
Joined: Tue Dec 27, 2011 12:43 am

Re: PiCard - GUI SD Preparation Tool

Sun Jan 01, 2012 7:08 pm

The Collectiontype which would fit for that kind of job is HashMap.

Its a very simple Key-Value-Relation.

Translations could be loaded from some xml(e.g. DOM-parser)- or sqlite(jdbc)-file for example.

Post your code on git, when you will have some so ppl can provide patches for like things .

Sidenote: Hardcoded-version can be done with enum's

liamfraser280
Posts: 354
Joined: Tue Oct 04, 2011 6:53 pm
Contact: Website

Re: PiCard - GUI SD Preparation Tool

Sun Jan 01, 2012 7:16 pm

Thanks Seekerm! It looks good. I'll look into it when I have some free time tomorrow.

Would you (or any other java devs) be up for peer reviewing my code when I'm further down the development path? To ensure that it is good robust code, and so that I can ensure I'm using good practice

User avatar
mkopack
Posts: 242
Joined: Mon Nov 07, 2011 8:46 pm

Re: PiCard - GUI SD Preparation Tool

Sun Jan 01, 2012 7:17 pm

What I'd suggest is using Java Properties files, and load different ones in based on language at startup time (of the app).

So for instance, you make a file like this:

string1=this is a test

string2=ok

string3=cancel

etc.

Make another version where the right side is in french, another in italian, etc.

Use java.util.Properties and call it's load at startup.

Then in the app, whenever you go to build up the UI elements (labels, etc.) just fetch the proper one out of the properties. For instance:

JLabel label1 = new JLabel(props.getProperty("string1"));

As far as the layout stuff goes, you shouldn't use fixed position layouts. Think about it like this - a word in English might only need 75 pixels across to display. The same word in German might be 100 pixels across. If you used fixed point layout then you might not have enough room for the German version without it being chopped off. Follow me?

Instead, use something like Spring layouts, or GridBagLayout (this is the most powerful, but also by far the biggest PITA layout in Java). These will resize dynamically based on the needed size of the label and the size of the window, and also the different L&F's used.

Otherwise, looking good. Hope this helps!

liamfraser280
Posts: 354
Joined: Tue Oct 04, 2011 6:53 pm
Contact: Website

Re: PiCard - GUI SD Preparation Tool

Sun Jan 01, 2012 7:20 pm

Property files sound easier actually ! Thank you.

The main reason I didn't use the other layouts is because I don't understand how to use them. Will have a proper look into it... you make a good point about different languages having different lengths for words and so on.

seekerm
Posts: 11
Joined: Tue Dec 27, 2011 12:43 am

Re: PiCard - GUI SD Preparation Tool

Sun Jan 01, 2012 7:31 pm

Propertyfile-way, suggested by mkopack, can be handy aswell, depending on the use case.

And yes I will take a look at your java code for sure, I guess a lot ppl will do

chrisg
Posts: 28
Joined: Wed Sep 21, 2011 6:41 pm
Location: Epsom, Surrey

Re: PiCard - GUI SD Preparation Tool

Sun Jan 01, 2012 7:46 pm

The "official" way to do Internationalisation with Java is to use ResourceBundles.

The PropertyResourceBundle implementation does the same as what has already been suggested with Properties files, but adds some conventions for how properties files get named for different locales, and adds some simple fallbacks when loading properties.

http://docs.oracle.com/javase/.....ncept.html

http://docs.oracle.com/javase/.....undle.html

Hope this helps,

Chris

liamfraser280
Posts: 354
Joined: Tue Oct 04, 2011 6:53 pm
Contact: Website

Re: PiCard - GUI SD Preparation Tool

Sun Jan 01, 2012 7:58 pm

Thanks so much for your advice guys! I'll have a look through all of this.

Cheers,

Liam.

liamfraser280
Posts: 354
Joined: Tue Oct 04, 2011 6:53 pm
Contact: Website

Re: PiCard - GUI SD Preparation Tool

Mon Jan 02, 2012 5:36 pm

mkopack said:


Instead, use something like Spring layouts, or GridBagLayout (this is the most powerful, but also by far the biggest PITA layout in Java). These will resize dynamically based on the needed size of the label and the size of the window, and also the different L&F's used.


I have found a pretty good method of using GridBag ... design in absoloute so there is no messing around. Then change to grid bag - makes all of your rows/cols for you and fits it all nicely!

Michael
Posts: 340
Joined: Sat Jul 30, 2011 6:05 pm

Re: PiCard - GUI SD Preparation Tool

Mon Jan 02, 2012 5:54 pm

Bradburts, Liam,

Excellent idea and great work so far.  This community is awesome!

--

Michael

liamfraser280
Posts: 354
Joined: Tue Oct 04, 2011 6:53 pm
Contact: Website

Re: PiCard - GUI SD Preparation Tool

Mon Jan 02, 2012 6:48 pm

Michael said:


Bradburts, Liam,

Excellent idea and great work so far.  This community is awesome!

--

Michael



Thanks Michael !

Not sure if we'll have something fully working for the initial release because I have exams and stuff like that but I'll try my best (at the least there will be a basic image flash but would require manual partitioning. I'm pretty sure most of the people buying the device now will be fine with using GParted or similar!). I'm doing research at the moment... Getting disk capacity (important so people pick the correct storage device to DD ) across the three platforms is a PITA because they all need different methods. Suppose that will be true for quite a few things on this project.

P.S Java Devs... I'm now using GridBagLayout which is working okay. The JPanel will resize itself when things are set to grow. However, is there an option I need to set on the JFrame to get that to also resize, or do I have to implement an event listener for when the content is sized?

Thanks,

Liam.

Borg 1.0
Posts: 35
Joined: Sun Jan 01, 2012 1:02 pm
Contact: Website

Re: PiCard - GUI SD Preparation Tool

Tue Jan 03, 2012 12:53 pm

Please correct me if I"m wrong, but once a card has been partitioned and filled, it should be possible to treat the "disk" as a raw image, no? After all the "ritin" and partitioning and so on, it"s simply a collection of sectors, which is eminently manageable.

If so, I"d be more than happy to write a native Windows image manager for those of us without native access to linux. I"m thinking of something along the lines of WinImage, but written specifically for the RasPi images. It obviously doesn"t need all the low-level sector/size management guff, so I could spend that time managing image sizes and so on.

I"d be interested to hear from anyone who might be interested in using such a tool. If there"s enough interest, I can whip up a proof-of-concept demo, and we can take it from there.

Obviously, this relies on someone else doing the hard stuff (building the images and so on), but it might help prevent wheel reinvention.

Any comments or suggestions?

bradburts
Posts: 341
Joined: Sun Oct 02, 2011 7:07 am

Re: PiCard - GUI SD Preparation Tool

Tue Jan 03, 2012 1:07 pm

Welcome on board.

There are more than a few paths available.

Personally I think that the software writting part of this task has effectively been covered by the Windows imagers already posted. Detailed 'how to' instructions remain.

Liam has higher goals in mind.

What exactly are you thinking? What would your WIM do? What does 'managing image sizes' involve?

I note that WinImage has ext3 support but unfortunately does not allow writes to ext3.

IMHO Windows native ext3/ext4 write support is the main bottleneck to a truely useful tool.

EDIT: But what is being done will be fine.

liamfraser280
Posts: 354
Joined: Tue Oct 04, 2011 6:53 pm
Contact: Website

Re: PiCard - GUI SD Preparation Tool

Tue Jan 03, 2012 1:21 pm

I don't see the point in rewriting software to just simply write images, there are plenty on here as bradburts has said. The actual image writing process of my software is easier than getting a list of disks and their capacity to be honest! (3 different ways for Win,Unix/Linux and Mac)

Borg 1.0
Posts: 35
Joined: Sun Jan 01, 2012 1:02 pm
Contact: Website

Re: PiCard - GUI SD Preparation Tool

Tue Jan 03, 2012 1:56 pm

No problem, guys, just thought I"d offer!

My "host" system (at least, the one I"m planning on using with the RasPi) doesn"t have a virtual machine (so Linux-ing the images isn"t an option I can use), and it doesn"t run java either. I guess this makes it a "corner case" box, hence my wish to be able to use a native app to work with images.

If I can"t find a tool that"ll work with the images before I start using the RasPi to do just that, I"ll be writing a tool anyway. At least this way, I know how user-cuddly I need to make it!

Thanks for your explanations, I appreciate your concerns with "hand-rolled" apps floating around!

bradburts
Posts: 341
Joined: Sun Oct 02, 2011 7:07 am

Re: PiCard - GUI SD Preparation Tool

Tue Jan 03, 2012 2:08 pm

I am confussed.

@Liam

1) What does: "The actual image writing process of my software is easier than getting a list of disks and their capacity to be honest!" mean?

@Borg

2) What does: "I could spend that time managing image sizes and so on" mean?

I think that in both cases I may be being a little slow

You will be able to buy a Pi complete with SD card at launch.

You will be able to clone that SD card using the tools that already have been posted.

Please don't let me dampen interest in writting home rolled applications. The foundation's aim is to promote computer science (albeit for young people) so any learning / interest is good.

liamfraser280
Posts: 354
Joined: Tue Oct 04, 2011 6:53 pm
Contact: Website

Re: PiCard - GUI SD Preparation Tool

Tue Jan 03, 2012 2:14 pm


Bradburts said:

I am confussed.

@Liam

1) What does: "The actual image writing process of my software is easier than getting a list of disks and their capacity to be honest!" mean?


It means that DDing images to an SD card is easy. Linux and Mac come with DD... and I just have to execute that and parse the progress. Windows has a lot of command line DD clones/similar alternatives ready for use.

It's harder (i.e takes a lot longer to implement) getting a list of storage devices and their capacity so that the user can choose the correct SD card.

liamfraser280
Posts: 354
Joined: Tue Oct 04, 2011 6:53 pm
Contact: Website

Re: PiCard - GUI SD Preparation Tool

Tue Jan 03, 2012 2:34 pm

Cephas Borg said:


No problem, guys, just thought I"d offer!

My "host" system (at least, the one I"m planning on using with the RasPi) doesn"t have a virtual machine (so Linux-ing the images isn"t an option I can use), and it doesn"t run java either. I guess this makes it a "corner case" box, hence my wish to be able to use a native app to work with images.

If I can"t find a tool that"ll work with the images before I start using the RasPi to do just that, I"ll be writing a tool anyway. At least this way, I know how user-cuddly I need to make it!

Thanks for your explanations, I appreciate your concerns with "hand-rolled" apps floating around!



Could I ask why you wouldn't install Java on your machine? As long as you stop the very handy 'auto updater' from starting there should be no performance impact. I do believe you can natively compile Java applications but don't know much about it.

bradburts
Posts: 341
Joined: Sun Oct 02, 2011 7:07 am

Re: PiCard - GUI SD Preparation Tool

Tue Jan 03, 2012 2:37 pm

I was right, I was being slow.

liamfraser280
Posts: 354
Joined: Tue Oct 04, 2011 6:53 pm
Contact: Website

Re: PiCard - GUI SD Preparation Tool

Fri Jan 06, 2012 12:00 pm

Hi All, (Any Java/C++ Devs with a spare couple of hours and want to help out? – please read to the bottom)

EDIT: A Dev might not be needed anymore because my Dad has agreed to help ... however this is still info on how the software will work so it's a useful read!

Just a little update on the progress. I'm reasearching the best way to get the different image sizes to people as well as developing the program. For now I've decided to leave out localization for the initial release as that's just one more thing I have to worry about. So far I can get a list of volumes on Unix and Mac, working on Windows. It's taking a while because there are three different methods (one for each platform).

So to test the best way to distribute images, I've been messing with compression utilities, GParted and DD. I zeroed a 4gb and 8gb sd card. Formatted the 4gb with a fat32 and ext3 partition. Then DD'd this to an image file. I then DD'd the image file to the 8gb card. Resized the ext3 partition to take up the rest of the free space and then DD'd that 8gb card to an image file. Now obviously, providing numerous image files is ineficcient and would require a lot of downloads if a user had more than one size card.

So… introducing Jonjos Binary Diff -

JDIFF is a program that outputs the differences between two binary files, either in binary format or in human readable format (detailed or summarized). JPATCH then allows to reconstruct the second file from the first file.

This works across windows and Linux and allows me to create a diff file between the 4gb and 8gb image of roughly 2mb (shrinks to almost nothing when compressed).

All the images need to be created on Linux anyway so that's fine. The idea is, to have the original distro image – and then just use diff files to make an image of 2, 4, 6 8 gb and so on. Then you just patch the appropriate diff file to the original to get the desired image size. Very efficient as it only requires one download and the diff files are tiny! I chose JDIFF for it's ability to create small diff files, use low enough memory to run on a Pi – and handle extremely large files.

The diff utils for java only currently work with text files. So – I've been looking at the binary diff source code. The actual diff code is complicated as expected… but the patch code doesn't look too bad. It's written in C++ but there is no reason why the patch function (and only that) can't be ported to Java (don't want to leave mac out as I've already put a considerable amount of work into getting that supported). The only problem is, I don't know enough C++ to port it. I basically would like Java code that can patch files made by the JDIFF utility !

http://sourceforge.net/project...../jojodiff/ The project is here and the source is included with the binaries. Would any Java dev's be up for having a little go at this? We want to port void jpatch from the file jpatch.cpp

It's probably a good idea to keep it in a seperate package and then we can also give it to the author of the original… of course you'd get all the credit and all that jazz!

I'd love to give it a go but have to balance this project with college work & exam revision!

Thanks,

Liam.

User avatar
walney
Posts: 233
Joined: Wed Nov 30, 2011 6:57 pm
Contact: Website

Re: PiCard - GUI SD Preparation Tool

Fri Jan 06, 2012 2:50 pm

I haven't been following this thread too closely and am a bit rusty on Linux so I'm not sure that it's doable, but have you considered the possibility of having the Linux install doing its own formatting and resizing?

Could you not have a standard Linux install that you stick on a card of any size? Then, at first boot, load into a RAMDISK. You would then have a known Linux OS that you could use and dynamically repartition/reconfigure the SD card on the fly.

liamfraser280
Posts: 354
Joined: Tue Oct 04, 2011 6:53 pm
Contact: Website

Re: PiCard - GUI SD Preparation Tool

Fri Jan 06, 2012 3:21 pm

walney said:


I haven't been following this thread too closely and am a bit rusty on Linux so I'm not sure that it's doable, but have you considered the possibility of having the Linux install doing its own formatting and resizing?

Could you not have a standard Linux install that you stick on a card of any size? Then, at first boot, load into a RAMDISK. You would then have a known Linux OS that you could use and dynamically repartition/reconfigure the SD card on the fly.



Yeah It's been considered. It's probably possible but that would take a lot of work from the teams who are building the distros. This way, it's easier for distros to get an image working for the Raspberry Pi and not have to worry about how it's distributed. It's not a bad solution considering the requirements and limitations we have

bradburts
Posts: 341
Joined: Sun Oct 02, 2011 7:07 am

Re: PiCard - GUI SD Preparation Tool

Fri Jan 06, 2012 3:32 pm

Liam,

I may be being slow again....

I don't follow your reasoning. Where are you going to get the original image file from? Why is it a lot of work to resize the disk by 'normal' Linux means?

liamfraser280
Posts: 354
Joined: Tue Oct 04, 2011 6:53 pm
Contact: Website

Re: PiCard - GUI SD Preparation Tool

Fri Jan 06, 2012 3:39 pm

Bradburts said:


Liam,

I may be being slow again....

I don't follow your reasoning. Where are you going to get the original image file from? Why is it a lot of work to resize the disk by 'normal' Linux means?



Original image is coming from official Rasp Pi of course . It's honestly fairly simple... although time consuming at the back end. Copy the official image to a 2, 4, 8, 16 and 32gb image file. Mount them all and resize. Then binary diff each one from the original image because alls that's changed is some partition info. At user end... Build the correct image for the sd card by patching diff for that size to original inage and DD it to users sd card. Surely having a distro load into a ramdisk isn't normal - and quite a lot of work?

Return to “Other projects”