import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+import java.nio.charset.StandardCharsets;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Collection;
* Select something in Chimera
*
* @param command
- * the selection command to pass to Chimera
+ * the selection command to pass to Chimera
*/
public void select(String command)
{
/**
* Return the list of depiction presets available from within Chimera. Chimera
- * will return the list as a series of lines with the format: Preset type
- * number "description"
+ * will return the list as a series of lines with the format: Preset type number
+ * "description"
*
* @return list of presets
*/
}
/**
- * Launch Chimera, unless an instance linked to this object is already
- * running. Returns true if chimera is successfully launched, or already
- * running, else false.
+ * Launch Chimera, unless an instance linked to this object is already running.
+ * Returns true if chimera is successfully launched, or already running, else
+ * false.
*
* @param chimeraPaths
* @return
* Determine the color that Chimera is using for this model.
*
* @param model
- * the ChimeraModel we want to get the Color for
+ * the ChimeraModel we want to get the Color for
* @return the default model Color for this model in Chimera
*/
public Color getModelColor(ChimeraModel model)
/**
*
* Get information about the residues associated with a model. This uses the
- * Chimera listr command. We don't return the resulting residues, but we add
- * the residues to the model.
+ * Chimera listr command. We don't return the resulting residues, but we add the
+ * residues to the model.
*
* @param model
- * the ChimeraModel to get residue information for
+ * the ChimeraModel to get residue information for
*
*/
public void addResidues(ChimeraModel model)
* Send a command to Chimera.
*
* @param command
- * Command string to be send.
+ * Command string to be send.
* @param reply
- * Flag indicating whether the method should return the reply from
- * Chimera or not.
+ * Flag indicating whether the method should return the reply
+ * from Chimera or not.
* @return List of Strings corresponding to the lines in the Chimera reply or
* <code>null</code>.
*/
*/
int waited = 0;
int pause = 25;
- while (busy && waited < 1001)
+ while (busy && waited < 1001)
{
try
{
String method = getHttpRequestMethod();
if ("GET".equals(method))
{
- command = command.replace(" ", "+").replace("#", "%23")
- .replace("|", "%7C").replace(";", "%3B");
+ try
+ {
+ command = URLEncoder.encode(command,
+ StandardCharsets.UTF_8.toString());
+ } catch (UnsupportedEncodingException e)
+ {
+ command = command.replace(" ", "+").replace("#", "%23")
+ .replace("|", "%7C").replace(";", "%3B")
+ .replace(":", "%3A");
+ }
}
commands.add(new BasicNameValuePair("command", command));