Permalink
Browse files

Added type parameters where I could infer them.

This also eliminated some type casts.

Signed-off-by: Joachim Durchholz <toolforger@durchholz.org>
  • Loading branch information...
1 parent 5b27ad1 commit fce7ef1b1c54df877efb2cb9880fe58b42247356 @toolforger toolforger committed May 17, 2012
@@ -123,7 +123,7 @@ public boolean contains(TreeItem<T> child) {
} else if (treeNodes.contains(child)) {
return true;
} else {
- for (TreeItem item : treeNodes) {
+ for (TreeItem<T> item : treeNodes) {
boolean found = item.contains(child);
if (found) {
return true;
@@ -54,7 +54,7 @@ public static void main(final String[] args) {
// create Nifty and load default styles and controls
Nifty nifty = new Nifty(new LwjglRenderDevice(true), new OpenALSoundDevice(), LwjglInitHelper.getInputSystem(),
new AccurateTimeProvider());
- ControlsDemo<DisplayMode> demo = new ControlsDemo(new ResolutionControlLWJGL());
+ ControlsDemo<DisplayMode> demo = new ControlsDemo<DisplayMode>(new ResolutionControlLWJGL());
demo.prepareStart(nifty);
nifty.gotoScreen("demo");
@@ -125,11 +125,11 @@ public ByteBuffer imageToByteBuffer(BufferedImage image, boolean flipped, boolea
if (useAlpha) {
depth = 32;
raster = Raster.createInterleavedRaster(DataBuffer.TYPE_BYTE, texWidth, texHeight, 4, null);
- texImage = new BufferedImage(glAlphaColorModel, raster, false, new Hashtable());
+ texImage = new BufferedImage(glAlphaColorModel, raster, false, new Hashtable<Object, Object>());
} else {
depth = 24;
raster = Raster.createInterleavedRaster(DataBuffer.TYPE_BYTE, texWidth, texHeight, 3, null);
- texImage = new BufferedImage(glColorModel, raster, false, new Hashtable());
+ texImage = new BufferedImage(glColorModel, raster, false, new Hashtable<Object, Object>());
}
// copy the source image into the produced image
@@ -130,11 +130,11 @@ public ByteBuffer imageToByteBuffer(BufferedImage image, boolean flipped, boolea
if (useAlpha) {
depth = 32;
raster = Raster.createInterleavedRaster(DataBuffer.TYPE_BYTE, texWidth, texHeight, 4, null);
- texImage = new BufferedImage(glAlphaColorModel, raster, false, new Hashtable());
+ texImage = new BufferedImage(glAlphaColorModel, raster, false, new Hashtable<Object, Object>());
} else {
depth = 24;
raster = Raster.createInterleavedRaster(DataBuffer.TYPE_BYTE, texWidth, texHeight, 3, null);
- texImage = new BufferedImage(glColorModel, raster, false, new Hashtable());
+ texImage = new BufferedImage(glColorModel, raster, false, new Hashtable<Object, Object>());
}
// copy the source image into the produced image
@@ -48,7 +48,7 @@ public static void poll(int delta) {
/** True if the music is playing */
private boolean playing;
/** The list of listeners waiting for notification that the music ended */
- private ArrayList listeners = new ArrayList();
+ private ArrayList<MusicListener> listeners = new ArrayList<MusicListener>();
/** The volume of this music */
private float volume = 1.0f;
/** Start gain for fading in/out */
@@ -175,7 +175,7 @@ public void removeListener(MusicListener listener) {
private void fireMusicEnded() {
playing = false;
for (int i=0;i<listeners.size();i++) {
- ((MusicListener) listeners.get(i)).musicEnded(this);
+ listeners.get(i).musicEnded(this);
}
}
@@ -187,7 +187,7 @@ private void fireMusicEnded() {
private void fireMusicSwapped(Music newMusic) {
playing = false;
for (int i=0;i<listeners.size();i++) {
- ((MusicListener) listeners.get(i)).musicSwapped(this, newMusic);
+ listeners.get(i).musicSwapped(this, newMusic);
}
}
/**
@@ -40,7 +40,7 @@
/** The number of sound sources enabled - default 8 */
private int sourceCount;
/** The map of references to IDs of previously loaded sounds */
- private HashMap loaded = new HashMap();
+ private HashMap<String, Integer> loaded = new HashMap<String, Integer>();
/** The ID of the buffer containing the music currently being played */
private int currentMusic = -1;
/** The OpenGL AL sound sources in use */
@@ -291,7 +291,7 @@ public void init() {
log.info("Initialising sounds..");
inited = true;
- AccessController.doPrivileged(new PrivilegedAction() {
+ AccessController.doPrivileged(new PrivilegedAction<Object>() {
public Object run() {
try {
AL.create();
@@ -633,7 +633,7 @@ public Audio getAIF(String ref, InputStream in) throws IOException {
int buffer = -1;
if (loaded.get(ref) != null) {
- buffer = ((Integer) loaded.get(ref)).intValue();
+ buffer = loaded.get(ref).intValue();
} else {
try {
IntBuffer buf = BufferUtils.createIntBuffer(1);
@@ -706,7 +706,7 @@ public Audio getWAV(String ref, InputStream in) throws IOException {
int buffer = -1;
if (loaded.get(ref) != null) {
- buffer = ((Integer) loaded.get(ref)).intValue();
+ buffer = loaded.get(ref).intValue();
} else {
try {
IntBuffer buf = BufferUtils.createIntBuffer(1);
@@ -827,7 +827,7 @@ public Audio getOgg(String ref, InputStream in) throws IOException {
int buffer = -1;
if (loaded.get(ref) != null) {
- buffer = ((Integer) loaded.get(ref)).intValue();
+ buffer = loaded.get(ref).intValue();
} else {
try {
IntBuffer buf = BufferUtils.createIntBuffer(1);
@@ -13,23 +13,23 @@
private paulscode.sound.SoundSystem soundSystem;
private int counter = 0;
- public PaulsSoundsystemSoundDevice(final Class libraryClass, final SupportedCodec ... additionalCodecs) throws SoundSystemException {
+ public PaulsSoundsystemSoundDevice(final Class<?> libraryClass, final SupportedCodec ... additionalCodecs) throws SoundSystemException {
SoundSystemConfig.setSoundFilesPackage("");
SoundSystemConfig.addLibrary(libraryClass);
// we decided that ogg and wav are build in
SoundSystemConfig.setCodec("ogg", CodecJOrbis.class);
SoundSystemConfig.setCodec("wav", CodecWav.class);
- addAdditionalCodecs(libraryClass, additionalCodecs);
+ addAdditionalCodecs(additionalCodecs);
soundSystem = new paulscode.sound.SoundSystem();
}
@Override
public void setResourceLoader(final NiftyResourceLoader resourceLoader) {
}
- private void addAdditionalCodecs(final Class libraryClass, final SupportedCodec... codecs) throws SoundSystemException {
+ private void addAdditionalCodecs(final SupportedCodec... codecs) throws SoundSystemException {
if (codecs != null) {
for (SupportedCodec codec : codecs) {
SoundSystemConfig.setCodec(codec.getExtension(), codec.getCodecClass());
@@ -2,9 +2,9 @@
public class SupportedCodec {
private String extension;
- private Class codecClass;
+ private Class<?> codecClass;
- public SupportedCodec(final String extension, final Class codecClass) {
+ public SupportedCodec(final String extension, final Class<?> codecClass) {
this.extension = extension;
this.codecClass = codecClass;
}
@@ -13,7 +13,7 @@ public String getExtension() {
return extension;
}
- public Class getCodecClass() {
+ public Class<?> getCodecClass() {
return codecClass;
}
}

0 comments on commit fce7ef1

Please sign in to comment.