Saturday, 1 November 2008

Geoff on GEF pt. V

Erk! Hit a really difficult problem now. I've been working on printing a draw2d figure from my app for a few days now (on and off). I have managed, through debugging, to show that the figures are all being laid out as expected. My output is producing the correct number of blank pages and I have managed to display all text on screen once, before re-writing slightly, but I have not yet managed to produce the required text on the pages.

The following shows what I have so far:

Printer printer = new Printer(data);
Graphics graphics = new PrinterGraphics(new SWTGraphics(new GC(printer, SWT.LEFT_TO_RIGHT)), printer);
Rectangle printRegion = getPrintRegion(printer);

+ " Score Cards");

Figure root = new Figure();
root.setLayoutManager(new ToolbarLayout(false));
root.setForegroundColor(new Color(printer, 0,0,0));

for (CompetitorStatus status : competitorStatuses) {
IFigure page = buildFigure(status);

Canvas c = new Canvas(new Shell(), SWT.None);
c.setLayout(new FillLayout());
LightweightSystem lwsTmp = new LightweightSystem(c);
c.setBounds(printRegion.x, printRegion.y, printRegion.width, printRegion.height);

graphics.translate(-printRegion.x, -printRegion.y);
printRegion.setLocation(printRegion.x, printRegion.y);

Sunday, 26 October 2008

Geoff on GEF pt. IV

Wow! Things are now really falling into place.

Most of my effort recently has been spent trying to get my GEF ViewPart to display in a seperate window, as a nice touch I wanted it to display in fullscreen on a second monitor if one is available. Amazingly, I've done it.

public void run() {
Display display = Display.getDefault();
Monitor[] monitors = display.getMonitors();

Monitor lastMon = monitors[monitors.length - 1];
Rectangle bounds = lastMon.getBounds();

try {
IWorkbenchWindow window = Workbench.getInstance().openWorkbenchWindow("org.gamingclubnetwork.tournament.perspective.display", null);

Shell shell = window.getShell();
shell.setLocation(bounds.x, bounds.y);
shell.setFullScreen(monitors.length > 1);
catch (WorkbenchException e) {
// TODO Auto-generated catch block

First of all we look for all available monitors and grab the last one (I assumed the secondary display will be used for projectors or large monitors).
With that done, the trick is to open a new workbench window specifying a new perspective that contains just my GEF view. I then grab the shell of this workbench, remove the menu bar, set it's location to the top corner of the monitor to show it on and then set to full screen if not on the primary display.

Friday, 24 October 2008

Geoff on GEF pt. III

I tracked down the reason for my figures not appearing to the layout used in my root figure. I was using the XYLayout from the example, changing it to the ToolbarLayout immediately produced the desired results. e.g.

protected IFigure createFigure() {
Figure f = new Figure();
f.setLayoutManager(new ToolbarLayout());
return f;

I can now plough on and create edit parts and figures for the remaining components of my model.

One of the problems I encountered when using the ttolbar layout, is that shapes I have defined are not appearing as expected, is the short term I have replaced them with Labels containing just icons, but I think I will have to revisit this in the future.

Thursday, 23 October 2008

Geoff on GEF pt. II

So, carrying straight on from last night, I fixed the null pointer and now have an empty view displaying. The trouble is, as soon as I plugged in the listeners and updated the children of the EditPart when the model changed, I still get an empty view.

After some investigation I discovered that the following code can be used in a ViewPart to display a GEF diagram.

public void createPartControl(Composite parent) {
DefaultEditDomain defaultEditDomain = new DefaultEditDomain(null);

sgv = new ScrollingGraphicalViewer();

ScalableRootEditPart sffrep = new ScalableRootEditPart();
sgv.setEditPartFactory(new TournamentEditPartFactory());



private void initView() {

However, my diagram is still not displaying as expected...

Wednesday, 22 October 2008

Geoff on GEF pt. I

It's been about 4 years since I last worked with the Graphical Editing Framework, or GEF, in eclipse. I have recently been working on a new application using eclipse RCP to manage tournaments (specifically wargaming events).
Anyway, I have a basic application up and running now and intend to add an additional feature to allow for real-time information to be displayed on a seperate screen (or projector). For this feature I've decided to use GEF once more.
As I said, it has been about 4 years since I last used GEF and I recall that it was a little tricky to get started with. This time around I have decided to document my experience as I develop this new functionality.

To get things started, I paid a visit to the GEF homepage and jumped straight into the tutorial referenced there. The tutorial starts by stating that an updated version was posted in March 2007, not a good sign if the homepage does not point to the more up-to-date documentation.
Skipping quickly over the first section, that explains the MVC architechture, I wrote a couple of EditParts as described, then decided to create a view to display them. Now, the tutorial only deals with creating an editor, not a view. So after some googling I found this post on creating a view for GEF.

One of the methods called is setEditPartFactory(), I know from experience that the Edit Part Factory is a core piece of functionality that creates controllers (EditParts) from your model. I was stunned to find that the Edit PartFactory was not described in the tutorial. I threw one together from memory (see below) to confirm that I could get a view to display.

On launching the app, the view displayed, but there was a null pointer when getting the children of my root object, not really a surprise as I had yet to populate it. Anyway, that was enough for one night. I shall continue to work on it tomorrow.

The content of my EditPartFactory (simply implements EditPartFactory):

public EditPart createEditPart(EditPart context, Object model) {
EditPart part = null;
if(model instanceof TournamentData)
part = new FloorplanEditPart();
else if(model instanceof Game)
part = new GameEditPart();

if(part != null)
return part;

Sunday, 9 March 2008

Progress at Last!

I have finally made some progress in the editing of video from my camcorder (a JVC Everio)!

It seems that support for MPEG-2 in After Effects is a "known issue" as the official Adobe support recommended I use a different source.

After serveral attempts at conversion with serveral different tools to several different formats, I have now found one that seems to work.

the wonderful ffmpeg is a command line tool that can convert from pretty much any video format to another.
For my camcorder and after effects, I have found that conversion to WMV2 seems to work best.
Anyone trying to reproduce this should try the following:
ffmpeg -i {input file} -vcodec wmv2 -vb 8900000 /
-acodec wmav2 -ab 384000 {output file}
This should keep the video at the same quality (or close enough) as the original.

Saturday, 16 February 2008

Adobe MPEG-2 Support


After struggling last time to import MPEG-2 files in Premier Pro, this week I have been having issues with poor support for the encoding in After Effects. There is a problem where the rendering suffers from red artifacts, normally filling the entire frame.

This is not a problem with the source as I can play the file in other software without issue, but the red flicker is being introduce in After Effects. After browsing the web for this issue, the concensus seems to be to convert your video files from MPEG-2 into something else before editing them, however, this is a time consuming process and adds the possibility of introducing more errors.

To add insult to injury, whenever I try to report an issue on the Adobe support site, it seems to be down for maintainance (do they do this every Saturday?).

Saturday, 2 February 2008

Adobe CS3 Production Premium

Okay, so one of my interests is film making (not that I've made any yet) and to that end I have just purchased a copy of Adobe CS3 Production Premium (actually I bought it over a week ago, but have been so busy I had done nothing but install it before today). Now I'm no expert, in fact most of this is completely new to me, so here is a beginner experience of video editing in CS3.

I had some video files lying around from my holiday last year, so I thought I'd have a go at editing one of those. It was a video of the dolphins at sea world (aww, cute).

One feature that caught my attention when I was reading about the package was the AutoComposer which you can use to create scores for your video. So, first thing I did was open up Bridge, as this is what pulls every thing together, and clicked on the olive coloured Sb box.

This did not, as I had hoped, open Soundbooth, but a page with information about SoundBooth; including, as luck would have it, a link to a tutorial on using AutoComposer. I clicked the link and while the tutorial opened, I opened up Soundbooth.

The tutorial started and I started along with it.
Choose a score it said. I did.
Click on the score and you will hear a preview it said. I didn't, hear a preview that is. I paused the tutorial and started poking around. I discovered a preview panel under the window menu, I heard the previews. I resumed the tutorial.
There is some explanation on various items on the composer panel.
Select the video file as the reference link it says. I pause it again. I have not yet got my video clip in the application, so I load it up and select it as the reference clip. I continue the tutorial.
It explains about intros and outros and how the score works with keyframes.
It explains how to lower the volume of the score while a person is talking. I lower the volume of my score only to find that no-one is talking when they should be. In fact, my video has no sound at all!!
I paused the tutorial and went on a hunt for an explanation.
After trawling through help and googling, I found a forum post that said the sound in MPEG files is not supported as it is mixed in with the video, or something like that.
Most of my video files are MPEG. In fact my new camcorder, a JVC Everio, records everything in MPEG.

I am really annoyed that CS3 does not support audio in MPEG files, I have used free video editing tools that do this, surely one I have paid so much for can do it!
Come on Adobe get your act together!!

I tried the video file in Premier Pro (the video editing package), no luck there either. So I googled again and found a freeware app to rip sound from MPEG, this worked... sort of.
The audio file was shorter the the original MPEG.
In Premier Pro I could change the duration, by I was not sure it would sync correctly. I decided that would do for now, I'd try out some other features.

I decided to use After Effects to try out stabilizing my video footage (hand held camcorders get a bit wobbly) and this was great! Load up the file, drop it into the composition, right click and select stabilize. Easy.
I turned on every option, selected 2 points then let it rip. I waited for it to process a few second, then stopped it, applied the results and hit playback. When it played back it was devoid of shakes, but even more impressive, it had sound! It seems After Effects can do what the other apps couldn't and can read sound from an MPEG file.

A plan began to form.

I saved my After Effects project and then tried exporting as a Premier Pro project.
I started up Premier Pro. I opened my new project. It didn't work.
The video data could not be found and the was still no audio.
Oh well, back to the drawing board.

At least I have about 3 seconds of video footage of dolphins that doesn't shake.

My Other Blog

I already have a blog dedicated to the work I am doing on Kingdom Gould, so this is my other blog, the one that contains all the other writings on what I'm interested in.