public NeighborInfo(int rowOffset, int columnOffset, double probability) { this.RelativeLocation = new RelativeLocation(rowOffset, columnOffset); this.DistanceProbability = probability; }
private RelativeLocation ComparePositions(Rectangle orig, Point check) { if (_owner.Orientation == Orientation.Horizontal) { int widthUnit = orig.Width / 2; RelativeLocation relativeLocation = RelativeLocation.Left; // we can return here if we are checking abovebelowleftright, because // the left right calculation is more picky than the above/below calculation // and the above below calculation will just override this one. if ((orig.Left + widthUnit) >= check.X) { relativeLocation = RelativeLocation.Left; return(relativeLocation); } else if ((orig.Right - widthUnit) <= check.X) { relativeLocation = RelativeLocation.Right; return(relativeLocation); } } if (_owner.Orientation == Orientation.Vertical) { int heightUnit = orig.Height / 2; RelativeLocation relativeLocation = (check.Y <= (orig.Top + heightUnit)) ? RelativeLocation.Above : RelativeLocation.Below; return(relativeLocation); } Debug.Fail("Could not calculate the relative position for AllowItemReorder"); return(RelativeLocation.Left); }
private void AddVertexToLayer(string vertexName, int layerIndex) { var vertex = GetVertex(vertexName); var relativeLocation = new RelativeLocation(layerIndex, Layers.GetLayer(layerIndex).Count); Layers.AddVertex(vertex, relativeLocation); }
public void Equals_DiffObjSameValue() { RelativeLocation loc_0_0 = new RelativeLocation(); Assert.IsTrue(loc.Equals(loc_0_0)); Assert.IsTrue(loc_1234_987.Equals(new RelativeLocation(1234, 987))); }
public void NegativeValues() { RelativeLocation loc = new RelativeLocation(-22, -6543); Assert.AreEqual(-22, loc.Row); Assert.AreEqual(-6543, loc.Column); }
private static List <Site> Get8Neighbors(Site site) { List <Site> neighbors = new List <Site>(); RelativeLocation[] neighborhood = new RelativeLocation[] { new RelativeLocation(-1, 0), // north new RelativeLocation(-1, 1), // northeast new RelativeLocation(0, 1), // east new RelativeLocation(1, 1), // southeast new RelativeLocation(1, 0), // south new RelativeLocation(1, -1), // southwest new RelativeLocation(0, -1), // west new RelativeLocation(-1, -1), // northwest }; foreach (RelativeLocation relativeLoc in neighborhood) { Site neighbor = site.GetNeighbor(relativeLoc); if (neighbor != null && neighbor.IsActive) { neighbors.Add(neighbor); } } PlugIn.ModelCore.shuffle(neighbors); return(neighbors); }
//--------------------------------------------------------------------- private static List <ActiveSite> Get4DiagonalNeighbors(Site srcSite) { if (!srcSite.IsActive) { throw new ApplicationException("Source site is not active."); } List <ActiveSite> neighbors = new List <ActiveSite>(); RelativeLocation[] neighborhood = new RelativeLocation[] { new RelativeLocation(-1, 1), // northwest new RelativeLocation(1, 1), // northeast new RelativeLocation(1, -1), // southeast new RelativeLocation(-1, -1), // southwest }; foreach (RelativeLocation relativeLoc in neighborhood) { Site neighbor = srcSite.GetNeighbor(relativeLoc); if (neighbor != null && neighbor.IsActive && !SiteVars.Disturbed[neighbor]) { neighbors.Add((ActiveSite)neighbor); } } return(neighbors); }
//--------------------------------------------------------------------- private static List <Site> Get4ActiveNeighbors(Site srcSite) { if (!srcSite.IsActive) { throw new ApplicationException("Source site is not active."); } List <Site> neighbors = new List <Site>(); RelativeLocation[] neighborhood = new RelativeLocation[] { new RelativeLocation(-1, 0), // north new RelativeLocation(0, 1), // east new RelativeLocation(1, 0), // south new RelativeLocation(0, -1), // west new RelativeLocation(-1, 1), // northwest new RelativeLocation(1, 1), // northeast new RelativeLocation(1, -1), // southeast new RelativeLocation(-1, -1), // southwest }; foreach (RelativeLocation relativeLoc in neighborhood) { Site neighbor = srcSite.GetNeighbor(relativeLoc); if (neighbor != null && neighbor.IsActive) { neighbors.Add(neighbor); } } return(neighbors); //fastNeighbors; }
public void AddVertex(LayoutVertexBase vertex, RelativeLocation targetLocation) { var layer = EnsureLayerExists(targetLocation.LayerIndex); _vertexToLayerIndexMap.Set(vertex, targetLocation.LayerIndex); layer.Add(vertex, targetLocation.IndexInLayer); }
//--------------------------------------------------------------------- private List <Site> GetNeighbors(Site site, int windDirection) { double mod_intensity = 1.0 - this.intensity; if (windDirection > 7) { windDirection = 7; } double[] windProbs = { (((4.0 - mod_intensity) / 8.0) * (1 + mod_intensity)), //Primary direction (((4.0 - mod_intensity) / 8.0) * (1 + mod_intensity)), (((4.0 - mod_intensity) / 8.0)), (((4.0 - mod_intensity) / 8.0) * (1 - mod_intensity)), (((4.0 - mod_intensity) / 8.0) * (1 - mod_intensity)), //Opposite of primary direction (((4.0 - mod_intensity) / 8.0) * (1 - mod_intensity)), (((4.0 - mod_intensity) / 8.0)), (((4.0 - mod_intensity) / 8.0) * (1 + mod_intensity)), }; double windProb = 0.0; int index = 0; List <Site> neighbors = new List <Site>(9); foreach (RelativeLocation relativeLoc in neighborhood) { Site neighbor = site.GetNeighbor(relativeLoc); if (index + windDirection > 7) { windProb = windProbs[index + windDirection - 8]; } else { windProb = windProbs[index + windDirection]; } if (neighbor != null && PlugIn.ModelCore.GenerateUniform() < windProb) { neighbors.Add(neighbor); } index++; } //Next, add the 9th neighbor, a neighbor one cell beyond the //8 nearest neighbors. //array index 0 = north; 1 = northeast, 2 = east,...,8 = northwest int[] vertical = { 2, 2, 0, -2, -2, -2, 0, 2 }; int[] horizontal = { 0, 2, 2, 2, 0, -2, -2, -2 }; RelativeLocation relativeLoc9 = new RelativeLocation(vertical[windDirection], horizontal[windDirection]); Site neighbor9 = site.GetNeighbor(relativeLoc9); if (neighbor9 != null && PlugIn.ModelCore.GenerateUniform() < this.intensity) { neighbors.Add(neighbor9); } return(neighbors); }
[Test] public void Constructor_with_LocationRelative_sets_Value_and_LocationRelative() { var locationRelative = new RelativeLocation(2.3, 3.4); string val = "theValue"; GuiProperty <string> prop = new GuiProperty <string>(val, locationRelative); Assert.That(prop.Content, Is.EqualTo(val)); Assert.That(prop.LocationRelative, Is.EqualTo(locationRelative)); }
/// <summary> /// Converts an object to a <see cref="JsonValue"/>. /// </summary> /// <param name="serializer">The <see cref="JsonSerializer"/> instance to use for additional /// serialization of values.</param> /// <returns>The <see cref="JsonValue"/> representation of the object.</returns> public JsonValue ToJson(JsonSerializer serializer) { var obj = new JsonObject(); obj["valid"] = IsValid; if (RelativeLocation != null) { var relativeLocation = RelativeLocation.ToString(); obj["keywordLocation"] = relativeLocation; if (AbsoluteLocation != null && (AbsoluteLocation.Fragment != relativeLocation || RelativeLocation.Contains("$ref") || RelativeLocation.Contains("$recursiveRef"))) { obj["absoluteKeywordLocation"] = AbsoluteLocation.OriginalString; } } if (InstanceLocation != null) { obj["instanceLocation"] = InstanceLocation.ToString(); } var nonNullNestedResults = NestedResults.Where(r => !ReferenceEquals(r, Null)).ToList(); if (Keyword != null) { obj["keyword"] = Keyword; } if (IsValid) { if (AnnotationValue != null) { obj["annotation"] = AnnotationValue; } if (nonNullNestedResults.Any()) { obj["annotations"] = nonNullNestedResults.Select(r => r.ToJson(serializer)).ToJson(); } } else { if (!string.IsNullOrWhiteSpace(ErrorMessage)) { obj["error"] = ErrorMessage; } if (nonNullNestedResults.Any()) { obj["errors"] = nonNullNestedResults.Select(r => r.ToJson(serializer)).ToJson(); } } if (IncludeAdditionalInfo && AdditionalInfo != null && AdditionalInfo.Any()) { obj["additionalInfo"] = AdditionalInfo; } return(obj); }
private void Draw() { Updating.Reset(); var viewCenter = new RelativeLocation(FixedLocation.Zero, viewShift); form.Display(members, viewCenter, zoomFactor); Updating.Set(); }
[Test] public void constructsCorrectlyGivenLocationAndSize() { Point location = new Point(20, 20); Size size = new Size(100, 200); var expectedRelLoc = new RelativeLocation(0.2, 0.1); var constructedRelLoc = new RelativeLocation(location, size); Assert.That(constructedRelLoc, Is.EqualTo(expectedRelLoc)); }
private void OnDropItem(ToolStripItem droppedItem, Point ownerClientAreaRelativeDropPoint) { int itemInsertionIndex = this.GetItemInsertionIndex(ownerClientAreaRelativeDropPoint); if (itemInsertionIndex < 0) { if ((itemInsertionIndex == -1) && (this.owner.Items.Count == 0)) { this.owner.Items.Add(droppedItem); this.owner.ClearInsertionMark(); } } else { ToolStripItem item = this.owner.Items[itemInsertionIndex]; if (item == droppedItem) { this.owner.ClearInsertionMark(); } else { RelativeLocation location = this.ComparePositions(item.Bounds, ownerClientAreaRelativeDropPoint); droppedItem.Alignment = item.Alignment; int num2 = Math.Max(0, itemInsertionIndex); switch (location) { case RelativeLocation.Above: num2 = (item.Alignment == ToolStripItemAlignment.Left) ? num2 : (num2 + 1); break; case RelativeLocation.Below: num2 = (item.Alignment == ToolStripItemAlignment.Left) ? num2 : (num2 - 1); break; default: if (((item.Alignment == ToolStripItemAlignment.Left) && (location == RelativeLocation.Left)) || ((item.Alignment == ToolStripItemAlignment.Right) && (location == RelativeLocation.Right))) { num2 = Math.Max(0, (this.owner.RightToLeft == RightToLeft.Yes) ? (num2 + 1) : num2); } else { num2 = Math.Max(0, (this.owner.RightToLeft == RightToLeft.No) ? (num2 + 1) : num2); } break; } if (this.owner.Items.IndexOf(droppedItem) < num2) { num2--; } this.owner.Items.MoveItem(Math.Max(0, num2), droppedItem); this.owner.ClearInsertionMark(); } } }
//--------------------------------------------------------------------- public override bool Equals(object obj) { //Check for null and compare run-time types. if (obj == null || GetType() != obj.GetType()) { return(false); } RelativeLocation loc = (RelativeLocation)obj; return(this == loc); }
protected CatalogSubject(SystemResourceScheme Scheme, string host, string Name, INodeCatalogSubject Parent = null) { this.Parent = Parent; this.Scheme = Scheme; this.IsRoot = Parent == null; this.SymbolicHost = host; this.Name = IsRoot ? $"/{host}/{Name}" : Name; this.Lineage = DeriveLineage().ToList(); this.RelativeLocation = IsRoot ? this.Name : DeriveRelativeLocation(); this.Urn = DeriveUrn(); this.LineageSegments = Urn.NonSchemeComponents.Zip(RelativeLocation.Split('/'), (x, y) => (x, y)).ToList(); this.Segment = (Urn.ToString(), RelativeLocation.ToString()); }
private bool setInsideOutsideState(RelativeLocation insideOutsideValue) { if (insideOutsideValue == RelativeLocation.Inside) { machine.INSIDEBOUNDINGBOX.SetCurrent(); return(false); } else { machine.OUTSIDEBOUNDINGBOX.SetCurrent(); return(true); } }
internal override void GetOrder(ColoBox boxToPlace, Point section, out RelativeLocation first, out RelativeLocation second) { if (boxToPlace.MinX <= section.X) //&& boxToPlace.MaxX <= section.Y) { first = RelativeLocation.Outside; second = RelativeLocation.Inside; } else { first = RelativeLocation.Inside; second = RelativeLocation.Outside; } }
//--------------------------------------------------------------------- // Generate a RelativeLocation array for one quarter of the neighborhood. // Check each cell within a box to the northeast the center point. This will // create a set of POTENTIAL neighbors. These potential neighbors // will need to be later checked to ensure that they are within the landscape // and active. private static IEnumerable <RelativeLocationWeighted> InitializeMaxSeedNeighborhood() { int maxSeedDistance = 0; foreach (ISpecies species in Model.Core.Species) { maxSeedDistance = Math.Max(maxSeedDistance, species.MaxSeedDist); } double CellLength = Model.Core.CellLength; UI.WriteLine(" Creating Dispersal Neighborhood List."); List <RelativeLocationWeighted> neighborhood = new List <RelativeLocationWeighted>(); int neighborRadius = maxSeedDistance; int numCellRadius = (int)(neighborRadius / CellLength); UI.WriteLine(" Dispersal: NeighborRadius={0}, CellLength={1}, numCellRadius={2}", neighborRadius, CellLength, numCellRadius); double centroidDistance = 0; double cellLength = CellLength; for (int row = 1; row <= numCellRadius; row++) { for (int col = 0; col <= numCellRadius; col++) { centroidDistance = DistanceFromCenter(row, col); //UI.WriteLine("Centroid Distance = {0}.", centroidDistance); if (centroidDistance <= neighborRadius) { RelativeLocation reloc = new RelativeLocation(row, col); neighborhood.Add(new RelativeLocationWeighted(reloc, centroidDistance)); } } } //Add same cell: neighborhood.Add(new RelativeLocationWeighted(new RelativeLocation(0, 0), 0.0)); WeightComparer weightComp = new WeightComparer(); neighborhood.Sort(weightComp); foreach (RelativeLocationWeighted reloc in neighborhood) { UI.WriteLine("Neighbor distance = {0}.", reloc.Weight); } return(neighborhood); }
//--------------------------------------------------------------------- //Generate a Relative Location array (with WEIGHTS) of neighbors. //Check each cell within a block surrounding the center point. This will //create a set of POTENTIAL neighbors. These potential neighbors //will need to be later checked to ensure that they are within the landscape // and active. private static IEnumerable <RelativeLocationWeighted> GetResourceNeighborhood(IAgent agent) { float CellLength = PlugIn.ModelCore.CellLength; PlugIn.ModelCore.UI.WriteLine("Creating Neighborhood List."); int neighborRadius = agent.NeighborRadius; int numCellRadius = (int)((double)neighborRadius / CellLength); PlugIn.ModelCore.UI.WriteLine("NeighborRadius={0}, CellLength={1}, numCellRadius={2}", neighborRadius, CellLength, numCellRadius); double centroidDistance = 0; double cellLength = CellLength; double neighborWeight = 0; List <RelativeLocationWeighted> neighborhood = new List <RelativeLocationWeighted>(); for (int row = (numCellRadius * -1); row <= numCellRadius; row++) { for (int col = (numCellRadius * -1); col <= numCellRadius; col++) { neighborWeight = 0; centroidDistance = DistanceFromCenter(row, col); //PlugIn.ModelCore.Log.WriteLine("Centroid Distance = {0}.", centroidDistance); if (centroidDistance <= neighborRadius && centroidDistance > 0) { if (agent.ShapeOfNeighbor == NeighborShape.uniform) { neighborWeight = 1.0; } if (agent.ShapeOfNeighbor == NeighborShape.linear) { //neighborWeight = (neighborRadius - centroidDistance + (cellLength/2)) / (double) neighborRadius; neighborWeight = 1.0 - (centroidDistance / (double)neighborRadius); } if (agent.ShapeOfNeighbor == NeighborShape.gaussian) { double halfRadius = neighborRadius / 2; neighborWeight = (float) System.Math.Exp(-1 * System.Math.Pow(centroidDistance, 2) / System.Math.Pow(halfRadius, 2)); } RelativeLocation reloc = new RelativeLocation(row, col); neighborhood.Add(new RelativeLocationWeighted(reloc, neighborWeight)); } } } return(neighborhood); }
/// <summary>Serves as the default hash function. </summary> /// <returns>A hash code for the current object.</returns> public override int GetHashCode() { unchecked { var hashCode = IsValid.GetHashCode(); hashCode = (hashCode * 397) ^ (RelativeLocation?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ (AbsoluteLocation?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ (InstanceLocation?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ (AnnotationValue?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ (Keyword?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ (AdditionalInfo?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ (NestedResults?.GetCollectionHashCode() ?? 0); return(hashCode); } }
//--------------------------------------------------------------------- // Generate a RelativeLocation array for one quarter of the neighborhood. // Check each cell within a box to the northeast the center point. This will // create a set of POTENTIAL neighbors. These potential neighbors // will need to be later checked to ensure that they are within the landscape // and active. public static void InitializeMaxSeedNeighborhood() { int maxSeedDistance = 0; foreach (ISpecies species in Model.Core.Species) { maxSeedDistance = Math.Max(maxSeedDistance, species.MaxSeedDist); } double cellLength = (double)Model.Core.CellLength; UI.WriteLine(" Creating Dispersal Neighborhood List."); List <RelativeLocationWeighted> neighborhood = new List <RelativeLocationWeighted>(); double neighborRadius = maxSeedDistance + (cellLength / 2.0); int numCellRadius = (int)(neighborRadius / cellLength); UI.WriteLine(" Dispersal: NeighborRadius={0}, CellLength={1}, numCellRadius={2}", neighborRadius, cellLength, numCellRadius); double centroidDistance = 0.0; for (int row = 1; row <= numCellRadius + 1; row++) { for (int col = 0; col <= numCellRadius + 1; col++) { centroidDistance = DistanceFromCenter((double)row, (double)col); //UI.WriteLine("Centroid Distance = {0}.", centroidDistance); if (centroidDistance <= neighborRadius) { RelativeLocation reloc = new RelativeLocation(row, col); neighborhood.Add(new RelativeLocationWeighted(reloc, centroidDistance)); } } } WeightComparer weightComp = new WeightComparer(); neighborhood.Sort(weightComp); //foreach(RelativeLocationWeighted reloc in neighborhood) //UI.WriteLine("Row = {0}. Col = {1}. Neighbor distance = {2}.", reloc.Location.Row, reloc.Location.Column, reloc.Weight); MaxSeedQuarterNeighborhood = neighborhood; return; }
private bool ShowItemDropPoint(Point ownerClientAreaRelativeDropPoint) { int i = GetItemInsertionIndex(ownerClientAreaRelativeDropPoint); if (i >= 0) { ToolStripItem item = _owner.Items[i]; RelativeLocation relativeLocation = ComparePositions(item.Bounds, ownerClientAreaRelativeDropPoint); Debug.WriteLineIf(ToolStrip.s_itemReorderDebug.TraceVerbose, "Drop relative loc " + relativeLocation); Debug.WriteLineIf(ToolStrip.s_itemReorderDebug.TraceVerbose, "Index " + i); Rectangle insertionRect = Rectangle.Empty; switch (relativeLocation) { case RelativeLocation.Above: insertionRect = new Rectangle(_owner.Margin.Left, item.Bounds.Top, _owner.Width - (_owner.Margin.Horizontal) - 1, ToolStrip.s_insertionBeamWidth); break; case RelativeLocation.Below: insertionRect = new Rectangle(_owner.Margin.Left, item.Bounds.Bottom, _owner.Width - (_owner.Margin.Horizontal) - 1, ToolStrip.s_insertionBeamWidth); break; case RelativeLocation.Right: insertionRect = new Rectangle(item.Bounds.Right, _owner.Margin.Top, ToolStrip.s_insertionBeamWidth, _owner.Height - (_owner.Margin.Vertical) - 1); break; case RelativeLocation.Left: insertionRect = new Rectangle(item.Bounds.Left, _owner.Margin.Top, ToolStrip.s_insertionBeamWidth, _owner.Height - (_owner.Margin.Vertical) - 1); break; } _owner.PaintInsertionMark(insertionRect); return(true); } else if (_owner.Items.Count == 0) { Rectangle insertionRect = _owner.DisplayRectangle; insertionRect.Width = ToolStrip.s_insertionBeamWidth; _owner.PaintInsertionMark(insertionRect); return(true); } return(false); }
public bool PerformAddOperation(string commandName, InformationSourceCollection sources, string requesterLocation, HttpFileCollection files) { // TODO: Properly separate acct add email and grp invite EmailAddress = EmailAddress.ToLower(); if (RelativeLocation.StartsWith("acc/")) { AddAccountEmailAddressHandling(); } else if (RelativeLocation.StartsWith("grp/")) { GroupInvitationHandling(); } else { throw new InvalidDataException("Relative location of AddEmailAddressInfo is not acc or grp context bound"); } this.EmailAddress = ""; return(true); }
private bool ShowItemDropPoint(Point ownerClientAreaRelativeDropPoint) { int itemInsertionIndex = this.GetItemInsertionIndex(ownerClientAreaRelativeDropPoint); if (itemInsertionIndex < 0) { if (this.owner.Items.Count == 0) { Rectangle displayRectangle = this.owner.DisplayRectangle; displayRectangle.Width = 6; this.owner.PaintInsertionMark(displayRectangle); return(true); } return(false); } ToolStripItem item = this.owner.Items[itemInsertionIndex]; RelativeLocation location = this.ComparePositions(item.Bounds, ownerClientAreaRelativeDropPoint); Rectangle empty = Rectangle.Empty; switch (location) { case RelativeLocation.Above: empty = new Rectangle(this.owner.Margin.Left, item.Bounds.Top, (this.owner.Width - this.owner.Margin.Horizontal) - 1, 6); break; case RelativeLocation.Below: empty = new Rectangle(this.owner.Margin.Left, item.Bounds.Bottom, (this.owner.Width - this.owner.Margin.Horizontal) - 1, 6); break; case RelativeLocation.Right: empty = new Rectangle(item.Bounds.Right, this.owner.Margin.Top, 6, (this.owner.Height - this.owner.Margin.Vertical) - 1); break; case RelativeLocation.Left: empty = new Rectangle(item.Bounds.Left, this.owner.Margin.Top, 6, (this.owner.Height - this.owner.Margin.Vertical) - 1); break; } this.owner.PaintInsertionMark(empty); return(true); }
//------------------------------------------------------- private static List <WeightedSite> Get8WeightedNeighbors(Site srcSite, Event fireEvent, bool buildUp) { if (!srcSite.IsActive) { throw new ApplicationException("Source site is not active."); } List <WeightedSite> temp = new List <WeightedSite>(0); double travelTime = 0.0; RelativeLocation[] neighborhood = new RelativeLocation[] { new RelativeLocation(-1, 0), // north new RelativeLocation(-1, 1), // northeast new RelativeLocation(0, 1), // east new RelativeLocation(1, 1), // southeast new RelativeLocation(1, 0), // south new RelativeLocation(1, -1), // southwest new RelativeLocation(0, -1), // west new RelativeLocation(-1, -1), // northwest }; foreach (RelativeLocation relativeLoc in neighborhood) { Site neighbor = srcSite.GetNeighbor(relativeLoc); if (neighbor != null && neighbor.IsActive && SiteVars.Event[neighbor] == null) { travelTime = CalculateTravelTime(neighbor, srcSite, fireEvent, buildUp); //if (travelTime < 1) // PlugIn.ModelCore.UI.WriteLine("Travel time < 1"); temp.Add(new WeightedSite(neighbor, travelTime)); } } return(temp); //fastNeighbors; }
public override bool CanMoveElements(RelativeLocation location, IList<CodeStructureElement> dropElements) { return false; }
public RelativeLocationWeighted(RelativeLocation location, double weight) { this.location = location; this.weight = weight; }
public static void DisperseLDD(Site site, bool wrapLDD) { double max_distance_dispersed = 0; //if (dispersal_type == Dispersal_Type.STATIC) //{ int limit = max_dispersal_distance_pixels; for (int j = -limit; j <= limit; j++) { for (int k = -limit; k <= limit; k++) { double r, p, dj, dk; int target_x, target_y; dj = j * PlugIn.ModelCore.CellLength; dk = k * PlugIn.ModelCore.CellLength; r = Math.Sqrt(dj * dj + dk * dk); p = dispersal_probability[r]; target_x = site.Location.Column + j; target_y = site.Location.Row + k; // wrapLDD causes dispersers to stay within the landscape by wrapping the dispersal vector around the landscape (i.e., torus) if (wrapLDD) { int landscapeRows = PlugIn.ModelCore.Landscape.Rows; int landscapeCols = PlugIn.ModelCore.Landscape.Columns; //remainRow=SIGN(C4)*MOD(ABS(C4),$B$1) int remainRow = Math.Sign(k) * (Math.Abs(k) % landscapeRows); int remainCol = Math.Sign(j) * (Math.Abs(j) % landscapeCols); //tempY=A4+H4 int tempY = site.Location.Row + remainRow; int tempX = site.Location.Column + remainCol; //source_y=IF(J4<1,$B$1+J4,IF(J4>$B$1,MOD(J4,$B$1),J4)) if (tempY < 1) { target_y = landscapeRows + tempY; } else { if (tempY > landscapeRows) { target_y = tempY % landscapeRows; } else { target_y = tempY; } } if (tempX < 1) { target_x = landscapeCols + tempX; } else { if (tempX > landscapeCols) { target_x = tempX % landscapeCols; } else { target_x = tempX; } } } //RelativeLocation targetLocation = new RelativeLocation(k, j); RelativeLocation targetLocation = new RelativeLocation(target_y - site.Location.Row, target_x - site.Location.Column); Site targetSite = site.GetNeighbor(targetLocation); if (targetSite.IsActive) { if (p * SiteVars.LDDout[site] >= 1 && r > max_distance_dispersed) { max_distance_dispersed = r; } SiteVars.Disperse_n[targetSite] = SiteVars.Disperse_n[targetSite] + p * SiteVars.LDDout[site]; SiteVars.Disperse_v[targetSite] = SiteVars.Disperse_v[targetSite] + p * (1 - p) * SiteVars.LDDout[site]; } } } //} }
public override void MoveElements(RelativeLocation location, IList<CodeStructureElement> dropElements) { throw new NotSupportedException(); }
public static RelativeLocation CreateRelativeLocation(int ID, int vertex_ID) { RelativeLocation relativeLocation = new RelativeLocation(); relativeLocation.ID = ID; relativeLocation.Vertex_ID = vertex_ID; return relativeLocation; }
private SourcePoint GetInsertionPoint(TypeDeclaration activeType, LanguageElementType elementType, RelativeLocation relativeLocation, DefaultLocation defaultLocation) { LanguageElementType[] elementTypes; if (elementType == LanguageElementType.Variable) { elementTypes = new LanguageElementType[2]; elementTypes[0] = LanguageElementType.Variable; elementTypes[1] = LanguageElementType.InitializedVariable; } else { elementTypes = new LanguageElementType[1]; elementTypes[0] = elementType; } ElementEnumerable elementEnumerable = new ElementEnumerable(activeType, elementTypes); LanguageElement lastElement = null; foreach (LanguageElement element in elementEnumerable) { if (relativeLocation == RelativeLocation.Before) return element.GetFullBlockCutRange().Top; else // RelativeLocation.After... lastElement = element; } if (lastElement != null) return lastElement.GetFullBlockCutRange().Bottom; if (defaultLocation == DefaultLocation.Top) return activeType.BlockCodeRange.Top; else // Bottom... return activeType.BlockCodeRange.Bottom; }
public void Init() { loc_1234_987 = new RelativeLocation(1234, 987); }
public void AddToRelativeLocations(RelativeLocation relativeLocation) { base.AddObject("RelativeLocations", relativeLocation); }