Adding text below text box - matlab

I have a text item on one of my plots, placed at a certain location, with a certain orientation:
th=text(x,y,'some text','HorizontalAlignment','right','rotation',rot);
Based on its position (get(th, 'Position')), or any other property, is there any way to compute the lower bound of its bounding box? I want to place another text just below it.

You could use the Extent property. You will probably need to tweak the alignments depending on what you're after, but something like this:
th = text(x,y,'some text','HorizontalAlignment','right','rotation',rot);
ex = get(th,'Extent');
text(ex(1),ex(2),'Text Below')

Related

Unity Resizing Dropdown Dynamically

I have a dropdown list on a filter panel which needs to stretch dynamically to fit the content as shown:
I have tried several content size fitters but cannot find anything, If possible I would like to set a max width it can expand to then truncate everything longer than that, I would also like it to expand only to the right with a right pivot point. I have found a similar example here: https://forum.unity3d.com/threads/resize-standard-dropdown-to-fit-content-width.400502/
Thanks!
Well. Lets start with the code from that Unity forum thread.
var widest = 0f;
foreach (var item in _inputMines.GetComponentsInChildren<Text>()) {
widest = Mathf.Max(item.preferredWidth, widest);
}
_inputMines.GetComponent<LayoutElement>().preferredWidth = widest + 40;
We want to have a max-width allowed, so any content longer than this will be truncated. So let's add that variable:
var maxWidth = 250f;
//or whatever value; you may wish this to be a property so you can edit it in the inspector
var widest = 0f;
foreach (var item in _inputMines.GetComponentsInChildren<Text>()) {
Now we use the smaller of the two width values. Then apply it to the content layout:
}
widest = Mathf.Min(maxWidth, widest);
_inputMines.GetComponent<LayoutElement>().preferredWidth = widest + 40;
The +40 should be retained because that deals with the scrollbar. Your maxWidth value should be chosen to account for this.
Finally we want the longer items to get cut off nicely.
Give each dropdown item a Rect Mask 2D component (Component -> UI -> Rect Mask 2D). The template object exists in the scene hierarchy before the game is run, just disabled. You can just add the component to the parent transform, the one with the image (so the text is clipped).
You'll need to make sure that the mask covers the same width as the image graphic and expands along with it, possibly slightly shorter on the X direction so the text gets cut off before the image border is drawn. This should happen automatically, but you will need to check and possibly make some alterations to the template object. Alternatively you can use an Image Mask, but you'll have to play with that one yourself, but it will allow for non-rectangular clipping.
That's it!

Setting text alignment with visio stencil

I'm in the proccess of creating an automated visio diagram script in powershell, adding elements with text like so.
$GROUP = $CPage.Drop($Stencil_AgentList, $x, $Y)
$GROUP.Text = $MatchedGroup.Name
$GROUP.AutoConnect($QUEUE, 0, $Stencil_Connector)
most of the functionality in terms of layout works at the moment, but i'm having serious troubles with the aspects that actually make diagrams look good.
I think this image explains it best: when you 'Edit Text' on an object, it appears to be aligned to the object in some way, either below or on top of it.
what I would like is to be able to align text, from the object itself, to the right side like below, where 'Example user name' is the ideal output.
I'm assuming this involves shapesheets etc. which I have almost no experience with.
Any help or resources on modifying these stencils so the 'text' area is where I want it to be would be much appreciated.
You should check out this page : https://msdn.microsoft.com/en-us/library/aa200988(v=office.10).aspx
The Text Block of a shape is by default, the same size as the enclosing rectangle of the shape. However, you can modify its size, position, rotation and the horizontal and vertical text alignment

matlab: having a good control of MyBox, box with text

my problem is I want to have a box for additional bigger comments to the graph.
How can I create this box, so that it will be always on the right bottom side outside of my graph, and it will be automatically adjusting its size to the amount of text inside? Also, if I will have longer text, I need it to be split into more lines, not just one line extremely long.
I use it like that, however I have a poor control over what is happening, this just creates a certain size in a certain place, text is cut.. please help :)
x = rand(110)*100;
y = x;
plot(x,y)
MyBox = uicontrol('style','text')
set(MyBox,'String','optional longer information to be put into diagram')
set(MyBox,'Position',[10,0,40,10])
I am afraid you can not do that automatically - Text boxes do not use callbacks. From the documentation:
Users cannot change static text interactively. Static text controls do not activate callback routines when clicked.
What you can do is call textwrap function, which will automatically wrap the text you pass to it and return new Text box position:
MyBox = uicontrol('style','text');
% set initial position - first three values are kept constant after wrap, the hight can be changed
set(MyBox,'Position',[10,10,30,10])
% adjust the height of your Text box and wrap the text
[outstring,newpos] = textwrap(MyBox,{'optional longer information to be put into diagram'});
% set new position and text
set(MyBox,'Position',newpos, 'String', outstring)
You will have to call textwrap and set(...) yourself whenever you change the string in the text box.

Determine/Save the position of text in matlab

I plotted few points using scatter and then label them using text. The position of these labels are same as the position of the points + some offset. Some of these text label overlap with each other and hence I moved them interactively (using mouse). I can check the new position of each of these text individually using property editor. However this is very time-consuming. Is there a better way to get the coordinates of all these text-label?
You can use findobj to get handles to text objects that are children of the current axes (or another handle... your choice):
text_handles = findobj('parent',gca,'type','text');
Then you can get the positions of these text objects:
positions = get(text_handles,'position');
You may need to do a bit more work to associate each text object with its data point - I suggest taking advantage of the property system, perhaps via the UserData field, for this, though there are many options.
If you want to do it easily later do this in your plots, for example:
h=text(2.9,7.5,'MyText');
This will put "MyText" at position 2.9, and 7.5.
Then to change the position use:
set(h,'Position',[2.5 7]);
This will change the position to 2.5 and 7.
Later if you need to see tthe position of text again use:
get(h);
Hope this helps.

if entry from database is of a certain value, substitute an image on the report

I am trying to read a value from my database, and depending on the character, have a different image show. Basically the values will either be b,r,g,or y for blue, red, green yellow and in the report I would like to show a colored circle corresponding to the entry. Does anyone know a quick way to do this? I am new to crystal reports. Thank you.
Circles are created using a rectangle (yes, really). Set the roundness=100%. Unfortunately, you can't hide/show (suppress, In Crystal's vernacular) a rectangle with conditional logic. Nor can you change its x and y values. So, for your purposes, its useless.
One option is to insert four, colored, images of circles. Suppress all but the one that you want to display.
Another option is to insert a text box, then add a circular, wingding character to it (Word can help w/ this). Use the text box's conditional formatting to change its color.
One additional suggestion to craig. You could:
create an image file for each of the coloured circles
add one of these coloured circles to the report
right click, format graphic
from the picture tab, select the formula editor for graphic location
enter a formula which looks for the relevant coloured circle image file
'C:\circles\' + {table.field} + '.jpg'
L