From: kruland2607 Date: Thu, 19 Apr 2012 16:03:48 +0000 (+0000) Subject: Change implementation of compatible types so they can be declared. Because of the... X-Git-Tag: upstream/12.09^2~349 X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=e2a9a04313460421faa97d393f7665b17d85aa1f;p=debian%2Fopenrocket Change implementation of compatible types so they can be declared. Because of the circular references, they cannot be declared in constructor arguments. git-svn-id: https://openrocket.svn.sourceforge.net/svnroot/openrocket/trunk@571 180e2498-e6e9-4542-8430-84ac67f01cd8 --- diff --git a/core/src/net/sf/openrocket/preset/ComponentPreset.java b/core/src/net/sf/openrocket/preset/ComponentPreset.java index 9ee7c009..d10a88b7 100644 --- a/core/src/net/sf/openrocket/preset/ComponentPreset.java +++ b/core/src/net/sf/openrocket/preset/ComponentPreset.java @@ -93,35 +93,29 @@ public class ComponentPreset implements Comparable { ComponentPreset.OUTER_DIAMETER, ComponentPreset.LENGTH} ); - - Type[] compatibleTypes; TypedKey[] displayedColumns; Type( TypedKey[] displayedColumns) { - compatibleTypes = new Type[1]; - compatibleTypes[0] = this; this.displayedColumns = displayedColumns; } - Type( Type[] t, TypedKey[] displayedColumns ) { - - compatibleTypes = new Type[t.length+1]; - compatibleTypes[0] = this; - for( int i=0; i getCompatibleTypes() { + return compatibleTypeMap.get(Type.this); } public TypedKey[] getDisplayedColumns() { return displayedColumns; } - + + private static Map> compatibleTypeMap = new HashMap>(); + + static { + compatibleTypeMap.put( BODY_TUBE, Arrays.asList( BODY_TUBE, TUBE_COUPLER) ); + compatibleTypeMap.put( TUBE_COUPLER, Arrays.asList( BODY_TUBE,TUBE_COUPLER) ); + compatibleTypeMap.put( CENTERING_RING, Arrays.asList( CENTERING_RING, ENGINE_BLOCK ) ); + compatibleTypeMap.put( NOSE_CONE, Arrays.asList( NOSE_CONE, TRANSITION)); + } + } public final static TypedKey MANUFACTURER = new TypedKey("Manufacturer", Manufacturer.class);