void WriteBorderInfo(GeometryToken token, BorderInfo borderInfo) { WriteStartElement(token); WriteAttribute(GeometryToken.InnerMargin, borderInfo.InnerMargin); WriteAttribute(GeometryToken.FixedPosition, borderInfo.FixedPosition); WriteAttribute(GeometryToken.Weight, borderInfo.Weight); WriteEndElement(); }
internal static string IsFixedString(BorderInfo bi) { if (bi.IsFixedPosition) { return("Fixed"); } return("Free"); }
//public Piece Instantiate<T>(PieceInfo info) //{ // var obj = Instantiate(_cellPrefab); // var cell = obj.GetComponent<Cell>(); // _pieceList.Cells.Add(info.Coord, cell); // cell.Initialize(info); // return obj; //} public Border Instantiate(BorderInfo info) { var obj = Instantiate(_borderPrefab); var border = obj.GetComponent <Border>(); _pieceList.Borders.Add(info.Coord, border); border.Initialize(info); return(obj); }
public void constructRoad(ref PathInfo[] path, int roadNumber, TurnInfo turnInfo) { path[roadNumber] = PathInfo.VALID; int addMoreLeft = 0; int addMoreRight = 0; switch (turnInfo) { case TurnInfo.LEFT: addMoreLeft++; break; case TurnInfo.RIGHT: addMoreRight++; break; case TurnInfo.BOTH: addMoreRight++; addMoreLeft++; break; default: break; } if (addMoreLeft == 0 && addMoreRight == 0 && currentPathSize % 2 == 0) { if (border == BorderInfo.CENTRAL) { border = Random.Range(0, 2) == 0 ? BorderInfo.LEFT : BorderInfo.RIGHT; } if (border == BorderInfo.LEFT) { addMoreLeft += 1; } else if (border == BorderInfo.RIGHT) { addMoreRight += 1; } if (border != BorderInfo.CENTRAL && Random.Range(0f, 100f) < 15f) { border = BorderInfo.CENTRAL; } } if (bonusRangeDuration > 0) { addMoreRight += (int)((float)bonusRange / 2f); addMoreLeft += (int)((float)bonusRange / 2f); } setRoadAside(ref path, roadNumber, true, (int)((currentPathSize - 1f) / 2f) + addMoreRight); setRoadAside(ref path, roadNumber, false, (int)((currentPathSize - 1f) / 2f) + addMoreLeft); }
} // end ComputeFixedBorders() private BorderInfo ComputeFixedBorder(BorderInfo bi, double innerEdgePosition) { // If the passed BorderInfo is fixed, then set its position such that its inner // edge is at innerEdgePosition. if (bi.IsFixedPosition && !RetainFixedBorders) { return(new BorderInfo(bi.InnerMargin, innerEdgePosition - bi.InnerMargin, bi.Weight)); } return(bi); }
// For initialization verbose output; we don't send an actual BorderInfo for borders with no margin etc. private static BorderInfo ComputeInitialBorder(BorderInfo bi, double unfixedInitialBorderPosition) { // If the passed BorderInfo is fixed, then set its position such that its inner // edge is at innerEdgePosition. if (bi.IsFixedPosition) { return(bi); } return(new BorderInfo(bi.InnerMargin, unfixedInitialBorderPosition - bi.InnerMargin, bi.Weight)); }
internal ClusterDef(double minSizeX, double minSizeY, BorderInfo lbi, BorderInfo rbi, BorderInfo tbi, BorderInfo bbi) : this() { this.MinimumSizeX = minSizeX; this.MinimumSizeY = minSizeY; this.LeftBorderInfo = lbi; this.RightBorderInfo = rbi; this.TopBorderInfo = tbi; this.BottomBorderInfo = bbi; }
private bool UnexpectedFixedBorderMove(BorderInfo bi, double edgePosition, string edgeName, bool isX, ref bool summaryDone) { if (Math.Abs(bi.FixedPosition - edgePosition) > MaxAllowedDiff) { if (!summaryDone) { WriteLine("Error: Unexpected {0} fixed-border change for Cluster '{1}':", isX ? "X" : "Y", this.ClusterId); WriteLine(" OlapCluster: {0} L/R {1:F5}/{2:F5}", this.Cluster, isX ? this.Left : this.Top, isX ? this.Right : this.Bottom); summaryDone = true; } WriteLine(" {0}BorderInfo: {1}", edgeName, this.LeftBorderInfo); return(true); } return(false); }
public static void Run() { // ExStart:RoundedCornerTable // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdf_Tables(); Aspose.Pdf.Table tab1 = new Aspose.Pdf.Table(); GraphInfo graph = new GraphInfo(); graph.Color = Aspose.Pdf.Color.Red; // Create a blank BorderInfo object BorderInfo bInfo = new BorderInfo(BorderSide.All, graph); // Set the border a rounder border where radius of round is 15 bInfo.RoundedBorderRadius = 15; // Set the table Corner style as Round. tab1.CornerStyle = Aspose.Pdf.BorderCornerStyle.Round; // Set the table border information tab1.Border = bInfo; // ExEnd:RoundedCornerTable }
// end Load() private static BorderInfo ParseBorderInfo(string strDir, string strLine, int lineNumber) { Match m = TestFileStrings.ParseClusterBorder.Match(strLine); if (m.Success) { string strRgxDir = m.Groups["dir"].ToString(); if (strRgxDir != strDir) { Validate.Fail(string.Format("Out-of-sequence CLUSTER Border line {0}: {1}", lineNumber, strLine)); } } else { Validate.Fail(string.Format("Unparsable CLUSTER Border line {0}: {1}", lineNumber, strLine)); } var bi = new BorderInfo { InnerMargin = double.Parse(m.Groups["margin"].ToString()), FixedPosition = BorderInfo.NoFixedPosition, Weight = BorderInfo.DefaultFreeWeight }; string strFixedPos = m.Groups["fixedpos"].ToString(); if (0 == string.Compare("Fixed", strFixedPos, StringComparison.OrdinalIgnoreCase)) { // Slightly hacky; just set this to a non-NaN and we'll compute the value from the // variables that go into it. bi.FixedPosition = 0.0; } var weight = double.Parse(m.Groups["weight"].ToString()); if (0.0 != weight) { bi.Weight = weight; } return(bi); }
private void AddOlapClusters(ConstraintGenerator generator, OverlapRemovalCluster olapParentCluster, Cluster incClus, InitialCenterDelegateType nodeCenter) { LayoutAlgorithmSettings settings = clusterSettings(incClus); double nodeSeparationH = settings.NodeSeparation; double nodeSeparationV = settings.NodeSeparation + 1e-4; double innerPaddingH = settings.ClusterMargin; double innerPaddingV = settings.ClusterMargin + 1e-4; // Creates the OverlapRemoval (Olap) Cluster/Node objects for our FastIncrementalLayout (FIL) objects. // If !isHorizontal this overwrites the Olap members of the Incremental.Clusters and Msagl.Nodes. // First create the olapCluster for the current incCluster. If olapParentCluster is null, then // incCluster is the root of a new hierarchy. RectangularClusterBoundary rb = incClus.RectangularBoundary; if (IsHorizontal) { rb.olapCluster = generator.AddCluster( olapParentCluster, incClus /* userData */, rb.MinWidth, rb.MinHeight, rb.LeftBorderInfo, rb.RightBorderInfo, rb.BottomBorderInfo, rb.TopBorderInfo); rb.olapCluster.NodePadding = nodeSeparationH; rb.olapCluster.NodePaddingP = nodeSeparationV; rb.olapCluster.ClusterPadding = innerPaddingH; rb.olapCluster.ClusterPaddingP = innerPaddingV; } else { var postXLeftBorderInfo = new BorderInfo(rb.LeftBorderInfo.InnerMargin, rb.Rect.Left, rb.LeftBorderInfo.Weight); var postXRightBorderInfo = new BorderInfo(rb.RightBorderInfo.InnerMargin, rb.Rect.Right, rb.RightBorderInfo.Weight); rb.olapCluster = generator.AddCluster( olapParentCluster, incClus /* userData */, rb.MinHeight, rb.MinWidth, rb.BottomBorderInfo, rb.TopBorderInfo, postXLeftBorderInfo, postXRightBorderInfo); rb.olapCluster.NodePadding = nodeSeparationV; rb.olapCluster.NodePaddingP = nodeSeparationH; rb.olapCluster.ClusterPadding = innerPaddingV; rb.olapCluster.ClusterPaddingP = innerPaddingH; } rb.olapCluster.TranslateChildren = rb.GenerateFixedConstraints; // Note: Incremental.Cluster always creates child List<Cluster|Node> so we don't have to check for null here. // Add our child nodes. foreach (var filNode in incClus.Nodes) { AddOlapNode(generator, rb.olapCluster, (FiNode)filNode.AlgorithmData, nodeCenter); } // Now recurse through all child clusters. foreach (var incChildClus in incClus.Clusters) { AddOlapClusters(generator, rb.olapCluster, incChildClus, nodeCenter); } }
public void setBorder(int side, int style, CondLength width, ColorType color) { borderInfo[side] = new BorderInfo(style, width, color); }
private static GameObject GetRMC_and_Set_Restriction_info(string tilename, int rotation, bool is_mirrored, Vector3 rmcPlacement) { // ((unity loads models with -x axis)) string RMCname = TileManager.TileListInfo[tilename].RMCname; Quaternion rotate_q = Quaternion.Euler(new Vector3(0, rotation, 0)); char x = RMCname[0]; char z = RMCname[2]; if (x == '1' && z == '1') { //nothing } else if (x == '1' && z == '2') { if (is_mirrored) { rotate_q = Quaternion.Euler(new Vector3(0, -rotation, 0)); if (rotation == 90 || rotation == 270) { // V1 = H2 if (RMCname.Contains("H2") && !RMCname.Contains("V1")) { RMCname += "V1"; } else if (!RMCname.Contains("H2") && RMCname.Contains("V1")) { RMCname = RMCname.Replace("V1", ""); } } } } else if (x == '2' && z == '1') { if (is_mirrored) { rotate_q = Quaternion.Euler(new Vector3(0, -rotation, 0)); if (rotation == 0 || rotation == 180) { // H1 = H2 if (RMCname.Contains("H2") && !RMCname.Contains("H1")) { RMCname += "H1"; } else if (!RMCname.Contains("H2") && RMCname.Contains("H1")) { RMCname = RMCname.Replace("H1", ""); } } } } else // 2x2 { if (is_mirrored) { // mirrored 2x2 tiles somehow invert restrictions H1 with H2 // switch H1 with H2 if (RMCname.Contains("H1")) { RMCname = RMCname.Replace("H2", "Hx").Replace("H1", "H2").Replace("Hx", "H1"); } else if (RMCname.Contains("H2")) { RMCname = RMCname.Replace("H2", "H1"); } if (rotation == 90) { // ("switched" H2) = V2 -> H1 = V2 if (RMCname.Contains("V2") && !RMCname.Contains("H1")) { RMCname += "H1"; } else if (!RMCname.Contains("V2") && RMCname.Contains("H1")) { RMCname = RMCname.Replace("H1", ""); } } } else { if (rotation == 270) { // H2 = V2 if (RMCname.Contains("V2") && !RMCname.Contains("H2")) { RMCname += "H2"; } else if (!RMCname.Contains("V2") && RMCname.Contains("H2")) { RMCname = RMCname.Replace("H2", ""); } } } } //Debug.Log(RMCname + " " + rotation + " " + is_mirrored); RMCname = NormalizeRMCname(RMCname); var rmc = Instantiate(Get_RMC_Containing(RMCname), rmcPlacement, rotate_q); BorderInfo.CreateComponent(rmc, RMCname); rmc.GetComponent <MeshRenderer>().material = transparent; return(rmc); }
/// <summary> /// ClipBorder computes the position of its single child and applies its child's alignments to the child. /// /// </summary> /// <param name="finalSize">The size reserved for this element by the parent</param> /// <returns>The actual ink area of the element, typically the same as finalSize</returns> protected override Size ArrangeOverride(Size finalSize) { var borders = BorderThickness; var boundRect = new Rect(finalSize); var innerRect = boundRect.Deflate(borders); var corners = CornerRadius; var padding = Padding; var childRect = innerRect.Deflate(padding); // calculate border rendering geometry if (!boundRect.Width.IsZero() && !boundRect.Height.IsZero()) { var outerBorderInfo = new BorderInfo(corners, borders, new Thickness(), true); var borderGeometry = new StreamGeometry(); using (var ctx = borderGeometry.Open()) { GenerateGeometry(ctx, boundRect, outerBorderInfo); } // Freeze the geometry for better perfomance borderGeometry.Freeze(); _borderGeometryCache = borderGeometry; } else { _borderGeometryCache = null; } // calculate background rendering geometry if (!innerRect.Width.IsZero() && !innerRect.Height.IsZero()) { var innerBorderInfo = new BorderInfo(corners, borders, new Thickness(), false); var backgroundGeometry = new StreamGeometry(); using (var ctx = backgroundGeometry.Open()) { GenerateGeometry(ctx, innerRect, innerBorderInfo); } // Freeze the geometry for better perfomance backgroundGeometry.Freeze(); _backgroundGeometryCache = backgroundGeometry; } else { _backgroundGeometryCache = null; } // Arrange the Child and set its clip var child = Child; if (child != null) { child.Arrange(childRect); // Calculate the Clipping Geometry var clipGeometry = new StreamGeometry(); var childBorderInfo = new BorderInfo(corners, borders, padding, false); using (var ctx = clipGeometry.Open()) { GenerateGeometry(ctx, new Rect(0, 0, childRect.Width, childRect.Height), childBorderInfo); } // Freeze the geometry for better perfomance clipGeometry.Freeze(); // Apply the clip to the Child child.Clip = clipGeometry; } return finalSize; }
/// <summary> /// Generates a StreamGeometry. /// </summary> /// <param name="ctx">An already opened StreamGeometryContext.</param> /// <param name="rect">Rectangle for geomentry conversion.</param> /// <param name="borderInfo">The core points of the border which needs to be used to create /// the geometry</param> /// <returns>Result geometry.</returns> private static void GenerateGeometry(StreamGeometryContext ctx, Rect rect, BorderInfo borderInfo) { // compute the coordinates of the key points var leftTop = new Point(borderInfo.LeftTop, 0); var rightTop = new Point(rect.Width - borderInfo.RightTop, 0); var topRight = new Point(rect.Width, borderInfo.TopRight); var bottomRight = new Point(rect.Width, rect.Height - borderInfo.BottomRight); var rightBottom = new Point(rect.Width - borderInfo.RightBottom, rect.Height); var leftBottom = new Point(borderInfo.LeftBottom, rect.Height); var bottomLeft = new Point(0, rect.Height - borderInfo.BottomLeft); var topLeft = new Point(0, borderInfo.TopLeft); // check keypoints for overlap and resolve by partitioning corners according to // the percentage of each one. // top edge if (leftTop.X > rightTop.X) { var v = (borderInfo.LeftTop) / (borderInfo.LeftTop + borderInfo.RightTop) * rect.Width; leftTop.X = v; rightTop.X = v; } // right edge if (topRight.Y > bottomRight.Y) { var v = (borderInfo.TopRight) / (borderInfo.TopRight + borderInfo.BottomRight) * rect.Height; topRight.Y = v; bottomRight.Y = v; } // bottom edge if (leftBottom.X > rightBottom.X) { var v = (borderInfo.LeftBottom) / (borderInfo.LeftBottom + borderInfo.RightBottom) * rect.Width; rightBottom.X = v; leftBottom.X = v; } // left edge if (topLeft.Y > bottomLeft.Y) { var v = (borderInfo.TopLeft) / (borderInfo.TopLeft + borderInfo.BottomLeft) * rect.Height; bottomLeft.Y = v; topLeft.Y = v; } // Apply offset var offsetX = rect.TopLeft.X; var offsetY = rect.TopLeft.Y; var offset = new Vector(offsetX, offsetY); leftTop += offset; rightTop += offset; topRight += offset; bottomRight += offset; rightBottom += offset; leftBottom += offset; bottomLeft += offset; topLeft += offset; // create the border geometry ctx.BeginFigure(leftTop, true /* is filled */, true /* is closed */); // Top line ctx.LineTo(rightTop, true /* is stroked */, false /* is smooth join */); // Upper-right corners var radiusX = rect.TopRight.X - rightTop.X; var radiusY = topRight.Y - rect.TopRight.Y; if (!radiusX.IsZero() || !radiusY.IsZero()) { ctx.ArcTo(topRight, new Size(radiusX, radiusY), 0, false, SweepDirection.Clockwise, true, false); } // Right line ctx.LineTo(bottomRight, true /* is stroked */, false /* is smooth join */); // Lower-right corners radiusX = rect.BottomRight.X - rightBottom.X; radiusY = rect.BottomRight.Y - bottomRight.Y; if (!radiusX.IsZero() || !radiusY.IsZero()) { ctx.ArcTo(rightBottom, new Size(radiusX, radiusY), 0, false, SweepDirection.Clockwise, true, false); } // Bottom line ctx.LineTo(leftBottom, true /* is stroked */, false /* is smooth join */); // Lower-left corners radiusX = leftBottom.X - rect.BottomLeft.X; radiusY = rect.BottomLeft.Y - bottomLeft.Y; if (!radiusX.IsZero() || !radiusY.IsZero()) { ctx.ArcTo(bottomLeft, new Size(radiusX, radiusY), 0, false, SweepDirection.Clockwise, true, false); } // Left line ctx.LineTo(topLeft, true /* is stroked */, false /* is smooth join */); // Upper-left corners radiusX = leftTop.X - rect.TopLeft.X; radiusY = topLeft.Y - rect.TopLeft.Y; if (!radiusX.IsZero() || !radiusY.IsZero()) { ctx.ArcTo(leftTop, new Size(radiusX, radiusY), 0, false, SweepDirection.Clockwise, true, false); } }
internal ClusterDef(BorderInfo lbi, BorderInfo rbi, BorderInfo tbi, BorderInfo bbi) : this(0.0, 0.0, lbi, rbi, tbi, bbi) { }
private static Row CreateTableRow(string text, HorizontalAlignment alignment, BorderInfo borderInfo) { //// Add the header Rows. var reportHeadingRow = new Row(); reportHeadingRow.Cells.Add(text); reportHeadingRow.Cells[0].ColSpan = ReportConstants.ColumnSpan; reportHeadingRow.Cells[0].Alignment = alignment; reportHeadingRow.Border = borderInfo; return reportHeadingRow; }
private static Border GetNewBorder(BorderInfo borderInfo, Boolean ignoreMod = true) { var border = new Border(); if (borderInfo.Border.DiagonalUpModified || ignoreMod) border.DiagonalUp = borderInfo.Border.DiagonalUp; if (borderInfo.Border.DiagonalDownModified || ignoreMod) border.DiagonalDown = borderInfo.Border.DiagonalDown; if (borderInfo.Border.LeftBorderModified || borderInfo.Border.LeftBorderColorModified || ignoreMod) { var leftBorder = new LeftBorder {Style = borderInfo.Border.LeftBorder.ToOpenXml()}; if (borderInfo.Border.LeftBorderColorModified || ignoreMod) { var leftBorderColor = GetNewColor(borderInfo.Border.LeftBorderColor); leftBorder.AppendChild(leftBorderColor); } border.AppendChild(leftBorder); } if (borderInfo.Border.RightBorderModified || borderInfo.Border.RightBorderColorModified || ignoreMod) { var rightBorder = new RightBorder {Style = borderInfo.Border.RightBorder.ToOpenXml()}; if (borderInfo.Border.RightBorderColorModified || ignoreMod) { var rightBorderColor = GetNewColor(borderInfo.Border.RightBorderColor); rightBorder.AppendChild(rightBorderColor); } border.AppendChild(rightBorder); } if (borderInfo.Border.TopBorderModified || borderInfo.Border.TopBorderColorModified || ignoreMod) { var topBorder = new TopBorder {Style = borderInfo.Border.TopBorder.ToOpenXml()}; if (borderInfo.Border.TopBorderColorModified || ignoreMod) { var topBorderColor = GetNewColor(borderInfo.Border.TopBorderColor); topBorder.AppendChild(topBorderColor); } border.AppendChild(topBorder); } if (borderInfo.Border.BottomBorderModified || borderInfo.Border.BottomBorderColorModified || ignoreMod) { var bottomBorder = new BottomBorder {Style = borderInfo.Border.BottomBorder.ToOpenXml()}; if (borderInfo.Border.BottomBorderColorModified || ignoreMod) { var bottomBorderColor = GetNewColor(borderInfo.Border.BottomBorderColor); bottomBorder.AppendChild(bottomBorderColor); } border.AppendChild(bottomBorder); } if (borderInfo.Border.DiagonalBorderModified || borderInfo.Border.DiagonalBorderColorModified || ignoreMod) { var DiagonalBorder = new DiagonalBorder {Style = borderInfo.Border.DiagonalBorder.ToOpenXml()}; if (borderInfo.Border.DiagonalBorderColorModified || ignoreMod) { var DiagonalBorderColor = GetNewColor(borderInfo.Border.DiagonalBorderColor); DiagonalBorder.AppendChild(DiagonalBorderColor); } border.AppendChild(DiagonalBorder); } return border; }
private static Row CreateTableRow(string text, HorizontalAlignment alignment, BorderInfo borderInfo) { //// Add the header Rows. var reportHeadingRow = new Row(); reportHeadingRow.Cells.Add(text); reportHeadingRow.Cells[0].ColSpan = ReportConstants.ColumnSpan; reportHeadingRow.Cells[0].Alignment = alignment; reportHeadingRow.Border = borderInfo; return(reportHeadingRow); }
private BorderCharacter(BorderInfo borderInfo, Point location) { _borderInfo = borderInfo; _location = location; }
public void MergeWith(BorderCharacter other) { _borderInfo |= other._borderInfo; }