Example #1
0
        /// <summary>
        /// Get molfile form of molecule doing a conversion from another format as necessary
        /// </summary>
        /// <returns></returns>

        public string GetMolfileString()
        {
            string molfile = "", helm = "";

            if (Lex.IsDefined(MolfileString))
            {
                return(MolfileString);
            }

            else if (Lex.IsDefined(ChimeString))
            {
                molfile = ChimeStringToMolfileString(ChimeString);
            }

            else if (Lex.IsDefined(SmilesString))
            {
                molfile = CdkMol.SmilesStringToMolfileString(SmilesString);
            }

            else if (Lex.IsDefined(InchiString))
            {
                molfile = CdkMol.InChIStringToMolfileString(PrimaryValue.ToString());
            }

            else if (Lex.IsDefined(HelmString))
            {
                molfile = HelmConverter.HelmToMolfile(this, HelmString);
            }

            else if (Lex.IsDefined(SequenceString))
            {
                helm       = HelmConverter.SequenceToHelm(SequenceString);
                HelmString = helm;
                if (Lex.IsDefined(helm))
                {
                    molfile = HelmConverter.HelmToMolfile(this, HelmString);
                }
            }

            else if (Lex.IsDefined(FastaString))
            {
                helm       = HelmConverter.FastaToHelm(FastaString);
                HelmString = helm;
                if (Lex.IsDefined(helm))
                {
                    molfile = HelmConverter.HelmToMolfile(this, HelmString);
                }
            }

            else
            {
                molfile = "";
            }

            MolfileString = molfile;             // save for later possible reuse
            return(MolfileString);
        }
Example #2
0
        public override void Draw(
            float offsetX,
            float offsetY,
            Renderer2D renderer)
        {
            DrawGauge(offsetX, offsetY, renderer, SecondaryValue, SecondaryGaugeColor);
            DrawGauge(offsetX, offsetY, renderer, PrimaryValue, PrimaryGaugeColor);

            float fontSize = Height - (2f * BorderWidth);

            fontSize      *= 0.8f;
            renderer.Color = TextColor;
            string format = asInteger ? "F0" : "F1";

            if (string.IsNullOrEmpty(Label)) // ラベルがなければ両方の数字を左右に分けて出す
            {
                // primaryは左寄せ
                renderer.AddText(
                    PrimaryValue.ToString(format),
                    offsetX + LocalLeftX + (BorderWidth * 2f),
                    offsetY + LocalTopY + (BorderWidth * 2f),
                    fontSize);

                // secondaryは右寄せ
                renderer.AddText(
                    SecondaryValue.ToString(format),
                    offsetX + LocalLeftX + Width - (BorderWidth * 2f),
                    offsetY + LocalTopY + (BorderWidth * 2f),
                    fontSize,
                    AlignX.Right);
            }
            else // ラベルがあれば左にラベル、右にプライマリの数値
            {
                renderer.AddText(
                    Label,
                    offsetX + LocalLeftX + (BorderWidth * 2f),
                    offsetY + LocalTopY + (BorderWidth * 2f),
                    fontSize);

                // 数字は右寄せ
                renderer.AddText(
                    PrimaryValue.ToString(format),
                    offsetX + LocalLeftX + Width - (BorderWidth * 2f),
                    offsetY + LocalTopY + (BorderWidth * 2f),
                    fontSize,
                    AlignX.Right);
            }
        }