VASGen: Free ActionScript3 Code Generation from Violet UML
Latest Release 0.2.1 (March 16, 2008)
VioletUML is a simple, lightweight, and free (GPL) tool for generating UML diagrams.
The VASGen build described here adds the ability to export from a UML Class Diagram to a set of ActionScript3 code files.
For ActionScript3 language manipulation, I integrate
Metaas, a project which provides an API for generating and parsing AS3.
Metaas in turn relies on ANTLR, a tool for
building lexers, parsers, and automated processing in general, for grammars.
My purpose in building this small integration project was
- to make it easier to play with different object models, try them out
a little, and throw them away as necessary, without the labor of hand-generating code files
and
- support practical process research around applying static analysis tools
and very-lightweight-CASE tools to agile development with dynamic languages
This blog post talks more about the idea.
Go straight to code/download!
Release Notes 0.2.1 (March 16, 2008)
- Bug fix: wrong visibility on getters/setters for generated properties
Release Notes 0.2 (December 3, 2007)
- Integration with Alexandre de Pellegrin's version of Violet which, in addition to
significant visual enhancements, is designed to run as an Eclipse plug-in,
standalone executable JAR, or via JNLP (aka Web Start). His elegant GUI work
makes it look like this:

- Support for packages using the class diagram editor, including nesting
packages, relationships between classes in different packages, and a global
"default" package that you can specify without actually having to put all of
your model inside a giant package shape if you don't want to.
- To use packages, just add them to your diagram and give them names
- VASGen will handle the nesting -- so if you have package "utils" inside
"app", it will end up app.utils in the ActionScript code and appropriate
folders will be generated
- To specify a default global package, just add a package to your diagram
anywhere and start the name with a '+' (e.g., +foobar) -- all classes that
are not in any package in the diagram will be assigned to this one in the
generated code.
- Use of Frédéric Lavigne's
JDirectoryChooser widget for specifying output location, to match the visual
design of this Violet version.
- Various bug fixes
- Issue: Some Java builds on Windows have a
huge
known perf issue when opening a JFileChooser dialog. Unfortunately, the
JDirectoryChooser has this same problem (I'm guessing they either use the
same filesystem APIs behind the scenes, or generate it the same way.)
Anyway, until Sun fixes this, some Windows users will see a massive -- 10
second on my box -- delay when working with this folder picker.
Release Notes (Stuff That's Fixed) in 0.1.5 (July 5, 2007)
- Using # to indicate protected fields and methods now generates correct code
- Default visibility is now replaced by explicit internal visibility:
internal is the default per the ActionScript3 spec, and making it explicit
is both good coding style and cuts down on warnings if you build
with Adobe's AS3 compiler
- Package declarations on interfaces (which were missing a space) now
generate correctly.
Here's What You Can Do In Original (0.1) Release (Stuff That Works)
- Create classes and interfaces in the Class Diagram Editor
- Add fields or properties by specifying them in Violet
- Optionally prepend a visibility indicator (- for private, + for public,
nothing for default)
- Use # for "protected" visibility -- in this release it will generate as
default visibility, but that way in a future release the protected marker
will be emitted for your fields.
- Use @ as a visibility indicator to have VASGen create a private member
with public getters and setters generated for you
- Optionally specify a type after a colon (e.g. -myField:int) ... the default is
String
- Add methods by specifying them in Violet
- Optionally provide a visibility indicator (as above), arguments, and/or a return type: e.g., +myMethod(i:int):Number
- Add interface implementation and class inheritance via Violet and have those relationships generated in code
- Add association, composition, and aggregation relationships in Violet and have those generated in code
(mostly)
- Choose File -> Gen ActionScript to generate code
June 25, 2007 v 0.1 Release Notes / Known Issues / Stuff that Doesn't Work
(0.1)
- If you load an old Violet model, the relationships will not generate
properly, because the relationship semantics are a new piece of data created by
this version of Violet. So you'll need to recreate the relationship, or try
VASGen out with some new models. I plan to add a simple inference mechanism, so
that in future VASGen will guess the semantics of the relationship based on the
default graphical styling that Violet applies to the line/arrow.
- Aggregation generates a private Array member, but doesn't generate public
methods for manipulating the collection
- All classes and interfaces are currently generated in a package called "VASGenDefault"
- In interfaces, the package declaration is missing a space, which the user
will need to correct before the generated code will compile. This appears to be
due to metaas
- No support for protected visibility of members. Big bummer since I
use protected a lot. Not supported in the metaas 0.7 api
- Multiple "association" or "composition" relationships in the same direction
between the same 2 types will generate duplicate members that need to be fixed
later. E.g., suppose you draw A ->composed of -> B, and you add that
relationship again. You will get two members "private var _b:B;" in your
generated A class. You might do this on purpose, and then change the names of
the fields.
- Limited validation of legitimate member names. The ANTLR grammar throws an
error on some improper uses, but others slip though.
- Limited error messages: a try-catch block will catch most code-generation
errors, and pop up a dialog box, but the error message (a raw Exception.toString())
is always helpful. On the other hand, sometimes it is thanks to great code in
ANTLR and metaas.
Regarding the metaas issues, I spent a little time building the ANTLR grammar
and the metaas library, hoping I could find an easy fix. Due to either my own
inexperience or possibly not using the proper
versions of the sources, I did get a successful
build, but I was getting some odd parse errors when using it. I figured better to get
the basic VASGen functionality out the door than spend a lot of time learning
ANTLR right now. Update: David Holroyd, who writes metaas, fixed these issues straightaway.
And I figured out what I was doing wrong in the build (mixing versions of ANTLR bits = BAD. Duh.)
Download
This is an executable jar file, and includes the original Violet metadata for
Eclipse plug-in and JNLP functionality.
Older binaries:
vasgen-0.2
vasgen-0.1.5
vasgen-0.1
Source!
Violet UML is licensed under the GPL. This archive
includes the full source for this altered version of Violet UML.
Older source:
vasgen-0.2-src
vasgen-0.1.5-src
vasgen-0.1
Dependencies include metaas and
ANTLR.