X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fstructure%2FStructureCommandsBase.java;fp=src%2Fjalview%2Fstructure%2FStructureCommandsBase.java;h=8716691d76f861effe1260796bbf4522a980fd90;hb=304e64fb34b32659be1bbfd39fb4e15b2f79586e;hp=0000000000000000000000000000000000000000;hpb=cfb79b69d9fa44595560659bd95d1d1cd27677ad;p=jalview.git
diff --git a/src/jalview/structure/StructureCommandsBase.java b/src/jalview/structure/StructureCommandsBase.java
new file mode 100644
index 0000000..8716691
--- /dev/null
+++ b/src/jalview/structure/StructureCommandsBase.java
@@ -0,0 +1,257 @@
+package jalview.structure;
+
+import java.awt.Color;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+/**
+ * A base class holding methods useful to all classes that implement commands
+ * for structure viewers
+ *
+ * @author gmcarstairs
+ *
+ */
+public abstract class StructureCommandsBase implements StructureCommandsI
+{
+ public static final String NAMESPACE_PREFIX = "jv_";
+
+ private static final String CMD_SEPARATOR = ";";
+
+ /**
+ * Returns something that separates concatenated commands
+ *
+ * @return
+ */
+ protected String getCommandSeparator()
+ {
+ return CMD_SEPARATOR;
+ }
+
+ /**
+ * Returns the lowest model number used by the structure viewer
+ *
+ * @return
+ */
+ @Override
+ public int getModelStartNo()
+ {
+ return 0;
+ }
+
+ /**
+ * Helper method to add one contiguous range to the AtomSpec model for the given
+ * value (creating the model if necessary). As used by Jalview, {@code value} is
+ *
+ *
a colour, when building a 'colour structure by sequence' command
+ *
a feature value, when building a 'set Chimera attributes from features'
+ * command
+ *
+ *
+ * @param map
+ * @param value
+ * @param model
+ * @param startPos
+ * @param endPos
+ * @param chain
+ */
+ public static final void addAtomSpecRange(Map