blob: 865c440ba159ac212ba310c70e346515b1c78c1d [file] [log] [blame]
==Converting Existing Ascape Models==
There are only a few changes should have to make to existing Ascape models or to use existing Ascape documentation to develop Escape models.
The core model is completely API compatible. No changes!
Because Escape uses SWT and Ascape uses Swing, there are a few unavoidable incompatibilities. Most of these we avoid by using higher level APIs but here are the key changes that you're likely to have to make:
====Convert the low-level imports from AWT and Swing to SWT====
The simplest way to accomplish this is to remove all of the imports and then organize imports. For example:
java.awt.Color =>
java.awt.Graphics => org.eclipse.draw2d.Graphics
Then just do a global find for all of the imports and replace them with nothing. This is a great place for a regexp. Try:
find: import java\.awt\.(.*);
replace: [nothing]
You don't have to replace these with the SWT equivalents, just click on the project, right-click and choose "Source:Organize Imports.."
By the way, a great way to avoid having to select the right entries in optimize imports and to alert you when you have missed anything is to prevent the awt and swing classes from being used at all. Right-click on project, choose "Build Path:Configure Build Path", go to Libraries tab, open JRE System Library, choose "Access Rules", edit, and then add entries for java/awt/** and javax/swing/**. The code will regenerate and you'll have error markers for all of the stuff that won't work with Escape and Eclipse.
====Convert color features====
You can't use AWT colors either so you'll need to replace any colors. AMP provides a convenience classes for Colors called ColorFeature and ColorFeatureConcrete. You can use these or any of the other ways to define SWT colors. For example:
Color.lightGray => ColorFeature.LIGHT_GRAY
new Color(Math.min(1.0f, (float) (redEnergy + orangeEnergy)), (float) orangeEnergy * .8f, (float) blueEnergy) =>
ColorFeatureConcrete.create(Math.min(1.0f, (float) (redEnergy + orangeEnergy)), (float) orangeEnergy * .8f, (float) blueEnergy)
====Change agent color getters====
If you've defined colors through overriding Agents as in most models, you'll need to change the method signature. You could just do a global replace for this one.
public Color getColor( => public Object getPlatformColor(
====Get rid of image features====
Escape doesn't support them. In practice they haven't been used a lot. At some point perhaps we'll have nice sprite support instead. :)
public Image getImage() {**} => ""
====Modify usages of DrawFeatures====
If you've created any of your own draw features, you'll need to change them slightly to accommodate the differences between the AWT and SWT / Draw2D APIs. This should be pretty straightforwrd. For example:
That's about it, though it's probable that we've missed something. Please post a message on the amp newsgroup if you run into any other conversion issues.
Instead of using Ant, Escape has really nice support for parameterizing and testing models. See [[Experimenting and Testing]] (todo). If you do want to work with ant you will need to install the plugins from the Sourceforge download site. (These have dependencies that I didn't want to bother with going through the Eclipse IP process to get in. If for some reason you think these should be part of core Escape let Miles know and I'll take care of it.) Ant has not been tested for Escape so it's not even clear it will work.