public void CreateRings() { int[] rings = new[] { 0 }; IRingSet newRingSet = new RingSet(rings); Assert.That(newRingSet.Rings, Is.EqualTo(rings)); Assert.That(newRingSet.RingCount, Is.EqualTo(rings.Length)); }
public void CreateShifter() { int[] rings = { 32, 22 }; RingSet newRingSet = new RingSet(rings); Shifter newShifter = new Shifter(newRingSet); Assert.That(newShifter.Rings, Is.EqualTo(newRingSet)); Assert.That(newShifter.GetRingCount(), Is.EqualTo(newRingSet.RingCount)); Assert.That(newShifter.CurPos, Is.EqualTo(0)); }
public void SetRings() { int[] rings = new[] { 0 }; IRingSet newRingSet = new RingSet(rings); int[] newRing = new[] { 32, 22 }; newRingSet.Rings = newRing; Assert.That(newRingSet.Rings, Is.EqualTo(newRing)); Assert.That(newRingSet.RingCount, Is.EqualTo(newRing.Length)); }
// ================================================= DefaultView private void DefaultView () { ClientSize = new Size (782, 683); RingSet rs = new RingSet (this, Auxi_Geometry .Middle (ClientRectangle), 40, 90, new double [] { 1, 2, 4, 8, 16 }); rs .Rings [0] .SectorTexts = Auxi_Common .strDays; int newInner = rs .OuterMostRadius + 50; rs .AddRing (newInner, newInner + 50, Math .PI / 10, new double [] { 3, 3, 3 }); double [] fVal = new double [] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; RingArea ring = new RingArea (this, new Point (0, 0), 240, 290, fVal); ring .Colors = Auxi_Colours .SmoothColorsList (fVal .Length, Color .Yellow, Color .Blue); ring .SectorTexts = Auxi_Common .strMonths; rs .AddRing (ring); ringsets .Add (rs); }
public void SetCurPos() { int[] rings = { 32, 22 }; RingSet newRingSet = new RingSet(rings); Shifter newShifter = new Shifter(newRingSet); Assert.That(newShifter.Rings, Is.EqualTo(newRingSet)); Assert.That(newShifter.GetRingCount(), Is.EqualTo(newRingSet.RingCount)); Assert.That(newShifter.CurPos, Is.EqualTo(0)); int[] newRings = { 11, 22, 33 }; newRingSet.SetRings(newRings); newShifter.SettingGears(newRingSet); Assert.That(newShifter.Rings, Is.EqualTo(newRingSet)); Assert.That(newShifter.GetRingCount(), Is.EqualTo(newRingSet.RingCount)); Assert.That(newShifter.CurPos, Is.EqualTo(0)); }
// ================================================= SetRing private void SetRing () { fVal = Auxi_Common .RandomArray (1000, nValues); ring = new RingSet (this, ptCenter, nInRad, nOutRad, fVal); RingArea ra = ring .Rings [0]; ra .StartingAngle = Math .PI; ra .CommentsVisibility = false; ra .Colors = Auxi_Colours .SmoothColorsList (fVal .Length, clrStart, clrEnd); TextsSource txtsource = (TextsSource) comboTexts .SelectedIndex; switch (txtsource) { case TextsSource .Alphabet: ra .SectorTexts = Auxi_Common .strAlphabet; break; case TextsSource .Days: ra .SectorTexts = Auxi_Common .strDays; break; case TextsSource .ElvishSong: ra .SectorTexts = Auxi_Common .strElvishSong; break; case TextsSource .Months: ra .SectorTexts = Auxi_Common .strMonths; break; case TextsSource .Names: ra .SectorTexts = Auxi_Common .strNames; break; case TextsSource .Undefined: // all texts were set to "Undefined" by default break; } listValues .Items .Clear (); foreach (double val in fVal) { listValues .Items .Add (Convert .ToInt32 (val) .ToString ()); } }
/// <summary> /// Indicates that ring properties should use the Essential Rings (default). /// The set is unique but only includes a subset of the SSSR. /// </summary> /// <seealso cref="UseSmallestSetOfSmallestRings"/> /// <seealso cref="UseEssentialRings"/> public void UseEssentialRings() { this.ringSet = RingSet.EssentialRings; }
/// <summary> /// Indicates that ring properties should use the Relevant Rings. The set is /// unique and includes all of the SSSR but may be exponential in size. /// </summary> /// <seealso cref="UseSmallestSetOfSmallestRings"/> /// <seealso cref="UseEssentialRings"/> public void UseRelevantRings() { this.ringSet = RingSet.RelevantRings; }
/// <summary> /// Indicates that ring properties should use the Smallest Set of Smallest /// Rings. The set is not unique and may lead to ambiguous matches. /// </summary> /// <seealso cref="UseEssentialRings"/> /// <seealso cref="UseRelevantRings"/> public void UseSmallestSetOfSmallestRings() { this.ringSet = RingSet.SmallestSetOfSmallestRings; }
// ------------------------------------------------- NewRingSet private void NewRingSet (Point pt) { Form_DefineNewRing form = new Form_DefineNewRing (2, 26); if (form .ShowDialog () == DialogResult .OK) { RingSet ringSrc = form .Ring; RingSet ring = new RingSet (this, pt, 40, 120, ringSrc .Rings [0] .Values); ring .AddComment (-90, -0.4, DateTime .Now .ToShortTimeString (), new Font ("Microsoft Sans Serif", 10, FontStyle .Bold | FontStyle .Italic), 0, Color .Blue); RingArea ra = ring .Rings [0]; ra .Colors = ringSrc .Rings [0] .Colors; for (int i = 0; i < ra .Comments .Count; i++) { ra .Comments [i] .Text = ringSrc .Rings [0] .Comments [i] .Text; } ringsets .Insert (0, ring); RenewMover (); Invalidate (); } }
/** * Post process a fragment. --> find neutral possible neutral losses read in * from the file * * @param original * the original * * @return the i atom container set * * @throws CDKException * the CDK exception * @throws CloneNotSupportedException * the clone not supported exception */ public List<IAtomContainer> PostProcess(IAtomContainer original, double neutralLossMass) { // Render.Draw(original, "Original Main"); var ret = new List<IAtomContainer>(); allRings = new RingSet(); if (allRingsOrig.getAtomContainerCount() > 0) { // get the rings which are not broken up yet var bondMap = new Dictionary<IBond, int>(); var count = 0; foreach (var bondOrig in original.bonds().ToWindowsEnumerable<IBond>()) { bondMap[bondOrig] = count; count++; } // check for rings which are not broken up! IRingSet validRings = new RingSet(); for (var i = 0; i < allRingsOrig.getAtomContainerCount(); i++) { var bondcount = 0; foreach (var bondRing in allRingsOrig.getAtomContainer(i).bonds().ToWindowsEnumerable<IBond>()) { if (bondMap.ContainsKey(bondRing)) { bondcount++; } } if (bondcount == allRingsOrig.getAtomContainer(i).getBondCount()) { validRings.addAtomContainer(allRingsOrig.getAtomContainer(i)); } } // rings which are not split up allRings = validRings; } IAtomContainer temp = new AtomContainer(); var doneAtoms = new List<IAtom>(); var doneBonds = new List<IBond>(); // now find out the important atoms of the neutral loss var atomToStart = neutralLoss[neutralLossMass].AtomToStart; foreach (var bond in original.bonds().ToWindowsEnumerable<IBond>()) { if (doneBonds.Contains(bond)) { continue; } else { doneBonds.Add(bond); } // check if this was checked b4 foreach (var atom in bond.atoms().ToWindowsEnumerable<IAtom>()) { if (doneAtoms.Contains(atom)) { continue; } else { doneAtoms.Add(atom); } // a possible hit if (atom.getSymbol().Equals(atomToStart) && !allRings.contains(atom)) { // Render.Draw(original, "BEFORE"); // check if it is a terminal bond...and not in between! var atomList = original.getConnectedAtomsList(atom); var atomCount = 0; foreach (var iAtom in atomList.ToWindowsEnumerable<IAtom>()) { // dont check if (iAtom.getSymbol().Equals("H")) { continue; } else { atomCount++; } } // not a terminal atom...so skip it! if (atomCount > 1) { continue; } temp = checkForCompleteNeutralLoss(original, atom, neutralLossMass); if (temp.getAtomCount() > 0) { if (ConnectivityChecker.isConnected(temp)) { ret.Add(temp); } else { var set = ConnectivityChecker .partitionIntoMolecules(temp); foreach (var molecule in set.molecules().ToWindowsEnumerable<IMolecule>()) { ret.Add(molecule); } } // create a atom container temp = new AtomContainer(); } } } } return ret; }
// ------------------------------------------------- DefaultView private void DefaultView () { ClientSize = new Size (811, 690); Font fntTitle = new Font ("Times New Roman", 12, FontStyle .Bold | FontStyle .Italic); Font fntSectors = new Font ("Times New Roman", 12); double angleTitle = 0; Color clrTitle = Color .Blue; RingSet rs = new RingSet (this, new Point (ClientRectangle .Width / 4, ClientRectangle .Height / 4), 30, 80, new double [] { 1, 2, 4, 8, 16 }); rs .Rings [0] .SectorTexts = Auxi_Common .strDays; int newInner = rs .OuterMostRadius; rs .AddRing (newInner, newInner + 50, Math .PI / 3, new double [] { 3, 7, 2, 9, 4 }); newInner = rs .OuterMostRadius; double [] fVal = new double [] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; RingArea ring = new RingArea (this, new Point (0, 0), newInner, newInner + 75, fVal); ring .Colors = Auxi_Colours .SmoothColorsList (fVal .Length, Color .Yellow, Color .Blue); ring .SectorTexts = Auxi_Common .strMonths; rs .AddRing (ring); elems .Add (new SingleElem (rs)); double [] fRandVal = Auxi_Common .RandomArray (1000, Auxi_Common .strDays .Length); PieChart chart = new PieChart (this, new Point (ClientRectangle .Width / 5, ClientRectangle .Height * 2 / 3), Math .Max (ClientRectangle .Width, ClientRectangle .Height) / 4, fRandVal); chart .SectorTexts = Auxi_Common .strDays; for (int i = 0; i < chart .Colors .Count; i++) { chart .ChangeColor (i, Auxi_Colours .ColorPredefined (i)); } int nDifViews = Enum .GetNames (typeof (RoundPlotTextView)) .Length; for (int i = 0; i < chart .Sectors; i++) { chart .SectorComments [i] .TextView = (RoundPlotTextView) (Enum .GetValues (typeof (RoundPlotTextView)) .GetValue (i % nDifViews)); chart .SectorComments [i] .Font = fntSectors; } chart .AddComment (-90, 0.2, DateTime .Now .ToShortTimeString (), fntTitle, angleTitle, clrTitle); elems .Insert (0, new SingleElem (chart)); int nSector = 21; fRandVal = Auxi_Common .RandomArray (1000, nSector); rs = new RingSet (this, new Point (ClientRectangle .Width * 3 / 4, ClientRectangle .Height / 3), 40, Convert .ToInt32 (chart .Radius * 1.1), fRandVal); rs .Rings [0] .Colors = Auxi_Colours .SmoothColorsList (nSector, Color .White, Color .LightBlue); rs .AddComment (90, 0.3, "People", fntTitle, angleTitle, clrTitle); for (int i = 0; i < rs .Rings [0] .Sectors; i++) { rs .Rings [0] .Comments [i] .Text = Auxi_Common .StringOfText (Auxi_Common .strNames, i); rs .Rings [0] .Comments [i] .TextView = RoundPlotTextView .Text; rs .Rings [0] .Comments [i] .Angle = rs .Rings [0] .Comments [i] .AngleToCenter; rs .Rings [0] .Comments [i] .Font = fntSectors; } rs .Rings [0] .FixedSectorTextsAngles = false; rs .Rings [0] .EasyToReadOnRotation = true; elems .Insert (0, new SingleElem (rs)); // barchart // int nSegment = Auxi_Common .strDays .Length - 2; int nSet = 4; double [,] fVals = new double [nSet, nSegment]; for (int i = 0; i < nSet; i++) { for (int j = 0; j < nSegment; j++) { fVals [i, j] = rand .Next (nSeed) % 1000; } } Rectangle rc = new Rectangle (ClientRectangle .Width / 2, ClientRectangle .Height / 2, ClientRectangle .Width * 3 / 7, ClientRectangle .Height * 2 / 5); BarChart barchart = new BarChart (this, rc, fVals, Side .S, Auxi_Common .strDays, TextsDrawingDirection .LTtoRB, Side .E, 1000.0, 0.0, GridOrigin .ByStep, 200.0); barchart .FillCoefficients (0, 0.85); barchart .NumScale .ValuesFormat = "F0"; barchart .AddComment (0.5, 0.1, "Default BarChart", new Font ("Times New Roman", 11, FontStyle .Bold), 0, Color .Red); elems .Insert (0, new SingleElem (barchart)); }
// ------------------------------------------------- public SingleElem (BarChart bc) { rotelem = MedleyElem .BarChart; piechart = null; ringset = null; barchart = bc; }
// ------------------------------------------------- public SingleElem (RingSet rs) { rotelem = MedleyElem .RingSet; piechart = null; ringset = rs; barchart = null; }
// ------------------------------------------------- public SingleElem (PieChart pie) { rotelem = MedleyElem .PieChart; piechart = pie; ringset = null; barchart = null; }
// ------------------------------------------------- Click_miAddRingSet private void Click_miAddRingSet (object sender, EventArgs e) { Form_DefineNewRing form = new Form_DefineNewRing (2, 26); if (form .ShowDialog () == DialogResult .OK) { RingSet ringSrc = form .Ring; RingSet ring = new RingSet (this, ptMouse_Down, 40, 120, ringSrc .Rings [0] .Values); ring .AddComment (-90, -0.3, DateTime .Now .ToShortTimeString (), new Font ("Microsoft Sans Serif", 10, FontStyle .Bold | FontStyle .Italic), 0, Color .Blue); RingArea ra = ring .Rings [0]; ra .Colors = ringSrc .Rings [0] .Colors; for (int i = 0; i < ra .Comments .Count; i++) { ra .Comments [i] .Text = ringSrc .Rings [0] .Comments [i] .Text; } elems .Insert (0, new SingleElem (ring)); RenewMover (); Invalidate (); } }