Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

AMP/UserGuide/Escape/Converting From Ascape

< AMP‎ | UserGuide‎ | Escape

Converting Existing Ascape models to Escape

There are only a few changes should have to make to existing Ascape models or to use existing Ascape documentation to develop Escape models.

Model

The core model is completely API compatible. No changes!

View

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 => org.eclipse.swt.graphics.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:

g.setColor(...
g.fillOval(..
becomes:
g.setBackgroundColor(
g.fillOval(..

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.

Configuration

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.

Current Limitations

  1. Escape is pretty robust, and the APIs are solid and well-tested but the runtime is not going to be as stable for a while as Ascape which has been around for a long time.
  2. Escape graphics performance is generally slower especially for charts. But on the other hand you can run multiple models at once and the headless models should perform just as well as console launched Ascape programs. In practice this shouldn't affect your normal model exploration work.
  3. We don't have the speed slider working yet. See [1]
  4. Charts only support time series, not histograms and pie. See [2]

Back to the top