GoText with same angle of GoLink object

Hi,

The requirement is to place GoText object on the same angle of GoLink objct.
Please see attached immage:
How can i set Target Route:92 text on the same angle as of arrowed link object?
Also box around the GoText is too tight. How it could have some space between text & border?
Please reply me as soon as possible.
Thanks

try this: http://www.nwoods.com/forum/forum_posts.asp?TID=1367

There's no Margin on GoText. You could add "spaces" to the text for left and right margin.
Hi,
Even after adding "spaces" to the text of GoText for left & right margin, it doesn't work.
I use GoText.Bordered = true to draw border around the GoText on view.

Here’s what I get with added spacing:

1 is no extra
2 is with 4 spaces before, 3 after
3 is set to multiline with a Newline at start and end.
Kind of a hack, and certainly doesn't work if you plan to make the text editable. but easy.
If you want more granular control, you'll have to use a GoGroup with a GoText and a GoShape (new GoDrawing(GoFigure.Rectangle)), which can be rotated by setting the Angle property).
Hi,
I tried as per you suggested in your earlier response by adding spaces at start & end of GoText objects.But i analysed that if GoText.Alignment = TopLeft, then only starting spaces reflected with GoText object on view, but spaces added at the end of GoText doesn't appear as:
But then i set GoText.Alignment = MiddleCenter, then spaces are reflected at the start as well as at the end of Gotext on view as:
But the requirement is to create GoText objects with TopLeft alignment only.
So how added spaces at the start as well as at the end of GoText.Text could be reflected with TopLeft alignment on view?
Please reply as soon as possible.
Thanks

Try this. It adds RotatedText and a rotatable GoDrawing Figure to a GoTextNode, letting you set margins.

[code]
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Drawing.Drawing2D;
using Northwoods.Go;
namespace App {
class RotatedTextNode : GoTextNode {
// a simple class that has a RotatedText and rotatable GoDrawing Figure.
// Allows setting of TopLeftMargin and BottomRightMargin to control the
// border around the text.
// no ports are supported, so it's not really much of a "Node".
protected override GoText CreateLabel() {
RotatedText rt = new RotatedText();
rt.Selectable = false;
rt.Editable = true;
rt.Text = "RotatedTextNode";
return rt;
}
protected override GoObject CreateBackground() {
GoDrawing r = new GoDrawing(GoFigure.Rectangle);
r.Selectable = false;
r.Resizable = false;
r.Reshapable = false;
return r;
}
// no ports
protected override GoPort CreatePort(int spot) {
return null;
}
public RotatedText RT {
get { return this.Label as RotatedText; }
}
public GoDrawing BG {
get {return this.Background as GoDrawing;}
}
public float Angle {
get {
float angle = 0;
GoDrawing bg = BG;
if (bg != null) angle = bg.Angle;
return angle;
}
set {
if (RT != null) RT.Angle = value;
if (BG != null) BG.Angle = value;
}
}
public override void LayoutChildren(GoObject childchanged) {
if (this.Initializing) return;
GoText label = this.Label;
if (label == null) return;
GoDrawing back = this.Background as GoDrawing;
if (back != null) {
SizeF topleft = this.TopLeftMargin;
SizeF bottomright = this.BottomRightMargin;
// assume if (this.AutoResizes) {
back.UnrotatedBounds = new RectangleF(label.Left - topleft.Width,
label.Top - topleft.Height,
label.Width + topleft.Width + bottomright.Width,
label.Height + topleft.Height + bottomright.Height);
}
// no ports
}
protected override RectangleF ComputeBounds() {
if (BG != null)
return BG.Bounds; // GoDrawing will compute Bounds correctly for any angle.
else return base.ComputeBounds();
}
}
}
[/code]
create via:
[code]
RotatedTextNode rtn2 = new RotatedTextNode();
rtn2.Location = new PointF(300, 100);
rtn2.TopLeftMargin = new SizeF(10, 10);
rtn2.BottomRightMargin = new SizeF(10, 10);
rtn2.Angle = 45;
doc.Add(rtn2);
[/code]

Hi,

I copied the code provided earlier for RotatedTextNode class. But when i compiled, then there is no class available as GoDrawing & GoFigure.
How can i resolve solution build error for these two classes?
please reply me as soon as possible.
Thanks

What version are you using?

Hi,

I don't require RotatedTextNode class.
For me, RotetedText class works fine except only one issue. In my application, moving the stop point, the corresponding text should be moved accordingly, which works fine with Target Route: 92 RotatedText object.
But the issue is that its border is not refreshed on its movement. It keeps left some portion of its border on view.Please see attached image with circled portion:
Please let me know how it could be resolved?
Thanks
public override RectangleF ExpandPaintBounds(RectangleF rect, GoView view) {
// make "rect" a little bigger here
...
return rect;
}
Hi,
There is already overridden function available in RotatedText class as:
public override RectangleF ExpandPaintBounds(RectangleF rect, GoView view)
{
RectangleF b = GetRealBounds(); return RectangleF.Union(rect, b); }
But it doesn't resolve the problem.

Make it bigger than the Union returns.

try
RectangleF b = GetRealBounds();
b = RectangleF.Union(rect, b);
b.Inflate(3, 3);
return b;

Hi,

Thanks for your support.
Now it works fine.
Thanks