X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fext%2Frbvi%2Fchimera%2FJalviewChimeraBinding.java;h=d0fa5ef8619c91d32332a3b57e988d7b202f2cef;hb=e739c2824d4d6a93c3e0f255780259c7daf2dc21;hp=786fc6cd6b11f74770124e3613a5b45919fa8566;hpb=4b53c6f969986c258e6cfbe20781c497caf33618;p=jalview.git diff --git a/src/jalview/ext/rbvi/chimera/JalviewChimeraBinding.java b/src/jalview/ext/rbvi/chimera/JalviewChimeraBinding.java index 786fc6c..d0fa5ef 100644 --- a/src/jalview/ext/rbvi/chimera/JalviewChimeraBinding.java +++ b/src/jalview/ext/rbvi/chimera/JalviewChimeraBinding.java @@ -41,6 +41,7 @@ import jalview.structure.AtomSpec; import jalview.structure.StructureMappingcommandSet; import jalview.structure.StructureSelectionManager; import jalview.structures.models.AAStructureBindingModel; +import jalview.util.ColorUtils; import jalview.util.MessageManager; import java.awt.Color; @@ -137,8 +138,7 @@ public abstract class JalviewChimeraBinding extends AAStructureBindingModel try { List modelsToMap = new ArrayList<>(); - List oldList = viewer.isChimeraX() ? new ArrayList<>() - : viewer.getModelList(); + List oldList = viewer.getModelList(); boolean alreadyOpen = false; /* @@ -1025,8 +1025,8 @@ public abstract class JalviewChimeraBinding extends AAStructureBindingModel /* * concatenate colour commands, one per residue symbol - * Chimera format: color 0.000000,0.372549,0.627451 ::VAL - * ChimeraX format: color :VAL rgb(73,73,182) + * Chimera format: color colorCode ::VAL + * ChimeraX format: color :VAL colourCode */ boolean chimeraX = viewer.isChimeraX(); for (String resName : residueSet) @@ -1036,7 +1036,7 @@ public abstract class JalviewChimeraBinding extends AAStructureBindingModel : resName.charAt(0); Color col = cs.findColour(res, 0, null, null, 0f); command.append("color "); - String colorSpec = getRgbDescriptor(col, chimeraX); + String colorSpec = ColorUtils.toTkCode(col); if (chimeraX) { command.append(":").append(resName).append(" ").append(colorSpec); @@ -1100,40 +1100,12 @@ public abstract class JalviewChimeraBinding extends AAStructureBindingModel public void setBackgroundColour(Color col) { viewerCommandHistory(false); - String command = "set bgColor " - + getRgbDescriptor(col, viewer.isChimeraX()); + String command = "set bgColor " + ColorUtils.toTkCode(col); viewer.sendChimeraCommand(command, false); viewerCommandHistory(true); } /** - * Answers the Chimera/X format for RGB values of the given colour. - * - *
-   * Chimera: r,g,b with values scaled [0=1]
-   * ChimeraX: rgb(r,g,b) with values scaled 0-255
-   * 
- * - * @param col - * @param chimeraX - * @return - */ - private static String getRgbDescriptor(Color col, boolean chimeraX) - { - if (chimeraX) - { - return String.format("rgb(%d,%d,%d)", col.getRed(), col.getGreen(), - col.getBlue()); - } - else - { - double scale = 255D; - return String.format("%f,%f,%f", col.getRed() / scale, - col.getGreen() / scale, col.getBlue() / scale); - } - } - - /** * Ask Chimera to save its session to the given file. Returns true if * successful, else false. *