The box2d faq may help you out, one of the Q&As reads:
How do I convert pixels to meters?
Suppose you have a sprite for a character that is 100x100 pixels. You decide to use a scaling factor that is 0.01. This will make the character physics box 1m x 1m. So go make a physics box that is 1x1. Now suppose the character starts out at pixel coordinate (345,679). So position the physics box at (3.45,6.79). Now simulate the physics world. Suppose the character physics box moves to (2.31,4.98), so move your character sprite to pixel coordinates (231,498). Now the only tricky part is choosing a scaling factor. This really depends on your game. You should try to get your moving objects in the range 0.1 - 10 meters, with 1 meter being the sweet spot.
As a basic example (snippet):
/** 100 Pixels = 1m in Physics jbox2d */
private static final float SCALE = 0.01f; // 1/100 pixels
// Convert a Slick 2D screen x coordinate to a JBox2D x coordinate
public static float toPosX(float posX)
{
float x = posX * SCALE;
return x;
}
// Convert a Slick 2D screen y coordinate to a JBox2D y coordinate
public static float toPosY(float posY)
{
// As the physics world uses a 2d cartesian coordinate system
// and slick uses screen coordinates with top-left being (0,0)
// flip y
float y = -posY * SCALE;
return y;
}
/**
* Convert a JBox2D x coordinate to a Slick 2D screen x coordinate
*
* @param posX The JBox2D x coordinate
* @return The Slick 2D x coordinate
*/
public static float toScreenX(float posX)
{
// convert back to screen coordinate
float x = posX / SCALE;
return x;
}
public static float toScreenY(float posY)
{
// convert back to screen coordinate
float y = -posY / SCALE;
return y;
}
public void example()
{
BodyDef bd = new BodyDef();
bd.type = BodyType.STATIC;
Body body = world.createBody(bd);
PolygonShape shape = new PolygonShape();
// Note: v1X, v1Y, v2X, v2Y are in screen coordinates
// Point A of the edge
Vec2 v1 = new Vec2(toPosX(v1X), toPosY(v1Y));
// Point B of the edge
Vec2 v2 = new Vec2(toPosX(v2X), toPosY(v2Y));
shape.setAsEdge(v1, v2);
body.createFixture(shape, 1.0f);
}
Also, someone gives a great explanation here:
https://stackoverflow.com/questions/9997006/slick2d-and-jbox2d-how-to-draw
There are many different ways of doing the conversion, this is just one example. If you take a look at the jbox2d testbed code, it uses an OOBB structure to do the conversion. I'm still getting my head around it myself, I haven't touched jbox2d for a while now so if anyone has any input, I would be glad to hear/see it.