Due to overwhelming demand (well, at least 1 person :-)), I've put up my initial code for exploring the Photoshop Elements database. For a small bit of background info, see my previous post.
I thought I'd give google code a try for hosting - as such, the project is located here.
Drop me a line in the comments if you're interested in participating.
Showing posts with label eclipse. Show all posts
Showing posts with label eclipse. Show all posts
Tuesday, January 29, 2008
Friday, January 04, 2008
Cheat Sheet Extensibility - Part 2
Oops.
I forgot to mention one of the little tricks required to make the cheat sheet actually usable - you need to be able to signal it's completion :-)
There are a few things required to make this happen:
I forgot to mention one of the little tricks required to make the cheat sheet actually usable - you need to be able to signal it's completion :-)
There are a few things required to make this happen:
- the task requires a UI control which allows the user to signal that the task is complete. I used a form hyperlink control, similar to the following:
ImageHyperlink link = toolkit.createImageHyperlink(
form.getBody(),
SWT.WRAP);
Image img = AbstractUIPlugin.imageDescriptorFromPlugin(
Activator.PLUGIN_ID, "/icons/complete_task.gif").createImage();
link.setImage(img);
link.addHyperlinkListener(this); a reference to the task being edited must be obtained. Fortunately, this is made available when the setInput method is called. In this method, use some code like this:
public void setInput(IEditableTask _task, IMemento memento) {
task = _task;
}attach a listener to the control
when the link is activated, your listener will be fired. When this happens, the task should be set to complete. This is then just a simple method call using the task instance which has already been saved:
task.complete();
Wednesday, January 02, 2008
Cheat Sheet Extensibility
I've been looking at the Eclipse Cheat Sheet capability recently - with a view to using it more as a workflow assistance tool, rather than a "follow these instructions" helper.
As such, the idea of crafting specific tasks that the user can interact with seems an appealing idea.
Here's a screen shot of a simple first attempt.

Note that I've used the Eclipse Forms controls to blend in with the "flat look" layout.
This was pretty easy to get going:
And that's it! Simple really.
Next, I'll take a look at how you can use task variables to communicate between your tasks.
As such, the idea of crafting specific tasks that the user can interact with seems an appealing idea.
Here's a screen shot of a simple first attempt.

Note that I've used the Eclipse Forms controls to blend in with the "flat look" layout.
This was pretty easy to get going:
- Define a task extension in your plug-in.
<taskEditor
class="mypdeproject.tasks.MyTaskExtension"
icon="icons/sample.gif"
id="MyPdeProject.taskEditor1">
</taskEditor> - Define the class referenced above. It needs to implement org.eclipse.ui.internal.provisional.cheatsheets.TaskEditor
- Implement the required methods. The main one of which is the createControl method - to create the UI controls used to edit the task.
public void createControl(Composite comp,
Obviously, you may want to define a few more fields in there than this.
FormToolkit toolkit) {
form = toolkit.createForm(comp);
form.setText("Hello, Eclipse Forms");
} - Define a complex task, and then reference our newly defined task extension.
<task id="t2" kind="MyPdeProject.taskEditor1"
name="Extended task"
skip="false">
<intro>
Introduction Extended
</intro>
<onCompletion>
This is the Conclusion
</onCompletion>
</task>
And that's it! Simple really.
Next, I'll take a look at how you can use task variables to communicate between your tasks.
Wednesday, December 05, 2007
Getting started with XProc using Eclipse
This post looks at how to get started with Norm Walsh's XProc implementation - using Eclipse.
XProc is an XML Pipeline Language, which is being defined by the folks at the XML Processing Model Working Group. Norm has an experimental implementation, hosted at https://xproc.dev.java.net/. The release notes are here.
Naturally enough, this is as a Netbeans project - but I thought I'd give it a try using Eclipse. It was pretty easy in the end:
Here's a screenshot of the project contents:

Note that some errors are shown (since not all required libraries are provided), and that all three of the saxon libs are required.
And for good measure, here's a screen shot of a successful run:
XProc is an XML Pipeline Language, which is being defined by the folks at the XML Processing Model Working Group. Norm has an experimental implementation, hosted at https://xproc.dev.java.net/. The release notes are here.
Naturally enough, this is as a Netbeans project - but I thought I'd give it a try using Eclipse. It was pretty easy in the end:
- Start your favourite Eclipse version - I used 3.3
- Add in a Subversion plugin (since dev.java.net uses subversion). I've been using Subclipse lately. See http://subclipse.tigris.org/ for more details.
- Point your SVN explorer to the repository https://xproc.dev.java.net/svn/xproc
- Check out as a new Java Project using the Wizard.
- Download (some of) the required frameworks ... I found that I could get by with Saxon 6.5 and Saxon 9 to get started. Add these .jars to the build path. Also note that you should add saxon9-s9api.jar as well as saxon9.jar.
- Adjust the build path - so that these two directories are used as the java source:
java/src
java
The second is required, since a number of configuration files are referenced using a path like /etc/configuration.xml and as such, they need to be findable on the classpath. Eclipse will make sure that you exclude java/src from this include. Your classpath should look something like this: - I used the xproc.Driver class to do a simple test. It was not long before I realized that things were not happy due to my running on a Windows box. I needed to change this line:
hash.put(port, "file://" + fn);
to this:
hash.put(port, "file://" + "/" + fn); - I then needed to use this sort of command line arguments:
-i source=c:\fred.xml java/samples/count.xpl
This just runs the count pipeline against a simple xml document.
Here's a screenshot of the project contents:

Note that some errors are shown (since not all required libraries are provided), and that all three of the saxon libs are required.
And for good measure, here's a screen shot of a successful run:

Tuesday, November 27, 2007
Declarative Eclipse Branding with SVG
Recently, I had need to add some Eclipse branding graphics to an RCP application.
Rather than take the "easy" route of using an image editor, I thought I'd explore the use of SVG to produce the required images in a declarative kind of way.
Using SVG for this purpose has a number of advantages ...
Fortunately, this can be overcome by converting the SVG images to a bitmap format by using a conversion program called a "rasterizer".
A good example of a rasterizer is Batik - an open-source toolkit for manipulating SVG images.
See http://xmlgraphics.apache.org/batik/tools/rasterizer.html for further details on the Batik rasterizer.
Round Trip example
Here's a simple example of some SVG source to get started.
This produces a result like this:

In order to produce this image for the web, I used the Batik rasterizer. For example, the command I used was this:
Once you have a PNG format image, it's a "simple" matter of converting that to a BMP format. The simplicity involved depends on your platform:
Well, that's produced a very simple image. But one of the advantages of SVG is that you can get very nice effects with a minimum of effort.
Step 1 - Background Gradient

Nice enough, but the default direction for a gradient is from left to right.
Step 2 - Background Gradient - in the correct direction
Here, we use another gradient - with a direction specifier - and embed the first.
This produces a result like this:

Step 3 - Background Gradient - with a horizon effect
This refinement adds a horizon - by splitting the image in two - at 200 px down, and using two gradients.
This produces a result like this:

Step 4 - With a Graphic
Naturally, if we are doing a nice, modern style image, we should use some modern styled clip-art to give the image a lift. Since we are using SVG, there is a whole world of choice at the Open Clip Art project. For my Hello World example, I've chosen a nice clean globe.
In order to use a graphic, download the source to separate file. It can then be included in two different ways:
This produces a result like this:

Step 5 - With a Reflection
No self-respecting modern image would be complete without the "reflection" technique! This is amazingly simple using SVG - just apply a transform effect on the use tag.
This produces a result like this:
Rather than take the "easy" route of using an image editor, I thought I'd explore the use of SVG to produce the required images in a declarative kind of way.
Using SVG for this purpose has a number of advantages ...
- they are cross platform
- the declarative, text file nature allows the content to be generated
- they can be created using open-source tools
Fortunately, this can be overcome by converting the SVG images to a bitmap format by using a conversion program called a "rasterizer".
A good example of a rasterizer is Batik - an open-source toolkit for manipulating SVG images.
See http://xmlgraphics.apache.org/batik/tools/rasterizer.html for further details on the Batik rasterizer.
Round Trip example
Here's a simple example of some SVG source to get started.
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
width="500"
height="330"
id="drawing">
<defs>
<g id="mytext">
<text
xml:space="preserve"
style="font-size:40px;font-weight:normal;text-align:start;line-height:100%;text-anchor:start;font-family:Bitstream Vera Sans"
x="200" y="125">Hello</text>
<text
xml:space="preserve"
style="font-size:40px;font-weight:normal;text-align:start;line-height:100%;text-anchor:start;font-family:Bitstream Vera Sans"
x="200" y="170">World ...</text>
</g>
</defs>
<rect style="fill:black" width="500" height="330" x="0" y="0" />
<use xlink:href="#mytext" style="fill:white" />
</svg>
This produces a result like this:

In order to produce this image for the web, I used the Batik rasterizer. For example, the command I used was this:
C:\>java -jar c:\jshare\batik-1.7\batik-rasterizer.jar drawing5.svg
About to transcode 1 SVG file(s)
Converting drawing5.svg to drawing5.png ... ... success
Once you have a PNG format image, it's a "simple" matter of converting that to a BMP format. The simplicity involved depends on your platform:
- if you're on Windows - you can use Microsoft Paint: open the PNG and then save as BMP
- if you're on Linux - you can use GIMP
Well, that's produced a very simple image. But one of the advantages of SVG is that you can get very nice effects with a minimum of effort.
Step 1 - Background Gradient
This produces a result like this:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
width="500"
height="330"
id="drawing">
<defs>
<g id="mytext">
<text
xml:space="preserve"
style="font-size:40px;font-weight:normal;text-align:start;line-height:100%;text-anchor:start;font-family:Bitstream Vera Sans"
x="200" y="125">Hello</text>
<text
xml:space="preserve"
style="font-size:40px;font-weight:normal;text-align:start;line-height:100%;text-anchor:start;font-family:Bitstream Vera Sans"
x="200" y="170">World ...</text>
</g>
<linearGradient id="top">
<stop offset="0%" style="stop-color: black;"/>
<stop offset="100%" style="stop-color: #484848;"/>
</linearGradient>
</defs>
<rect style="fill:url(#top)" width="500" height="330" x="0" y="0" />
<use xlink:href="#mytext" style="fill:white" />
</svg>

Nice enough, but the default direction for a gradient is from left to right.
Step 2 - Background Gradient - in the correct direction
Here, we use another gradient - with a direction specifier - and embed the first.
<linearGradient id="top">
<stop offset="0%" style="stop-color: black;"/>
<stop offset="100%" style="stop-color: #484848;"/>
</linearGradient>
<linearGradient id="topa"
xlink:href="#top"
x1="0%" y1="0%" x2="0%" y2="100%"/>
</defs>
<rect style="fill:url(#topa)" width="500" height="330" x="0" y="0" />
This produces a result like this:

Step 3 - Background Gradient - with a horizon effect
This refinement adds a horizon - by splitting the image in two - at 200 px down, and using two gradients.
<linearGradient id="top">
<stop offset="0%" style="stop-color: black;"/>
<stop offset="100%" style="stop-color: #484848;"/>
</linearGradient>
<linearGradient id="topa"
xlink:href="#top"
x1="0%" y1="0%" x2="0%" y2="100%"/>
<linearGradient id="bottom">
<stop offset="0%" style="stop-color: #707070;"/>
<stop offset="100%" style="stop-color: black;"/>
</linearGradient>
<linearGradient id="bottoma"
xlink:href="#bottom"
x1="0%" y1="0%" x2="0%" y2="100%"/>
</defs>
<rect style="fill:url(#topa)" width="500" height="200" x="0" y="0" />
<rect style="fill:url(#bottoma)" width="500" height="130" x="0" y="200" />
This produces a result like this:

Step 4 - With a Graphic
Naturally, if we are doing a nice, modern style image, we should use some modern styled clip-art to give the image a lift. Since we are using SVG, there is a whole world of choice at the Open Clip Art project. For my Hello World example, I've chosen a nice clean globe.
In order to use a graphic, download the source to separate file. It can then be included in two different ways:
- cut and paste the source code into your SVG file
- save it to a separate file, and reference it as below using the image tag.
<g id="globe">
<image xlink:href="globe.svg"
width="500" height="500" x="0" y="0"
transform="scale(0.25)"/>
</g>
</defs>
<rect style="fill:url(#topa)" width="500" height="200" x="0" y="0" />
<rect style="fill:url(#bottoma)" width="500" height="130" x="0" y="200" />
<use xlink:href="#mytext" style="fill:white" />
<use xlink:href="#globe" x="60" y="80" />
This produces a result like this:

Step 5 - With a Reflection
No self-respecting modern image would be complete without the "reflection" technique! This is amazingly simple using SVG - just apply a transform effect on the use tag.
<use xlink:href="#mytext" style="fill:white" />
<use xlink:href="#mytext" style="fill:white;opacity:0.25" transform="matrix(1 0 0 -1 0 400)"/>
<use xlink:href="#globe" x="60" y="80" />
<use xlink:href="#globe" style="opacity:0.25" x="60" y="80" transform="matrix(1 0 0 -1 0 400)"/>
This produces a result like this:

Friday, November 02, 2007
Photoshop Elements - Explorer
As a way of investigating the internals of the Adobe Photoshop Elements (PSE) meta tags, I thought I'd whip up a little Eclipse plug-in to do some experimentation.
The primary purpose was to provide a means of exporting my metadata. I do a little editing within PSE, but my largest investment is in the metadata attached to (almost) every photo.
I realize that you can (and should) backup your PSE catalog using the supplied tools, but this approach also provides a degree of independence should I ever wish to decamp to another product.
Plug-in Structure
The following diagram shows the plug-in dependency hierarchy. The diagram was produced using the brilliant Plug-in Dependency Visualization Tool from Ian Bull, also described here on his blog.

As can be seen from the hierarchy, I make use of a number of libraries, packaged as plug-ins.
Workbench Integration
Since I was aiming for the workbench, it made sense to provide some integration with the functionality you get for free! The two most obvious points are:
I have also encountered a great image viewer, courtesy of Wayne Beaton - see here for more details.
The great thing about making use of these functions is that they simply require an adapter to the required class to exploit the functionality.
Plug-in Functionality
It's pretty basic - a simple PSE Explorer View, which lists the contents of the catalog, and two menu options:

The plug-in functionality is initiated by the two command handlers (corresponding to the menu items) - that is, import and export.
The import function is facilitated by a simple DataProvider class. This provides the means of accessing the SQLite database and populating the model used by the viewer. The SQL used is similar to my earlier experiments.
The export function merely provides an XML transformer for the populated model. The results of the export looks like this:

Summary
This is just a starting point, but it has provided a easy way for exploring the PSE metadata. With a bit more polish, I'll see if I can release some of the code.
The primary purpose was to provide a means of exporting my metadata. I do a little editing within PSE, but my largest investment is in the metadata attached to (almost) every photo.
I realize that you can (and should) backup your PSE catalog using the supplied tools, but this approach also provides a degree of independence should I ever wish to decamp to another product.
Plug-in Structure
The following diagram shows the plug-in dependency hierarchy. The diagram was produced using the brilliant Plug-in Dependency Visualization Tool from Ian Bull, also described here on his blog.

As can be seen from the hierarchy, I make use of a number of libraries, packaged as plug-ins.
- XOM - to provide XML support. See here for more details on XOM.
- SQLite JDBC driver. See here for more details.
Workbench Integration
Since I was aiming for the workbench, it made sense to provide some integration with the functionality you get for free! The two most obvious points are:
- workbench properties
- an image viewer
I have also encountered a great image viewer, courtesy of Wayne Beaton - see here for more details.
The great thing about making use of these functions is that they simply require an adapter to the required class to exploit the functionality.
- the Properties View needs an adapter to an IPropertySource implementation
- the Image View plug-in requires an adapter to an ImageProvider implementation.
Plug-in Functionality
It's pretty basic - a simple PSE Explorer View, which lists the contents of the catalog, and two menu options:
- one to load an existing PSE catalog file (SQLite database)
- one to export the loaded PSE catalog as an XML Document.

The plug-in functionality is initiated by the two command handlers (corresponding to the menu items) - that is, import and export.
The import function is facilitated by a simple DataProvider class. This provides the means of accessing the SQLite database and populating the model used by the viewer. The SQL used is similar to my earlier experiments.
The export function merely provides an XML transformer for the populated model. The results of the export looks like this:

Summary
This is just a starting point, but it has provided a easy way for exploring the PSE metadata. With a bit more polish, I'll see if I can release some of the code.
Monday, October 15, 2007
Eclipse Commands
The new command framework for Eclipse looks quite good. But I found it a little hard to get started with it.
I've found some really useful info here though:
I stumbled across a simple solution - cheat! That is, use the Cheat Sheets wizard to give a helping hand. (Thanks to Chris Aniszczyk for his informative article on Cheat Sheets - reading it gave me the inspiration for this!)
I've found some really useful info here though:
- http://richclientplatform.blogspot.com/2007/07/new-menu-contribution-extension.html
- http://wiki.eclipse.org/Platform_Command_Framework#Commands
I stumbled across a simple solution - cheat! That is, use the Cheat Sheets wizard to give a helping hand. (Thanks to Chris Aniszczyk for his informative article on Cheat Sheets - reading it gave me the inspiration for this!)
- Create a new cheat sheet, by selecting File -> New ... and then selecting "Cheat Sheet".
- Just use any name, and specify a "Simple" cheat sheet.
- Once in the editor, select the "Item" - and on the right hand side of the form, you will be able to specify a command - using the gift of Browse.
- Click on the Browse button, and you'll be presented with a list of common workbench commands. For example:
- You can then select the Command, and even press "Execute" to try it.
Subscribe to:
Posts (Atom)