本文整理汇总了C#中Microsoft.Msagl.Core.Geometry.Rectangle类的典型用法代码示例。如果您正苦于以下问题:C# Rectangle类的具体用法?C# Rectangle怎么用?C# Rectangle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Rectangle类属于Microsoft.Msagl.Core.Geometry命名空间,在下文中一共展示了Rectangle类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: MinimumSizeIsRespected
public void MinimumSizeIsRespected()
{
// Setup
string filePath = Path.Combine(this.TestContext.TestDir, "Out\\Dots", "chat.dot");
GeometryGraph graph = this.LoadGraph(filePath);
const double DesiredHeight = 100000;
const double DesiredWidth = 100000;
SugiyamaLayoutSettings settings = new SugiyamaLayoutSettings();
settings.MinimalHeight = DesiredHeight;
settings.MinimalWidth = DesiredWidth;
// Execute
LayeredLayout layeredLayout = new LayeredLayout(graph, settings);
layeredLayout.Run();
// Verify the graph is the correct size
Assert.IsTrue(DesiredHeight < graph.Height, "Graph height should be the minimal height.");
Assert.IsTrue(DesiredWidth < graph.Width, "Graph width should be the minimal width.");
// Verify the nodes were spread apart to fill the space
Rectangle nodeBounds = new Rectangle(graph.Nodes.Select(n => n.BoundingBox));
Assert.IsTrue(DesiredWidth < nodeBounds.Height, "The graph nodes weren't scaled vertically to fill the space.");
Assert.IsTrue(DesiredWidth < nodeBounds.Width, "The graph nodes weren't scaled horizontally to fill the space.");
}
开发者ID:WenzCao,项目名称:automatic-graph-layout,代码行数:26,代码来源:MinimumWidthHeightTests.cs
示例2: PreGraph
internal PreGraph(EdgeGeometry[] egs, Set<ICurve> nodeBoundaries) {
edgeGeometries = new List<EdgeGeometry>(egs);
this.nodeBoundaries = new Set<ICurve>(nodeBoundaries);
boundingBox = Rectangle.CreateAnEmptyBox();
foreach (var curve in nodeBoundaries)
boundingBox.Add(curve.BoundingBox);
}
开发者ID:danielskowronski,项目名称:network-max-flow-demo,代码行数:7,代码来源:PreGraph.cs
示例3: AddToAdjacentVertex
internal void AddToAdjacentVertex(TransientGraphUtility transUtil
, VisibilityVertex targetVertex, Directions dirToExtend, Rectangle limitRect) {
if (!PointComparer.Equal(this.Point, targetVertex.Point)) {
transUtil.FindOrAddEdge(this.Vertex, targetVertex, InitialWeight);
}
ExtendEdgeChain(transUtil, targetVertex, dirToExtend, limitRect);
}
开发者ID:danielskowronski,项目名称:network-max-flow-demo,代码行数:7,代码来源:FreePoint.cs
示例4: InteriorEdgeCrossesObstacle
private bool InteriorEdgeCrossesObstacle(ObstacleTree obstacleTree) {
// File Test: Nudger_Overlap4
// Use the VisibilityBoundingBox for groups because those are what the tree consists of.
var rect = new Rectangle(this.UnpaddedBorderIntersect, this.VisibilityBorderIntersect);
return InteriorEdgeCrossesObstacle(rect, obs => obs.VisibilityPolyline,
obstacleTree.Root.GetLeafRectangleNodesIntersectingRectangle(rect)
.Where(node => !node.UserData.IsGroup && (node.UserData != this.Obstacle)).Select(node => node.UserData));
}
开发者ID:danielskowronski,项目名称:network-max-flow-demo,代码行数:8,代码来源:ObstaclePortEntrance.cs
示例5: GridTraversal
public GridTraversal(Rectangle boundingBox, int iLevel)
{
_boundingBox = boundingBox;
_iLevel = iLevel;
_numberOfTilesOnSide = (ulong)Math.Pow(2, iLevel);
TileWidth = boundingBox.Width / _numberOfTilesOnSide;
TileHeight = boundingBox.Height / _numberOfTilesOnSide;
}
开发者ID:danielskowronski,项目名称:network-max-flow-demo,代码行数:8,代码来源:GridTraversal.cs
示例6: CommonArea
static double CommonArea(ref Rectangle a, ref Rectangle b)
{
double l = Math.Min(a.Left, b.Left);
double r = Math.Max(a.Right, b.Right);
double t = Math.Max(a.Top, b.Top);
double bt = Math.Min(a.Bottom, b.Bottom);
return (r - l) * (t - bt);
}
开发者ID:mrkcass,项目名称:SuffixTreeExplorer,代码行数:8,代码来源:LocationLabeler.cs
示例7: IntersectsOnY
internal bool IntersectsOnY(Rectangle r){
if (r.Bottom > top + ApproximateComparer.DistanceEpsilon)
return false;
if (r.Top < bottom - ApproximateComparer.DistanceEpsilon)
return false;
return true;
//return ApproximateComparer.Compare(r.bottom, top) <= 0 && ApproximateComparer.Compare(bottom, r.top) <= 0;
}
开发者ID:danielskowronski,项目名称:network-max-flow-demo,代码行数:10,代码来源:Rectangle.cs
示例8: Area
/// <summary>
/// Additionally needed area of nodes compared to the optimal packing of the nodes.
/// </summary>
/// <param name="graphOriginal"></param>
/// <param name="graphNew"></param>
/// <returns></returns>
public static Tuple<String, double> Area(GeometryGraph graph)
{
double minimalArea = graph.Nodes.Sum(v => v.BoundingBox.Area);
Rectangle boundingBoxNew=new Rectangle(graph.Nodes.Select(v=>v.BoundingBox));
double areaNew = boundingBoxNew.Area;
double ratio = areaNew/minimalArea;
// return Tuple.Create("AreaIncreaseToMinPacking",ratio - 1);//we are interested in increase compared to optimal packing.
return Tuple.Create("AreaAbsolute/(1E6)", areaNew / (1E6));//we are interested in increase compared to optimal packing.
}
开发者ID:mrkcass,项目名称:SuffixTreeExplorer,代码行数:17,代码来源:Statistics.cs
示例9: GetInitialBoundingBox
public Rectangle GetInitialBoundingBox() {
Rectangle bbox = new Rectangle();
bbox.SetToEmpty();
foreach (var rect in _fixedRectangles) {
bbox.Add(rect);
}
foreach (var rect in _moveableRectangles) {
bbox.Add(rect);
}
return bbox;
}
开发者ID:danielskowronski,项目名称:network-max-flow-demo,代码行数:11,代码来源:OverlapRemovalFixedSegmentsBitmap.cs
示例10: IntersectsOnX
internal bool IntersectsOnX(Rectangle r){
//return ApproximateComparer.Compare(r.left, right) <= 0 && ApproximateComparer.Compare(left, r.right) <= 0;
if (r.Left > right + ApproximateComparer.DistanceEpsilon)
return false;
if (r.Right < left - ApproximateComparer.DistanceEpsilon)
return false;
return true;
//return ApproximateComparer.Compare(r.left, right) <= 0 && ApproximateComparer.Compare(left, r.right) <= 0;
}
开发者ID:danielskowronski,项目名称:network-max-flow-demo,代码行数:12,代码来源:Rectangle.cs
示例11: AddEdgeToAdjacentEdge
// Adds an edge from this.Vertex to a (possibly new) vertex at an intersection with an
// existing Edge that adjoins the point. We take 'dir' as an input parameter for edge
// extension because we may be on the edge so can't calculate the direction.
internal VisibilityVertex AddEdgeToAdjacentEdge(TransientGraphUtility transUtil
, VisibilityEdge targetEdge, Directions dirToExtend, Rectangle limitRect) {
Point targetIntersect = StaticGraphUtility.SegmentIntersection(targetEdge, this.Point);
VisibilityVertex targetVertex = transUtil.VisGraph.FindVertex(targetIntersect);
if (null != targetVertex) {
AddToAdjacentVertex(transUtil, targetVertex, dirToExtend, limitRect);
}
else {
targetVertex = transUtil.AddEdgeToTargetEdge(this.Vertex, targetEdge, targetIntersect);
}
ExtendEdgeChain(transUtil, targetVertex, dirToExtend, limitRect);
return targetVertex;
}
开发者ID:danielskowronski,项目名称:network-max-flow-demo,代码行数:16,代码来源:FreePoint.cs
示例12: OverlapRemovalFixedSegmentsBitmap
public OverlapRemovalFixedSegmentsBitmap(Rectangle[] moveableRectangles, Rectangle[] fixedRectangles,
SymmetricSegment[] fixedSegments) {
_moveableRectangles = moveableRectangles;
_fixedRectangles = fixedRectangles;
_fixedSegments = fixedSegments;
_bbox = GetInitialBoundingBox();
_bbox.ScaleAroundCenter(1.25);
InitBitmap();
InitTransform();
movedRectangles = new Rectangle[moveableRectangles.Length];
}
开发者ID:danielskowronski,项目名称:network-max-flow-demo,代码行数:14,代码来源:OverlapRemovalFixedSegmentsBitmap.cs
示例13: Intersection
/// <summary>
/// intersection (possibly empty) of rectangles
/// </summary>
/// <param name="rectangle"></param>
/// <returns></returns>
public Rectangle Intersection(Rectangle rectangle)
{
Rectangle intersection = new Rectangle();
if (!Intersects(rectangle))
{
intersection.SetToEmpty();
return intersection;
}
double l = Math.Max(Left, rectangle.Left);
double r = Math.Min(Right, rectangle.Right);
double b = Math.Max(Bottom, rectangle.Bottom);
double t = Math.Min(Top, rectangle.Top);
return new Rectangle(l,b,r,t);
}
开发者ID:danielskowronski,项目名称:network-max-flow-demo,代码行数:19,代码来源:Rectangle.cs
示例14: PlaceNodesOnly
public void PlaceNodesOnly(Rectangle bbox)
{
BoundingBox = bbox;
int numInserted = 0;
int level = 1;
int iLevel = 0;
while (numInserted < SortedLgNodeInfos.Count && level <= MaxLevel) {
numInserted = DrawNodesOnlyOnLevel(level, numInserted);
AddAllToNodeLevel(iLevel);
level *= 2;
iLevel++;
}
}
开发者ID:danielskowronski,项目名称:network-max-flow-demo,代码行数:14,代码来源:GreedyNodeRailLevelCalculator.cs
示例15: AddVoronoiCite
void AddVoronoiCite(CdtTriangle triangle)
{
Point p;
var goodTriangle = GetCenterOfDescribedCircle(triangle, out p);
if (!goodTriangle)
return;
if (!BoundingBox.Contains(p))
return;
var rect=new Rectangle(p);
rect.Pad(eps);
if (voronoiSiteTree.GetAllIntersecting(rect).Count() > 0)
return;
voronoiSiteTree.Add(rect, p);
}
开发者ID:WenzCao,项目名称:automatic-graph-layout,代码行数:15,代码来源:Program.cs
示例16: VerifyAspectRatio
/// <summary>
/// Verifies that the graph conforms to the correct aspect ratio.
/// </summary>
private static void VerifyAspectRatio(GeometryGraph graph, double aspectRatio)
{
double ratioTolerance = aspectRatio * 0.05;
// Verify the graph is the correct size
Assert.AreEqual(aspectRatio, (graph.Width-(graph.Margins*2)) / (graph.Height-(graph.Margins*2)), ratioTolerance, "The graph does not conform to the aspect ratio.");
// Verify the nodes were spread apart to fill the space
IEnumerable<Rectangle> nodeBoxes = graph.Nodes.Select(n => n.BoundingBox);
IEnumerable<Rectangle> edgeBoxes = graph.Edges.Select(e => e.BoundingBox);
IEnumerable<Rectangle> labelBoxes = graph.CollectAllLabels().Select(l => l.BoundingBox);
Rectangle itemBounds = new Rectangle(nodeBoxes.Concat(edgeBoxes).Concat(labelBoxes));
Assert.AreEqual(aspectRatio, itemBounds.Width / itemBounds.Height, ratioTolerance, "The graph's nodes do not conform to the aspect ratio.");
}
开发者ID:WenzCao,项目名称:automatic-graph-layout,代码行数:18,代码来源:AspectRatioTests.cs
示例17: GetOutCode
public static int GetOutCode(Rectangle rect, Point p) {
int code = INSIDE;
if (p.X < rect.Left)
code |= LEFT;
else if (p.X > rect.Right)
code |= RIGHT;
if (p.Y < rect.Bottom)
code |= BOTTOM;
else if (p.Y > rect.Top)
code |= TOP;
return code;
}
开发者ID:danielskowronski,项目名称:network-max-flow-demo,代码行数:15,代码来源:RectSegIntersection.cs
示例18: RunTest2
public static void RunTest2() {
Point p1, p2;
Rectangle rect1 = new Rectangle(1, 1, 4, 4);
Point pc1, pc2;
double a;
p1 = new Point(-1, 0);
p2 = new Point(2, 3);
RectSegIntersection.ClipOnRect(rect1, p1, p2, out pc1, out pc2);
a = RectSegIntersection.GetOverlapAmount(rect1, p1, p2);
p1 = new Point(1, 0);
p2 = new Point(5, 4);
a = RectSegIntersection.GetOverlapAmount(rect1, p1, p2);
p1 = new Point(0, 4);
p2 = new Point(4, 0);
a = RectSegIntersection.GetOverlapAmount(rect1, p1, p2);
p1 = new Point(0, 4);
p2 = new Point(4, 0);
a = RectSegIntersection.GetOverlapAmount(rect1, p1, p2);
p1 = new Point(1, 5);
p2 = new Point(5, 1);
a = RectSegIntersection.GetOverlapAmount(rect1, p1, p2);
p1 = new Point(0, 1);
p2 = new Point(5, 4);
a = RectSegIntersection.GetOverlapAmount(rect1, p1, p2);
p1 = new Point(-1, 3);
p2 = new Point(2, 6);
a = RectSegIntersection.GetOverlapAmount(rect1, p1, p2);
bool intersect;
p1 = new Point(-1, 3);
p2 = new Point(2, 6);
intersect = RectSegIntersection.Intersect(rect1, p1, p2);
p1 = new Point(1, 2);
p2 = new Point(1, 3);
intersect = RectSegIntersection.Intersect(rect1, p1, p2);
a = RectSegIntersection.GetOverlapAmount(rect1, p1, p2);
}
开发者ID:WenzCao,项目名称:automatic-graph-layout,代码行数:48,代码来源:Test1.cs
示例19: PositionElement
internal static void PositionElement(FrameworkElement fe, Rectangle object_box, Rectangle bounding_box, double scale)
{
Microsoft.Msagl.Core.Geometry.Point origin = bounding_box.Center;
double desiredH = object_box.Height * scale - fe.Margin.Top - fe.Margin.Bottom,
desiredW = object_box.Width * scale + fe.Margin.Left + fe.Margin.Right;
if (bounding_box.Height < desiredH)
{
origin.Y += object_box.Center.Y * scale - fe.Margin.Top;
}
else
{
if (fe.VerticalAlignment == VerticalAlignment.Top)
{
origin.Y = bounding_box.Top;
}
else if (fe.VerticalAlignment == VerticalAlignment.Bottom)
{
origin.Y -= bounding_box.Height / 2 - object_box.Height * scale;
}
else
{
origin.Y += object_box.Center.Y * scale;
}
}
if (bounding_box.Width < desiredW)
{
origin.X -= object_box.Center.X * scale;
}
else
{
if (fe.HorizontalAlignment == HorizontalAlignment.Left)
{
origin.X -= bounding_box.Width / 2 - fe.Margin.Left;
}
else if (fe.HorizontalAlignment == HorizontalAlignment.Right)
{
origin.X -= bounding_box.Width / 2 - object_box.Width * scale;
}
else
{
origin.X -= object_box.Center.X * scale;
}
}
PositionElement(fe, origin, scale);
}
开发者ID:mrkcass,项目名称:SuffixTreeExplorer,代码行数:46,代码来源:CommonX.cs
示例20: RunTest1
public static void RunTest1() {
Rectangle rect1 = new Rectangle(0, 0, 2, 2);
Rectangle rect2 = new Rectangle(3, 3, 4, 4);
Rectangle rect3 = new Rectangle(4, 1, 5, 2);
Rectangle[] moveableRectangles = {rect1, rect2, rect3};
Rectangle[] fixedRectangles = {};
SymmetricSegment[] fixedSegments = {};
OverlapRemovalFixedSegmentsMst orfs = new OverlapRemovalFixedSegmentsMst(moveableRectangles, fixedRectangles,
fixedSegments);
orfs.InitCdt();
double dist = orfs.GetDistance(rect1, rect2);
var mstEdges = orfs.GetMstFromCdt();
}
开发者ID:WenzCao,项目名称:automatic-graph-layout,代码行数:17,代码来源:Test1.cs
注:本文中的Microsoft.Msagl.Core.Geometry.Rectangle类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论