ser's home page
about searching
about searching
Jan 21st
TASK:
Change a diagram editor generated by GMF to make its figures sensitive to changes of semantic elements’ attributes’ values. Changes of attributes’ values should be automatically detected and reflected in figures’ look.
SOLUTION:
You have to make a little change in *EditPart class. I’m going to change edit part for the semantic model element named Port, so I will edit my.package.diagram.edit.parts.PortEditPart class.
Add a new method to the PortFigure class, which is PortEditPart‘s inner class:
public void updateFace() { Port port = (Port) ((Node) PortEditPart.this.getModel()).getElement(); // set line width according to number of some children int lineWidth = 1; if (port.getLogicalUnits().size() > 1) { lineWidth = 2; } this.setLineWidth(lineWidth); // update tooltip String tooltipText; if (port.getDescription() != null && port.getDescription().length() > 0) { tooltipText = port.getDescription(); } else { tooltipText = port.getName(); } if (getToolTip() == null) { setToolTip(new Label(tooltipText)); } else if (getToolTip() instanceof Label) { ((Label) getToolTip()).setText(tooltipText); } }
The updateFace method makes actual changes to the figure’s look. This example implementation sets the line’s width according to the number of Port’s children (port.getLogicalUnits().size()) and sets the tool-tip text to the value of element’s attribute named description.
Then you have to hook up this method in two places: PortFigure‘s constructor to update the look when editor starts and the handleNotificationEvent method to react to live changes.
Change PortFigure‘s constructor to make it use new method.
/** * @generated NOT */ public PortFigure() { this.setFill(true); this.setFillXOR(false); this.setOutline(true); this.setOutlineXOR(false); this.setLineStyle(Graphics.LINE_SOLID); //this.setLineWidth(1); //this.setForegroundColor(PORTFIGURE_FORE); //this.setBackgroundColor(PORTFIGURE_BACK); updateFace(); createContents(); }
Override handleNotificationEvent(Notification notification) method in PortEditPart.
@Override protected void handleNotificationEvent(Notification notification) { if (notification.getNotifier() instanceof Port) { getPrimaryShape().updateFace(); } super.handleNotificationEvent(notification); }
Without this method you would need to restart editor to reflect element’s changes in figure parameters.
Tested on GMF version 2.0.
Jan 12th
I have stumbled on this again. There is so many places on the Net (for example Advanced Bash-Scripting Guide) where you can read that Bash does not support regular expression by itself and you have to use other tools (usually grep, sed and awk are mentioned) to match/replace with regex. Since regular expressions are part of POSIX.1-2001, why would Bash not provide such useful function to its users? Of course it provides. You can use conditional expression’s binary operator =~ to match strings with regex. As a result you get a return code 0, 1 or 2 (for matched, not matched and regex syntax error) and an array of matched substrings referenced by the BASH_REMATCH variable. Example:
$ [[ /etc/passwd =~ ^/(.+)/(.+) ]]; echo $? ${BASH_REMATCH[@]}
0 /etc/passwd etc passwd
So if you want to rename a file whose name is stored in a bash variable, you do not have to fork perl or sed for that.
Aug 22nd
Sometimes it is useful to have image size written in filename (I needed it when I was browsing my collection of wallpapers). I could not find any tool which would automate this process, so I have decided to write one. Probably it is job for bash or Python but I like Java most, so it is Java CLI tool. I have used ImageInfo class to get image parameters.
That’s what it does:
Use it like this:
# to preview changes:
$ java -jar /some-path/into-filename.jar file1 file2 ... # you can use full file paths
# to rename files:
$ java -jar /some-path/into-filename.jar -p file1 file2 ...
And here is the jar: into-filename (Public Domain License)
Jul 2nd
This solution is for those who use also GMF. In one of your plug-ins (or create a new empty plug-in for that) add following section to plugin.xml:
<extension point="org.eclipse.emf.ecore.extension_parser">
<parser type="MY_SEMANTIC_MODEL_FILE_EXTENSION"
class="org.eclipse.gmf.runtime.emf.core.resources.GMFResourceFactory">
</parser>
</extension>
It will make EMF use GMFResourceFactory for XMI [de]serialization. GMFResourceFactory enables usage of UUIDs. Don’t forget to replace MY_SEMANTIC_MODEL_FILE_EXTENSION with your own file extension.
Feb 7th
Currently I’m writing NetFlow analyser as a Rich Internet Application. After long consideration and evaluation of available open-source technologies I have concluded that GWT will be the best shot in this case (now I’m not so sure any more, but this is another story). To make building nice user interface easier I have decided to equip user side CLASSPATH with GWT-Ext library. GWT-Ext reuses ExtJS and ExtJS needs some underlying JavaScript framework. A lot of people use YUI as base for ExtJS, so automatically I have started to use it too. And this is where the first problems arose.
More >
Aug 2nd
Because of the final of the Tall Ships’ Races 2007 in Szczecin one of the gates to Drobnica Port Szczecin was widely opened and I was able to legally get inside. Drobnica Port is connected with Gryfia Shipyard, and then you can get to Szczecin part of Szczecin-Świnoujście Port from which you can go without much trouble to Ostrów Grabowski. Here is google map (with photos) of the trip and here is the gallery itself.
Jul 12th
The first gallery contains few 3D images, I have created quite long time ago using Blender 3D, a great 3D modeling and rendering tool. Some images were finally rendered by yafray renderer. Example image included. Click on thumbnail to pop-up bigger one. All images can be seen in my local gallery or on flickr.
Apr 13th
I have decided to reactivate XEland project. XELand is a small program, which generates night landscapes as stereo pairs for cross-eye viewing. Original version was written in C++/Gnome and had continually problems with compilation (due to lots of dependencies). Java version is of course free of such problems. Currently it uses two map generation methods (plus some variations). Generated height maps are seamless and can be saved as PNG images. The program requires only JDK 1.5 or above, and is very easy to use. To take full advantage of XEland you should learn cross-eye viewing. Support for anaglyph is expected soon.