2 * RocksimFinishCode.java
4 package net.sf.openrocket.file.rocksim;
6 import net.sf.openrocket.rocketcomponent.ExternalComponent;
9 * Models the finish of a component.
11 enum RocksimFinishCode {
12 POLISHED(0, ExternalComponent.Finish.POLISHED),
13 GLOSS(1, ExternalComponent.Finish.SMOOTH),
14 MATT(2, ExternalComponent.Finish.NORMAL),
15 UNFINISHED(3, ExternalComponent.Finish.UNFINISHED);
17 /** The Rocksim code (from XML). */
18 private final int ordinal;
20 /** The corresponding OpenRocket finish. */
21 private final ExternalComponent.Finish finish;
26 * @param idx the Rocksim enum value
27 * @param theFinish the OpenRocket finish
29 private RocksimFinishCode(int idx, ExternalComponent.Finish theFinish) {
35 * Get the OpenRocket finish.
37 * @return a Finish instance
39 public ExternalComponent.Finish asOpenRocket() {
44 * Lookup an instance of this enum from a Rocksim value.
46 * @param rocksimFinishCode the Rocksim value
48 * @return an instance of this enum; Defaults to MATT
50 public static RocksimFinishCode fromCode(int rocksimFinishCode) {
51 RocksimFinishCode[] values = values();
52 for (RocksimFinishCode value : values) {
53 if (value.ordinal == rocksimFinishCode) {
57 return MATT; //Default