Here is some sample code on calculating distance per pulse and setting up an encoder. You would just need to place them in the proper locations of your code.
The code should be self explanatory, but if you have any questions, reply back.
//DIO Port of Encoder
public static final int rightDriveEncoderChannelA = 3;
public static final int rightDriveEncoderChannelB = 4;
//Wheel Radius
public static final int driveWheelRadius=2;//wheel radius in inches
public static final int pulsePerRotation = 360; //encoder pulse per rotation
public static final double gearRatio = 1/1; //ratio between wheel and encoder
public static final double driveEncoderPulsePerRot= pulsePerRotation*gearRatio; //pulse per rotation * gear ratio
public static final double driveEncoderDistPerTick=(Math.PI*2*driveWheelRadius)/driveEncoderPulsePerRot;
public static final int driveEncoderMinRate=10;
public static final int driveEncoderMinPeriod=10;
public static final boolean rightDriveTrainEncoderReverse=false;
//declare sensors
Encoder rightEncoder;
//instantiate encoder
rightEncoder = new Encoder(rightDriveEncoderChannelA, rightDriveEncoderChannelB, rightDriveTrainEncoderReverse, CounterBase.EncodingType.k4X);
rightEncoder.setDistancePerPulse(driveEencoderDistPerTick);
rightEncoder.setMaxPeriod(driveEncoderMinPeriod);//min period before reported stopped
rightEncoder.setMinRate(driveEncoderMinRate);//min rate before reported stopped
rightEncoder.start();
Hope this helps,
Kev