public override IVisual CreateVisual(IRenderContext context) { VisualGroup container = new VisualGroup(); var bounds = Bounds; var width = bounds.Width; var height = bounds.Height; var cornerSize = Math.Min(width, height) * 0.4; var path = new GeneralPath(); path.MoveTo(0, 0); path.LineTo(width - cornerSize, 0); path.LineTo(width, cornerSize); path.LineTo(width, height); path.LineTo(0, height); path.Close(); container.Add(new GeneralPathVisual(path) { Brush = Brush, Pen = Pen }); path = new GeneralPath(); path.MoveTo(width - cornerSize, 0); path.LineTo(width - cornerSize, cornerSize); path.LineTo(width, cornerSize); container.Add(new GeneralPathVisual(path) { Brush = null, Pen = Pen }); container.Transform = new Matrix(1, 0, 0, 1, (float)Bounds.X, (float)Bounds.Y); return(container); }
private Shape getProjectedClip() { if (projectedClip == null) { if (clip == null) { return(null); } Shape s = new Rectangle(clip.getX(), clip.getY(), clip.getWidth(), clip.getHeight()); if (clipTransform != null && !clipTransform.isIdentity()) { GeneralPath p = new GeneralPath(); p.setShape(s, clipTransform.getInverse()); s = p; } if (transform != null && !transform.isIdentity()) { GeneralPath p = new GeneralPath(); p.setShape(s, transform); s = p; } projectedClip = s; } return(projectedClip); }
/// <summary> /// Creates the visual appearance of an edge /// </summary> private void Render(IRenderContext context, IEdge edge, VisualGroup container, RenderDataCache cache) { // store information with the visual on how we created it container.SetRenderDataCache(cache); GeneralPath gp = cache.GeneralPath; Path path = new Path { // convince WPF to render the path even if all coordinates are negative Stretch = Stretch.None, MinWidth = 1, MinHeight = 1, Data = CreateGeometry(gp) }; // set the stroke path.Stroke = pathStroke; path.StrokeThickness = cache.PathThickness; path.StrokeLineJoin = PenLineJoin.Round; container.Add(path); // add the arrows to the container base.AddArrows(context, container, edge, gp, cache.Arrows, cache.Arrows); }
public void CreateCustomBridge(IRenderContext context, GeneralPath path, PointD start, PointD end, double gapLength) { // first finish the last segment path.LineTo(start); // then calculate the gap var vectorLength = gapLength; if (vectorLength > 1) { // some helper vectors first var delta = end - start; var rightVector = delta / vectorLength; var upVector = new PointD(rightVector.Y, -rightVector.X); // get the height from the context double height = GetBridgeHeight(context); // determine bending for our arc double arc = 3; // now draw two arcs at the end and the start of the segment path.MoveTo(start + upVector * height - rightVector * arc); path.QuadTo(start + rightVector * arc, start + upVector * -height - rightVector * arc); path.MoveTo(end + rightVector * arc + upVector * height); path.QuadTo(end - rightVector * arc, end + upVector * -height + rightVector * arc); // finally make sure that the edge continues at the right location path.MoveTo(end); } else { // for very short gaps, we use a trivial rendering path.LineTo(start); path.MoveTo(end); } }
public void Update(GeneralPath path, double pathThickness, Color color) { if (this.path == null || !this.path.Equals(path)) { this.graphicsPath = path.CreatePath(new Matrix()); } this.path = path; this.pathThickness = (float)pathThickness; if (!this.color.Equals(color)) { brush = new LinearGradientBrush(new Point(0, 0), new Point(200, 200), Color.FromArgb((byte)Math.Max(0, color.A - 50), (byte)Math.Min(255, color.R * 1.7), (byte)Math.Min(255, color.G * 1.7), (byte)Math.Min(255, color.B * 1.7)), Color.FromArgb((byte)Math.Max(0, color.A - 50), (byte)Math.Min(255, color.R * 1.4), (byte)Math.Min(255, color.G * 1.4), (byte)Math.Min(255, color.B * 1.4))) { WrapMode = WrapMode.TileFlipXY }; } this.color = color; }
//////////////////////////////////////////////////// //////////////// New in this sample //////////////// //////////////////////////////////////////////////// /// <summary> /// Decorates a given path with bridges. /// </summary> /// <remarks> /// All work is delegated to the BridgeManager's addBridges() method. /// </remarks> /// <param name="path">The path to decorate.</param> /// <param name="context">The render context.</param> /// <returns>A copy of the given path with bridges.</returns> private GeneralPath CreatePathWithBridges(GeneralPath path, IRenderContext context) { var manager = GetBridgeManager(context); // if there is a bridge manager registered: use it to add the bridges to the path return(manager == null ? path : manager.AddBridges(context, path, null)); }
public XYAreaRenderer(int type, XYToolTipGenerator toolTipGenerator, XYURLGenerator urlGenerator) { XYAreaRenderer xyAreaRenderer = this; this.setBaseToolTipGenerator(toolTipGenerator); this.setURLGenerator(urlGenerator); if (type == 1) this.plotShapes = true; if (type == 2) this.plotLines = true; if (type == 3) { this.plotShapes = true; this.plotLines = true; } if (type == 4) this.plotArea = true; if (type == 5) { this.plotArea = true; this.plotShapes = true; } this.showOutline = false; GeneralPath generalPath = new GeneralPath(); ((Path2D.Float) generalPath).moveTo(0.0f, -4f); ((Path2D.Float) generalPath).lineTo(3f, -2f); ((Path2D.Float) generalPath).lineTo(4f, 4f); ((Path2D.Float) generalPath).lineTo(-4f, 4f); ((Path2D.Float) generalPath).lineTo(-3f, -2f); ((Path2D) generalPath).closePath(); this.legendArea = (Shape) generalPath; }
/// <summary> /// Runs a layout algorithm which is configured to consider node rotations. /// </summary> public async Task ApplyLayout() { var graph = graphControl.Graph; // provide the rotated outline and layout for the layout algorithm graph.MapperRegistry.CreateDelegateMapper(RotatedNodeLayoutStage.RotatedNodeLayoutDpKey, node => { var style = node.Style; var outline = style.Renderer.GetShapeGeometry(node, style).GetOutline(); if (outline == null) { outline = new GeneralPath(4); outline.AppendRectangle(node.Layout.ToRectD(), false); } return(new RotatedNodeLayoutStage.RotatedNodeShape(outline, style is RotatableNodeStyleDecorator ? ((RotatableNodeStyleDecorator)style).GetRotatedLayout(node) : (IOrientedRectangle) new OrientedRectangle(node.Layout))); }); // get the selected layout algorithm var layout = GetLayoutAlgorithm(); // wrap the algorithm in RotatedNodeLayoutStage to make it aware of the node rotations var rotatedLayout = new RotatedNodeLayoutStage(layout) { EdgeRoutingMode = GetRoutingMode() }; // apply the layout await graphControl.MorphLayout(rotatedLayout, TimeSpan.FromMilliseconds(700)); // clean up mapper registry graph.MapperRegistry.RemoveMapper(RotatedNodeLayoutStage.RotatedNodeLayoutDpKey); }
override protected void CollectGridSnapResults(GraphSnapContext context, CollectSnapResultsEventArgs args, RectD suggestedLayout, INode node) { // node.Layout isn't updated, yet, so we have to calculate the delta between the the new suggested layout and the current node.Layout PointD delta = suggestedLayout.TopLeft - node.Layout.GetTopLeft(); // get outline of the shape and iterate over it's path point IShapeGeometry geometry = node.Style.Renderer.GetShapeGeometry(node, node.Style); GeneralPath outline = geometry.GetOutline(); if (outline != null) { GeneralPath.PathCursor cursor = outline.CreateCursor(); while (cursor.MoveNext()) { // ignore PathType.Close as we had the path point as first point // and cursor.CurrentEndPoint is always (0, 0) for PathType.Close if (cursor.PathType != PathType.Close) { // adjust path point by the delta calculated above and add an according SnapResult PointD endPoint = cursor.CurrentEndPoint + delta; AddGridSnapResultCore(context, args, endPoint, node, GridSnapTypes.GridPoints, SnapPolicy.ToNearest, SnapPolicy.ToNearest); } } } }
public RenderDataCache(double pathThickness, bool selected, GeneralPath generalPath, IArrow arrows) { PathThickness = pathThickness; Selected = selected; GeneralPath = generalPath; Arrows = arrows; }
/// <summary> /// Creates the geometry for the path from the given GeneralPath. /// </summary> private Geometry CreateGeometry(GeneralPath gp) { PolyLineSegment pl = new PolyLineSegment(); PathFigure figure = new PathFigure { Segments = { pl } }; // create path if (gp != null) { var cursor = gp.CreateCursor(); if (cursor.MoveNext()) { figure.StartPoint = cursor.CurrentEndPoint; } // loop all bends of the edge while (cursor.MoveNext()) { pl.Points.Add(cursor.CurrentEndPoint); } } return(new PathGeometry { Figures = { figure } }); }
protected override GeneralPath CreatePath(IStripe stripe, IRectangle layout) { var column = (IColumn)stripe; GeneralPath outline = new GeneralPath(); //Left border: outline.MoveTo(0, 0); outline.LineTo(layout.Width, 0); outline.LineTo(layout.Width + WedgeWidth, WedgeHeight); outline.LineTo(layout.Width, 2 * WedgeHeight); outline.LineTo(layout.Width, layout.Height); outline.LineTo(0, layout.Height); if (IsFirst(column)) { outline.Close(); } else { outline.LineTo(0, layout.Height); outline.LineTo(0, 2 * WedgeHeight); outline.LineTo(WedgeWidth, WedgeHeight); outline.Close(); } return(outline); }
/// <summary> /// Returns the outline of the node. /// </summary> /// <remarks> /// Overriding this method will yield proper hit tests and edge intersection tests. /// </remarks> /// <param name="node"></param> /// <returns></returns> protected override GeneralPath GetOutline(INode node) { var path = new GeneralPath(); path.AppendEllipse(node.Layout, false); return(path); }
internal virtual void setClip(ui.geom.Rectangle clip) { removeClip(); if (clip == null) { return; } if (clip.getWidth() <= 0) { // System.Diagnostics.Debug.WriteLine("aaaaaaaaaaaaaaaaaaaa width"); clip.setWidth(1); } if (clip.getHeight() <= 0) { // System.Diagnostics.Debug.WriteLine("aaaaaaaaaaaaaaaaaaaa height"); clip.setHeight(1); } if (transform != null && !transform.isIdentity()) { GeneralPath gp = new GeneralPath(); gp.setShape(clip, transform); layer = graphics.CreateLayer(1f, CanvasGeometry.CreatePath(SilverlightImplementation.instance.cn1ShapeToAndroidPath(gp))); } else { layer = graphics.CreateLayer(1f, new Rect( clip.getX(), clip.getY(), clip.getWidth(), clip.getHeight() )); } }
public override Visual CreateVisual(IRenderContext context) { VisualGroup container = new VisualGroup(); var bounds = Bounds; var width = bounds.Width; var height = bounds.Height; var cornerSize = Math.Min(width, height) * 0.4; var path = new GeneralPath(); path.MoveTo(0, 0); path.LineTo(width - cornerSize, 0); path.LineTo(width, cornerSize); path.LineTo(width, height); path.LineTo(0, height); path.Close(); container.Add(path.CreatePath(Brush, Pen, new Matrix2D(), FillMode.Always)); path = new GeneralPath(); path.MoveTo(width - cornerSize, 0); path.LineTo(width - cornerSize, cornerSize); path.LineTo(width, cornerSize); container.Add(path.CreatePath(null, Pen, new Matrix2D(), FillMode.Never)); container.SetRenderDataCache(new PathIconState(width, height, Pen, Brush)); container.SetCanvasArrangeRect(bounds.ToRectD()); return(container); }
public override Visual CreateVisual(IRenderContext context) { VisualGroup container = new VisualGroup(); var bounds = Bounds; var width = bounds.Width; var height = bounds.Height; var path = new GeneralPath(); path.MoveTo(0, TopLeftRadius); path.QuadTo(0, 0, TopLeftRadius, 0); path.LineTo(width - TopRightRadius, 0); path.QuadTo(width, 0, width, TopRightRadius); path.LineTo(width, height - BottomRightRadius); path.QuadTo(width, height, width - BottomRightRadius, height); path.LineTo(BottomLeftRadius, height); path.QuadTo(0, height, 0, height - BottomRightRadius); path.Close(); var pathVisual = path.CreatePath(Brush, Pen, new Matrix2D(), FillMode.Always); container.Add(pathVisual); container.SetRenderDataCache(new PathIconState(width, height, Pen, Brush)); container.SetCanvasArrangeRect(bounds.ToRectD()); return(container); }
private Bounds CreateArrow(double minWidth, double minHeight) { var arrow = new Bounds(); var headThickness = minHeight / 3; var inset = 0.8; var headLength = minHeight; switch (direction) { case ReactionDirection.Forward: { var fp = new PathFigure(); arrow.Add(new LineElement(new Point(0, 0), new Point(minWidth - 0.5 * headLength, 0), minHeight / 14, fgcol)); fp.StartPoint = new Point(minWidth, 0); fp.Segments.Add(new LineSegment(new Point(minWidth - headLength, +headThickness), true)); fp.Segments.Add(new LineSegment(new Point(minWidth - inset * headLength, 0), true)); fp.Segments.Add(new LineSegment(new Point(minWidth - headLength, -headThickness), true)); fp.IsClosed = true; var path = new PathGeometry(new[] { fp }); arrow.Add(GeneralPath.ShapeOf(path, fgcol)); } break; case ReactionDirection.Backward: { var fp = new PathFigure(); arrow.Add(new LineElement(new Point(0.5 * headLength, 0), new Point(minWidth, 0), minHeight / 14, fgcol)); fp.StartPoint = new Point(0, 0); fp.Segments.Add(new LineSegment(new Point(minHeight, +headThickness), true)); fp.Segments.Add(new LineSegment(new Point(minHeight - (1 - inset) * minHeight, 0), true)); fp.Segments.Add(new LineSegment(new Point(minHeight, -headThickness), true)); fp.IsClosed = true; var path = new PathGeometry(new[] { fp }); arrow.Add(GeneralPath.ShapeOf(path, fgcol)); } break; case ReactionDirection.Bidirectional: // equilibrium? { var fp1 = new PathFigure { StartPoint = new Point(0, 0.5 * +headThickness) }; fp1.Segments.Add(new LineSegment(new Point(minWidth + minHeight + minHeight, 0.5 * +headThickness), true)); fp1.Segments.Add(new LineSegment(new Point(minWidth + minHeight, 1.5 * +headThickness), true)); var fp2 = new PathFigure { StartPoint = new Point(minWidth + minHeight + minHeight, 0.5 * -headThickness) }; fp2.Segments.Add(new LineSegment(new Point(0, 0.5 * -headThickness), true)); fp2.Segments.Add(new LineSegment(new Point(minHeight, 1.5 * -headThickness), true)); var path = new PathGeometry(new[] { fp1, fp2 }); arrow.Add(GeneralPath.OutlineOf(path, minHeight / 14, fgcol)); } break; } return(arrow); }
public RenderDataCache(double pathThickness, bool selected, GeneralPath generalPath, IArrow arrows, long obstacleHash) { this.obstacleHash = obstacleHash; PathThickness = pathThickness; Selected = selected; GeneralPath = generalPath; Arrows = arrows; }
/// <summary> /// Gets the outline of the node, an ellipse in this case /// </summary> /// <remarks> /// This allows for correct edge path intersection calculation, among others. /// </remarks> protected override GeneralPath GetOutline(INode node) { var rect = node.Layout.ToRectD(); var outline = new GeneralPath(); outline.AppendEllipse(rect, false); return(outline); }
private GeneralPath GetGeneralPath() { PathIterator iter = getPathIterator(null); GeneralPath path = new GeneralPath(); path.append(iter, false); return(path); }
/// <summary> /// Creates an <see cref="IVisual"/> which renders the label. /// </summary> /// <remarks> /// Adds separate visuals for background and text in a VisualGroup. /// Delegates to method <see cref="LabelStyleBase{TVisual}.GetTransform"/> /// to get a valid transform for the label. /// </remarks> /// <param name="context">The Render Context.</param> /// <param name="label">The label to render.</param> /// <returns>A visual which renders the label.</returns> protected override VisualGroup CreateVisual(IRenderContext context, ILabel label) { var layout = label.GetLayout(); // don't render invisible labels if (layout.Width < 0 || layout.Height < 0) { return(null); } var group = new VisualGroup(); // convert to convenient coordinate space group.Transform = GetTransform(context, layout, true); // Draw the label background as a rounded rectangle GeneralPath gp = new GeneralPath(10); double xRad = layout.Width / 4; double yRad = layout.Height / 10; gp.MoveTo(0, yRad); gp.QuadTo(0, 0, xRad, 0); gp.LineTo(layout.Width - xRad, 0); gp.QuadTo(layout.Width, 0, layout.Width, yRad); gp.LineTo(layout.Width, layout.Height - yRad); gp.QuadTo(layout.Width, layout.Height, layout.Width - xRad, layout.Height); gp.LineTo(xRad, layout.Height); gp.QuadTo(0, layout.Height, 0, layout.Height - yRad); gp.Close(); var pathVisual = new GeneralPathVisual(gp) { Brush = new SolidBrush(Color.FromArgb(255, 240, 248, 255)), Pen = Pens.SkyBlue }; group.Add(pathVisual); // Draw the label's text if (context.Zoom >= buttonZoomThreshold) { // draw the action button group.Add(new ImageVisual { Image = Resources.edit_label, Rectangle = new RectD(layout.Width - (inset + buttonWidth), inset, buttonWidth, layout.Height - inset * 2) }); group.Add(new TextVisual { Text = label.Text, Font = Font, Brush = Brushes.Black, Location = PointD.Origin }); } else { group.Add(new TextVisual { Text = label.Text, Font = Font, Brush = Brushes.Black, Location = new PointD((buttonWidth + 2 * inset) * 0.5, 0) }); } return(group); }
private IRenderingElement GenerateAbbreviationSgroup(IAtomContainer mol, Sgroup sgroup) { string label = sgroup.Subscript; // already handled by symbol remapping if (sgroup.Bonds.Count > 0 || string.IsNullOrEmpty(label)) { return(new ElementGroup()); } if (!CheckAbbreviationHighlight(mol, sgroup)) { return(new ElementGroup()); } // we're showing a label where there were no atoms before, we put it in the // middle of all of those which were hidden var sgroupAtoms = sgroup.Atoms; Debug.Assert(sgroupAtoms.Any()); var highlight = sgroupAtoms.First().GetProperty <Color>(StandardGenerator.HighlightColorKey); var style = parameters.GetHighlighting(); var glowWidth = parameters.GetOuterGlowWidth(); Vector2 labelCoords = GeometryUtil.Get2DCenter(sgroupAtoms); ElementGroup labelgroup = new ElementGroup(); foreach (var outline in atomGenerator.GenerateAbbreviatedSymbol(label, HydrogenPosition.Right) .Resize(1 / scale, 1 / -scale) .GetOutlines()) { if (highlight != null && style == HighlightStyle.Colored) { labelgroup.Add(GeneralPath.ShapeOf(outline, highlight)); } else { labelgroup.Add(GeneralPath.ShapeOf(outline, foreground)); } } if (highlight != null && style == HighlightStyle.OuterGlow) { ElementGroup group = new ElementGroup { // outer glow needs to be being the label StandardGenerator.OuterGlow(labelgroup, highlight, glowWidth, stroke), labelgroup }; return(group); } else { return(MarkedElement.MarkupAtom(labelgroup, null)); } }
protected override GeneralPath GetOutline(INode node) { double size = Math.Min(node.Layout.Width, node.Layout.Height); RectD bounds = new RectD(node.Layout.GetCenter().X - size / 2, node.Layout.GetCenter().Y - size / 2, size, size); var path = new GeneralPath(); path.AppendEllipse(bounds, false); return(path); }
internal MinMaxCategoryRenderer\u00241([In] MinMaxCategoryRenderer obj0, [In] GeneralPath obj1, [In] Paint obj2, [In] Paint obj3, [In] int obj4, [In] int obj5) { base.\u002Ector(); MinMaxCategoryRenderer\u00241 categoryRenderer1 = this; this.this\u00240 = obj0; this.val\u0024path = obj1; this.val\u0024fillPaint = obj2; this.val\u0024outlinePaint = obj3; this.val\u0024width = obj4; this.val\u0024height = obj5; }
//////////////// New in this sample //////////////// // Path creation has been extracted into method CreatePath /// <summary> /// Creates a general path for the locations of the ports and the bends of the edge. /// </summary> /// <param name="edge">The edge.</param> /// <returns>A general path for the locations of the ports and the bends of the edge.</returns> private static GeneralPath CreatePath(IEdge edge) { GeneralPath path = new GeneralPath(); path.MoveTo(edge.SourcePort.GetLocation()); foreach (var bend in edge.Bends) { path.LineTo(bend.Location); } path.LineTo(edge.TargetPort.GetLocation()); return(path); }
/// <summary> /// Use the node style's outline as obstacle. /// </summary> /// <remarks>For node style renderers that don't provide a <see cref="IShapeGeometry"/>, no bridges will be created.</remarks> /// <returns></returns> private GeneralPath CreatePath() { INodeStyle style = groupNode.Style; IShapeGeometry geometry = style.Renderer.GetShapeGeometry(groupNode, style); if (geometry != null) { GeneralPath outline = geometry.GetOutline(); return(outline); } return(null); }
protected override GeneralPath GetPath(IEdge edge) { // Create a general path from the locations of the ports and the bends of the edge. GeneralPath path = new GeneralPath(); path.MoveTo(GetLocation(edge.SourcePort)); foreach (var bend in edge.Bends) { path.LineTo(bend.Location); } path.LineTo(GetLocation(edge.TargetPort)); // shorten the path in order to provide room for drawing the arrows. return base.CropPath(edge, Arrows, Arrows, path); }
public void Update(IRenderContext context, INode node) { var nodeData = node.Tag as NodeData; if (nodeData == null) { return; } if (node.Layout.ToRectD() != layout || nodeData.Geometry.Height != height || nodeData.Color != color || nodeData.Pen != pen || context.Projection != projection) { layout = node.Layout.ToRectD(); height = nodeData.Geometry.Height; color = nodeData.Color; pen = nodeData.Pen; projection = context.Projection; var corners = CalculateCorners(context.Projection, layout.X, layout.Y, layout.Width, layout.Height, height); var brush = nodeData.Brush; if (brush != null) { this.topBrush = brush; if (height > 0) { this.leftBrush = Darker(brush); this.rightBrush = Darker(leftBrush); } } if (height == 0) { leftFacePath = null; rightFacePath = null; } else if (height > 0) { // check which of the left, right, back and front faces are visible using the current projection var upVector = CalculateHeightVector(context.Projection); var useLeft = upVector.X > 0; var useBack = upVector.Y > 0; leftFacePath = useLeft ? GetLeftFacePath(corners) : GetRightFacePath(corners); rightFacePath = useBack ? GetBackFacePath(corners) : GetFrontFacePath(corners); } topFacePath = GetTopFacePath(corners); } }
protected override GeneralPath GetPath(IEdge edge) { // Create a general path from the locations of the ports and the bends of the edge. GeneralPath path = new GeneralPath(edge.Bends.Count + 2); path.MoveTo(edge.SourcePort.GetLocation()); foreach (var bend in edge.Bends) { path.LineTo(bend.Location); } path.LineTo(edge.TargetPort.GetLocation()); return(path); }
protected override VisualGroup CreateVisual(IRenderContext context, IStripe stripe) { IRectangle layout = stripe.Layout.ToRectD(); GeneralPath outline = CreatePath(stripe, layout); var visual = outline.CreatePath(StripeDescriptor.BackgroundBrush, new Pen(StripeDescriptor.BorderBrush, StripeDescriptor.BorderThickness.Left), null, FillMode.Always); var cc = new VisualGroup(); cc.Add(visual); cc.SetCanvasArrangeRect(layout.ToRectD()); return(cc); }
/// <summary> /// Creates the rendering visual. /// </summary> /// <remarks> /// An ellipse with a + or - symbol. /// </remarks> /// <param name="context">The render context.</param> /// <param name="node">The node.to render.</param> /// <returns>A visual representation.</returns> protected override VisualGroup CreateVisual(IRenderContext context, INode node) { var vg = new AggregationVisual(); var info = (AggregationNodeInfo)node.Tag; vg.HasNode = info.Aggregate.Node != null; vg.IsAggregated = info.IsAggregated; // draw a grey ellipse // if the aggregate represents a node draw a solid border. Draw a dashed border otherwise. var pen = info.Aggregate.Node == null ? new Pen(Brushes.LightGray) { DashStyle = DashStyle.Dash, DashPattern = new[] { 2f, 2f } } : Pens.LightGray; vg.Add(new EllipseVisual(new RectD(PointD.Origin, node.Layout.GetSize())) { Pen = pen, Brush = new SolidBrush(info.IsAggregated ? Color.FromArgb(0x11, 0x6c, 0x91, 0xbf) : Color.FromArgb(0x09, 0x6c, 0x91, 0xbf)) }); // draw a + if aggregated, - otherwise GeneralPath gp = new GeneralPath(); if (info.IsAggregated) { gp.MoveTo(0, -4); gp.LineTo(0, 4); gp.MoveTo(-4, 0); gp.LineTo(4, 0); } else { gp.MoveTo(-4, 0); gp.LineTo(4, 0); } gp.Transform(new Matrix2D(1, 0, 0, 1, node.Layout.Width / 2, node.Layout.Height / 2)); GeneralPathVisual path = new GeneralPathVisual(gp); path.Pen = new Pen(Brushes.DimGray) { Width = 1.5f }; vg.Add(path); vg.Transform = new Matrix(1, 0, 0, 1, (float)node.Layout.X, (float)node.Layout.Y); return(vg); }
protected override GeneralPath GetOutline(INode node) { double size = Math.Min(node.Layout.Width, node.Layout.Height); RectD bounds = new RectD(node.Layout.X + node.Layout.Width / 2 - size / 2, node.Layout.Y + node.Layout.Height / 2 - size / 2, size, size); var path = new GeneralPath(); path.MoveTo(bounds.X, bounds.CenterY); // < path.LineTo(bounds.CenterX, bounds.Y); // ^ path.LineTo(bounds.MaxX, bounds.CenterY); // > path.LineTo(bounds.CenterX, bounds.MaxY); // v path.Close(); return(path); }
public XYAreaRenderer2(XYToolTipGenerator labelGenerator, XYURLGenerator urlGenerator) { XYAreaRenderer2 xyAreaRenderer2 = this; this.showOutline = false; this.setBaseToolTipGenerator(labelGenerator); this.setURLGenerator(urlGenerator); GeneralPath generalPath = new GeneralPath(); ((Path2D.Float) generalPath).moveTo(0.0f, -4f); ((Path2D.Float) generalPath).lineTo(3f, -2f); ((Path2D.Float) generalPath).lineTo(4f, 4f); ((Path2D.Float) generalPath).lineTo(-4f, 4f); ((Path2D.Float) generalPath).lineTo(-3f, -2f); ((Path2D) generalPath).closePath(); this.legendArea = (Shape) generalPath; }
/** * Gets the freeform path * * @return the freeform path */ public GeneralPath GetPath(){ EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID); opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.GEOMETRY__SHAPEPATH, 0x4)); EscherArrayProperty verticesProp = (EscherArrayProperty)getEscherProperty(opt, (short)(EscherProperties.GEOMETRY__VERTICES + 0x4000)); if(verticesProp == null) verticesProp = (EscherArrayProperty)getEscherProperty(opt, EscherProperties.GEOMETRY__VERTICES); EscherArrayProperty segmentsProp = (EscherArrayProperty)getEscherProperty(opt, (short)(EscherProperties.GEOMETRY__SEGMENTINFO + 0x4000)); if(segmentsProp == null) segmentsProp = (EscherArrayProperty)getEscherProperty(opt, EscherProperties.GEOMETRY__SEGMENTINFO); //sanity check if(verticesProp == null) { logger.log(POILogger.WARN, "Freeform is missing GEOMETRY__VERTICES "); return null; } if(segmentsProp == null) { logger.log(POILogger.WARN, "Freeform is missing GEOMETRY__SEGMENTINFO "); return null; } GeneralPath path = new GeneralPath(); int numPoints = verticesProp.GetNumberOfElementsInArray(); int numSegments = segmentsProp.GetNumberOfElementsInArray(); for (int i = 0, j = 0; i < numSegments && j < numPoints; i++) { byte[] elem = segmentsProp.GetElement(i); if(Arrays.Equals(elem, SEGMENTINFO_MOVETO)){ byte[] p = verticesProp.GetElement(j++); short x = LittleEndian.Getshort(p, 0); short y = LittleEndian.Getshort(p, 2); path.moveTo( ((float)x*POINT_DPI/MASTER_DPI), ((float)y*POINT_DPI/MASTER_DPI)); } else if (Arrays.Equals(elem, SEGMENTINFO_CUBICTO) || Arrays.Equals(elem, SEGMENTINFO_CUBICTO2)){ i++; byte[] p1 = verticesProp.GetElement(j++); short x1 = LittleEndian.Getshort(p1, 0); short y1 = LittleEndian.Getshort(p1, 2); byte[] p2 = verticesProp.GetElement(j++); short x2 = LittleEndian.Getshort(p2, 0); short y2 = LittleEndian.Getshort(p2, 2); byte[] p3 = verticesProp.GetElement(j++); short x3 = LittleEndian.Getshort(p3, 0); short y3 = LittleEndian.Getshort(p3, 2); path.curveTo( ((float)x1*POINT_DPI/MASTER_DPI), ((float)y1*POINT_DPI/MASTER_DPI), ((float)x2*POINT_DPI/MASTER_DPI), ((float)y2*POINT_DPI/MASTER_DPI), ((float)x3*POINT_DPI/MASTER_DPI), ((float)y3*POINT_DPI/MASTER_DPI)); } else if (Arrays.Equals(elem, SEGMENTINFO_LINETO)){ i++; byte[] pnext = segmentsProp.GetElement(i); if(Arrays.Equals(pnext, SEGMENTINFO_ESCAPE)){ if(j + 1 < numPoints){ byte[] p = verticesProp.GetElement(j++); short x = LittleEndian.Getshort(p, 0); short y = LittleEndian.Getshort(p, 2); path.lineTo( ((float)x*POINT_DPI/MASTER_DPI), ((float)y*POINT_DPI/MASTER_DPI)); } } else if (Arrays.Equals(pnext, SEGMENTINFO_CLOSE)){ path.ClosePath(); } } } return path; }
/** * Set the shape path * * @param path */ public void SetPath(GeneralPath path) { Rectangle2D bounds = path.GetBounds2D(); PathIterator it = path.GetPathIterator(new AffineTransform()); List<byte[]> segInfo = new List<byte[]>(); List<Point2D.Double> pntInfo = new List<Point2D.Double>(); bool IsClosed = false; while (!it.IsDone()) { double[] vals = new double[6]; int type = it.currentSegment(vals); switch (type) { case PathIterator.SEG_MOVETO: pntInfo.Add(new Point2D.Double(vals[0], vals[1])); segInfo.Add(SEGMENTINFO_MOVETO); break; case PathIterator.SEG_LINETO: pntInfo.Add(new Point2D.Double(vals[0], vals[1])); segInfo.Add(SEGMENTINFO_LINETO); segInfo.Add(SEGMENTINFO_ESCAPE); break; case PathIterator.SEG_CUBICTO: pntInfo.Add(new Point2D.Double(vals[0], vals[1])); pntInfo.Add(new Point2D.Double(vals[2], vals[3])); pntInfo.Add(new Point2D.Double(vals[4], vals[5])); segInfo.Add(SEGMENTINFO_CUBICTO); segInfo.Add(SEGMENTINFO_ESCAPE2); break; case PathIterator.SEG_QUADTO: //TODO: figure out how to convert SEG_QUADTO into SEG_CUBICTO logger.log(POILogger.WARN, "SEG_QUADTO is not supported"); break; case PathIterator.SEG_CLOSE: pntInfo.Add(pntInfo.Get(0)); segInfo.Add(SEGMENTINFO_LINETO); segInfo.Add(SEGMENTINFO_ESCAPE); segInfo.Add(SEGMENTINFO_LINETO); segInfo.Add(SEGMENTINFO_CLOSE); isClosed = true; break; } it.next(); } if(!isClosed) segInfo.Add(SEGMENTINFO_LINETO); segInfo.Add(new byte[]{0x00, (byte)0x80}); EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID); opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.GEOMETRY__SHAPEPATH, 0x4)); EscherArrayProperty verticesProp = new EscherArrayProperty((short)(EscherProperties.GEOMETRY__VERTICES + 0x4000), false, null); verticesProp.SetNumberOfElementsInArray(pntInfo.Count); verticesProp.SetNumberOfElementsInMemory(pntInfo.Count); verticesProp.SetSizeOfElements(0xFFF0); for (int i = 0; i < pntInfo.Count; i++) { Point2D.Double pnt = pntInfo.Get(i); byte[] data = new byte[4]; LittleEndian.Putshort(data, 0, (short)((pnt.GetX() - bounds.GetX())*MASTER_DPI/POINT_DPI)); LittleEndian.Putshort(data, 2, (short)((pnt.GetY() - bounds.GetY())*MASTER_DPI/POINT_DPI)); verticesProp.SetElement(i, data); } opt.AddEscherProperty(verticesProp); EscherArrayProperty segmentsProp = new EscherArrayProperty((short)(EscherProperties.GEOMETRY__SEGMENTINFO + 0x4000), false, null); segmentsProp.SetNumberOfElementsInArray(segInfo.Count); segmentsProp.SetNumberOfElementsInMemory(segInfo.Count); segmentsProp.SetSizeOfElements(0x2); for (int i = 0; i < segInfo.Count; i++) { byte[] seg = segInfo.Get(i); segmentsProp.SetElement(i, seg); } opt.AddEscherProperty(segmentsProp); opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.GEOMETRY__RIGHT, (int)(bounds.Width*MASTER_DPI/POINT_DPI))); opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.GEOMETRY__BOTTOM, (int)(bounds.Height*MASTER_DPI/POINT_DPI))); opt.sortProperties(); SetAnchor(bounds); }
public static Shape createDiagonalCross(float l, float t) { GeneralPath generalPath = new GeneralPath(); ((Path2D.Float) generalPath).moveTo(-l - t, -l + t); ((Path2D.Float) generalPath).lineTo(-l + t, -l - t); ((Path2D.Float) generalPath).lineTo(0.0f, -t * ShapeUtilities.SQRT2); ((Path2D.Float) generalPath).lineTo(l - t, -l - t); ((Path2D.Float) generalPath).lineTo(l + t, -l + t); ((Path2D.Float) generalPath).lineTo(t * ShapeUtilities.SQRT2, 0.0f); ((Path2D.Float) generalPath).lineTo(l + t, l - t); ((Path2D.Float) generalPath).lineTo(l - t, l + t); ((Path2D.Float) generalPath).lineTo(0.0f, t * ShapeUtilities.SQRT2); ((Path2D.Float) generalPath).lineTo(-l + t, l + t); ((Path2D.Float) generalPath).lineTo(-l - t, l - t); ((Path2D.Float) generalPath).lineTo(-t * ShapeUtilities.SQRT2, 0.0f); ((Path2D) generalPath).closePath(); return (Shape) generalPath; }
/** * Draws a sequence of connected lines defined by * arrays of <i>x</i> and <i>y</i> coordinates. * Each pair of (<i>x</i>, <i>y</i>) coordinates defines a point. * The figure is not closed if the first point * differs from the last point. * @param xPoints an array of <i>x</i> points * @param yPoints an array of <i>y</i> points * @param nPoints the total number of points * @see java.awt.Graphics#drawPolygon(int[], int[], int) * @since JDK1.1 */ public void DrawPolyline(int[] xPoints, int[] yPoints, int nPoints){ if(nPoints > 0){ GeneralPath path = new GeneralPath(); path.moveTo(xPoints[0], yPoints[0]); for(int i=1; i<nPoints; i++) path.lineTo(xPoints[i], yPoints[i]); Draw(path); } }
public static Shape createLineRegion(Line2D line, float width) { GeneralPath generalPath = new GeneralPath(); float num1 = (float) line.getX1(); float num2 = (float) line.getX2(); float num3 = (float) line.getY1(); float num4 = (float) line.getY2(); if ((double) (num2 - num1) != 0.0) { double num5 = Math.atan((double) ((num4 - num3) / (num2 - num1))); float num6 = (float) Math.sin(num5) * width; float num7 = (float) Math.cos(num5) * width; ((Path2D.Float) generalPath).moveTo(num1 - num6, num3 + num7); ((Path2D.Float) generalPath).lineTo(num1 + num6, num3 - num7); ((Path2D.Float) generalPath).lineTo(num2 + num6, num4 - num7); ((Path2D.Float) generalPath).lineTo(num2 - num6, num4 + num7); ((Path2D) generalPath).closePath(); } else { ((Path2D.Float) generalPath).moveTo(num1 - width / 2f, num3); ((Path2D.Float) generalPath).lineTo(num1 + width / 2f, num3); ((Path2D.Float) generalPath).lineTo(num2 + width / 2f, num4); ((Path2D.Float) generalPath).lineTo(num2 - width / 2f, num4); ((Path2D) generalPath).closePath(); } return (Shape) generalPath; }
public override void drawItem(Graphics2D g2, XYItemRendererState state, Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, int series, int item, CrosshairState crosshairState, int pass) { if (!this.getItemVisible(series, item)) return; if (pass == 0) { IntervalXYDataset ntervalXyDataset = (IntervalXYDataset) dataset; DeviationRenderer.State state1 = (DeviationRenderer.State) state; double xvalue = ntervalXyDataset.getXValue(series, item); double startYvalue = ntervalXyDataset.getStartYValue(series, item); double endYvalue = ntervalXyDataset.getEndYValue(series, item); RectangleEdge domainAxisEdge = plot.getDomainAxisEdge(); RectangleEdge rangeAxisEdge = plot.getRangeAxisEdge(); double num1 = domainAxis.valueToJava2D(xvalue, dataArea, domainAxisEdge); double num2 = rangeAxis.valueToJava2D(startYvalue, dataArea, rangeAxisEdge); double num3 = rangeAxis.valueToJava2D(endYvalue, dataArea, rangeAxisEdge); PlotOrientation orientation = plot.getOrientation(); if (orientation == PlotOrientation.__\u003C\u003EHORIZONTAL) { List list1 = state1.lowerCoordinates; double[] numArray1 = new double[2]; int index1 = 0; double num4 = num2; numArray1[index1] = num4; int index2 = 1; double num5 = num1; numArray1[index2] = num5; list1.add((object) numArray1); List list2 = state1.upperCoordinates; double[] numArray2 = new double[2]; int index3 = 0; double num6 = num3; numArray2[index3] = num6; int index4 = 1; double num7 = num1; numArray2[index4] = num7; list2.add((object) numArray2); } else if (orientation == PlotOrientation.__\u003C\u003EVERTICAL) { List list1 = state1.lowerCoordinates; double[] numArray1 = new double[2]; int index1 = 0; double num4 = num1; numArray1[index1] = num4; int index2 = 1; double num5 = num2; numArray1[index2] = num5; list1.add((object) numArray1); List list2 = state1.upperCoordinates; double[] numArray2 = new double[2]; int index3 = 0; double num6 = num1; numArray2[index3] = num6; int index4 = 1; double num7 = num3; numArray2[index4] = num7; list2.add((object) numArray2); } if (item == dataset.getItemCount(series) - 1) { Composite composite = g2.getComposite(); g2.setComposite((Composite) AlphaComposite.getInstance(3, this.alpha)); g2.setPaint(this.getItemFillPaint(series, item)); GeneralPath generalPath = new GeneralPath(); double[] numArray1 = (double[]) state1.lowerCoordinates.get(0); ((Path2D.Float) generalPath).moveTo((float) numArray1[0], (float) numArray1[1]); for (int index = 1; index < state1.lowerCoordinates.size(); ++index) { double[] numArray2 = (double[]) state1.lowerCoordinates.get(index); ((Path2D.Float) generalPath).lineTo((float) numArray2[0], (float) numArray2[1]); } int num4 = state1.upperCoordinates.size(); double[] numArray3 = (double[]) state1.upperCoordinates.get(num4 - 1); ((Path2D.Float) generalPath).lineTo((float) numArray3[0], (float) numArray3[1]); int num5 = num4 - 2; while (num5 >= 0) { double[] numArray2 = (double[]) state1.upperCoordinates.get(num5); ((Path2D.Float) generalPath).lineTo((float) numArray2[0], (float) numArray2[1]); num5 += -1; } ((Path2D) generalPath).closePath(); g2.fill((Shape) generalPath); g2.setComposite(composite); state1.lowerCoordinates.clear(); state1.upperCoordinates.clear(); } } if (this.isLinePass(pass)) { if (item == 0) { DeviationRenderer.State state1 = (DeviationRenderer.State) state; ((Path2D) state1.seriesPath).reset(); state1.setLastPointGood(false); } if (!this.getItemLineVisible(series, item)) return; this.drawPrimaryLineAsPath(state, g2, plot, dataset, pass, series, item, domainAxis, rangeAxis, dataArea); } else { if (!this.isItemPass(pass)) return; EntityCollection entities = (EntityCollection) null; if (info != null) entities = info.getOwner().getEntityCollection(); this.drawSecondaryPass(g2, plot, dataset, pass, series, item, domainAxis, dataArea, rangeAxis, crosshairState, entities); } }
private void ClearCache () { _pathData = null; _generalPath = null; }
private GeneralPath GetGeneralPath () { PathIterator iter = getPathIterator (null); GeneralPath path = new GeneralPath (); path.append (iter, false); return path; }
public static Shape readShape(ObjectInputStream stream) { if (stream == null) { string str = "Null 'stream' argument."; Throwable.__\u003CsuppressFillInStackTrace\u003E(); throw new IllegalArgumentException(str); } else { object obj1 = (object) null; if (!stream.readBoolean()) { Class @class = (Class) stream.readObject(); if (Object.instancehelper_equals((object) @class, SerialUtilities.class\u0024java\u0024awt\u0024geom\u0024Line2D != null ? (object) SerialUtilities.class\u0024java\u0024awt\u0024geom\u0024Line2D : (object) (SerialUtilities.class\u0024java\u0024awt\u0024geom\u0024Line2D = SerialUtilities.class\u0024("java.awt.geom.Line2D")))) obj1 = (object) new Line2D.Double(stream.readDouble(), stream.readDouble(), stream.readDouble(), stream.readDouble()); else if (Object.instancehelper_equals((object) @class, SerialUtilities.class\u0024java\u0024awt\u0024geom\u0024Rectangle2D != null ? (object) SerialUtilities.class\u0024java\u0024awt\u0024geom\u0024Rectangle2D : (object) (SerialUtilities.class\u0024java\u0024awt\u0024geom\u0024Rectangle2D = SerialUtilities.class\u0024("java.awt.geom.Rectangle2D")))) obj1 = (object) new Rectangle2D.Double(stream.readDouble(), stream.readDouble(), stream.readDouble(), stream.readDouble()); else if (Object.instancehelper_equals((object) @class, SerialUtilities.class\u0024java\u0024awt\u0024geom\u0024Ellipse2D != null ? (object) SerialUtilities.class\u0024java\u0024awt\u0024geom\u0024Ellipse2D : (object) (SerialUtilities.class\u0024java\u0024awt\u0024geom\u0024Ellipse2D = SerialUtilities.class\u0024("java.awt.geom.Ellipse2D")))) obj1 = (object) new Ellipse2D.Double(stream.readDouble(), stream.readDouble(), stream.readDouble(), stream.readDouble()); else if (Object.instancehelper_equals((object) @class, SerialUtilities.class\u0024java\u0024awt\u0024geom\u0024Arc2D != null ? (object) SerialUtilities.class\u0024java\u0024awt\u0024geom\u0024Arc2D : (object) (SerialUtilities.class\u0024java\u0024awt\u0024geom\u0024Arc2D = SerialUtilities.class\u0024("java.awt.geom.Arc2D")))) obj1 = (object) new Arc2D.Double(stream.readDouble(), stream.readDouble(), stream.readDouble(), stream.readDouble(), stream.readDouble(), stream.readDouble(), stream.readInt()); else if (Object.instancehelper_equals((object) @class, SerialUtilities.class\u0024java\u0024awt\u0024geom\u0024GeneralPath != null ? (object) SerialUtilities.class\u0024java\u0024awt\u0024geom\u0024GeneralPath : (object) (SerialUtilities.class\u0024java\u0024awt\u0024geom\u0024GeneralPath = SerialUtilities.class\u0024("java.awt.geom.GeneralPath")))) { GeneralPath generalPath = new GeneralPath(); float[] numArray = new float[6]; for (int index1 = stream.readBoolean() ? 1 : 0; index1 == 0; index1 = stream.readBoolean() ? 1 : 0) { int num = stream.readInt(); for (int index2 = 0; index2 < 6; ++index2) numArray[index2] = stream.readFloat(); switch (num) { case 0: ((Path2D.Float) generalPath).moveTo(numArray[0], numArray[1]); break; case 1: ((Path2D.Float) generalPath).lineTo(numArray[0], numArray[1]); break; case 2: ((Path2D.Float) generalPath).quadTo(numArray[0], numArray[1], numArray[2], numArray[3]); break; case 3: ((Path2D.Float) generalPath).curveTo(numArray[0], numArray[1], numArray[2], numArray[3], numArray[4], numArray[5]); break; case 4: ((Path2D) generalPath).closePath(); break; default: string str = "JFreeChart - No path exists"; Throwable.__\u003CsuppressFillInStackTrace\u003E(); throw new RuntimeException(str); } ((Path2D) generalPath).setWindingRule(stream.readInt()); } obj1 = (object) generalPath; } else obj1 = (object) (Shape) stream.readObject(); } object obj2 = obj1; if (obj2 == null) return (Shape) null; Shape shape = obj2 as Shape; if (shape != null) return shape; else throw new IncompatibleClassChangeError(); } }
public static Shape createDownTriangle(float s) { GeneralPath generalPath = new GeneralPath(); ((Path2D.Float) generalPath).moveTo(0.0f, s); ((Path2D.Float) generalPath).lineTo(s, -s); ((Path2D.Float) generalPath).lineTo(-s, -s); ((Path2D) generalPath).closePath(); return (Shape) generalPath; }
public void DrawPolyline(int[] xPoints, int[] yPoints, int nPoints) { if(nPoints > 0) { GeneralPath generalpath = new GeneralPath(); generalpath.moveTo(xPoints[0], yPoints[0]); for(int j = 1; j < nPoints; j++) generalpath.lineTo(xPoints[j], yPoints[j]); Draw(generalpath); } }
public static Shape createRegularCross(float l, float t) { GeneralPath generalPath = new GeneralPath(); ((Path2D.Float) generalPath).moveTo(-l, t); ((Path2D.Float) generalPath).lineTo(-t, t); ((Path2D.Float) generalPath).lineTo(-t, l); ((Path2D.Float) generalPath).lineTo(t, l); ((Path2D.Float) generalPath).lineTo(t, t); ((Path2D.Float) generalPath).lineTo(l, t); ((Path2D.Float) generalPath).lineTo(l, -t); ((Path2D.Float) generalPath).lineTo(t, -t); ((Path2D.Float) generalPath).lineTo(t, -l); ((Path2D.Float) generalPath).lineTo(-t, -l); ((Path2D.Float) generalPath).lineTo(-t, -t); ((Path2D.Float) generalPath).lineTo(-l, -t); ((Path2D) generalPath).closePath(); return (Shape) generalPath; }
public override void draw(Graphics2D g2, DialPlot plot, Rectangle2D frame, Rectangle2D view) { g2.setPaint((Paint) Color.blue); g2.setStroke((Stroke) new BasicStroke(1f)); Rectangle2D rectangle2D1 = DialPlot.rectangleByRadius(frame, this.radius, this.radius); Rectangle2D rectangle2D2 = DialPlot.rectangleByRadius(frame, this.widthRadius, this.widthRadius); double d = plot.getValue(this.datasetIndex); double num = plot.getScaleForDataset(this.datasetIndex).valueToAngle(d); Point2D endPoint1 = ((Arc2D) new Arc2D.Double(rectangle2D1, num, 0.0, 0)).getEndPoint(); Arc2D.Double double1 = new Arc2D.Double(rectangle2D2, num - 90.0, 180.0, 0); Point2D startPoint1 = ((Arc2D) double1).getStartPoint(); Point2D endPoint2 = ((Arc2D) double1).getEndPoint(); Point2D startPoint2 = ((Arc2D) new Arc2D.Double(rectangle2D2, num - 180.0, 0.0, 0)).getStartPoint(); GeneralPath generalPath = new GeneralPath(); ((Path2D.Float) generalPath).moveTo((float) endPoint1.getX(), (float) endPoint1.getY()); ((Path2D.Float) generalPath).lineTo((float) startPoint1.getX(), (float) startPoint1.getY()); ((Path2D.Float) generalPath).lineTo((float) startPoint2.getX(), (float) startPoint2.getY()); ((Path2D.Float) generalPath).lineTo((float) endPoint2.getX(), (float) endPoint2.getY()); ((Path2D) generalPath).closePath(); g2.setPaint(this.fillPaint); g2.fill((Shape) generalPath); g2.setPaint(this.outlinePaint); Line2D.Double double2 = new Line2D.Double(((RectangularShape) frame).getCenterX(), ((RectangularShape) frame).getCenterY(), endPoint1.getX(), endPoint1.getY()); g2.draw((Shape) double2); ((Line2D) double2).setLine(startPoint1, endPoint2); g2.draw((Shape) double2); ((Line2D) double2).setLine(endPoint2, endPoint1); g2.draw((Shape) double2); ((Line2D) double2).setLine(startPoint1, endPoint1); g2.draw((Shape) double2); ((Line2D) double2).setLine(startPoint1, startPoint2); g2.draw((Shape) double2); ((Line2D) double2).setLine(endPoint2, startPoint2); g2.draw((Shape) double2); }
/** * Strokes the outline of a <code>Shape</code> using the Settings of the * current <code>Graphics2D</code> context. The rendering attributes * applied include the <code>Clip</code>, <code>Transform</code>, * <code>Paint</code>, <code>Composite</code> and * <code>Stroke</code> attributes. * @param shape the <code>Shape</code> to be rendered * @see #setStroke * @see #setPaint * @see java.awt.Graphics#setColor * @see #_transform * @see #setTransform * @see #clip * @see #setClip * @see #setComposite */ public void Draw(Shape shape){ GeneralPath path = new GeneralPath(_transform.CreateTransformedShape(shape)); Freeform p = new Freeform(_group); p.SetPath(path); p.GetFill().SetForegroundColor(null); ApplyStroke(p); _group.AddShape(p); }
public FillAdapter() { path = new GeneralPath(GeneralPath.WIND_NON_ZERO); }
/** * Fills the interior of a <code>Shape</code> using the Settings of the * <code>Graphics2D</code> context. The rendering attributes applied * include the <code>Clip</code>, <code>Transform</code>, * <code>Paint</code>, and <code>Composite</code>. * @param shape the <code>Shape</code> to be Filled * @see #setPaint * @see java.awt.Graphics#setColor * @see #_transform * @see #setTransform * @see #setComposite * @see #clip * @see #setClip */ public void Fill(Shape shape){ GeneralPath path = new GeneralPath(_transform.CreateTransformedShape(shape)); Freeform p = new Freeform(_group); p.SetPath(path); ApplyPaint(p); p.SetLineColor(null); //Fills must be "No Line" _group.AddShape(p); }
public static bool equal(GeneralPath p1, GeneralPath p2) { if (p1 == null) { return p2 == null; } else { if (p2 == null || ((Path2D) p1).getWindingRule() != ((Path2D) p2).getWindingRule()) return false; PathIterator pathIterator1 = ((Path2D.Float) p1).getPathIterator((AffineTransform) null); PathIterator pathIterator2 = ((Path2D.Float) p2).getPathIterator((AffineTransform) null); double[] numArray1 = new double[6]; double[] numArray2 = new double[6]; for (int index = !pathIterator1.isDone() || !pathIterator2.isDone() ? 0 : 1; index == 0; index = !pathIterator1.isDone() || !pathIterator2.isDone() ? 0 : 1) { if (pathIterator1.isDone() != pathIterator2.isDone() || pathIterator1.currentSegment(numArray1) != pathIterator2.currentSegment(numArray2) || !Arrays.equals(numArray1, numArray2)) return false; pathIterator1.next(); pathIterator2.next(); } return true; } }