Upgrading Enterprise Architect Diagram Element names wrap - enterprise-architect

We recently upgraded enterprise architect to version 12 and when I open up our diagram, all names wrap now to the width of the element. Before it would write the server name in one line under the element even if the name was longer than the element itself, but now they wrap to the width of the element.
How can I make it show the name of the element in one line instead of wrapping?
Edit: This seems to be a problem if we have dashes in the name. If I change the dashes to underscores, it doesn't wrap. But we really need dashes in the names.
Edit #2: Here is a screen shot of my issue. One on the left has a dash and wraps, one on the right has underscore and doesn't wrap. Everything else is the same.

You need to open Features and Properties/Feature...
There you switch this for individual elements. To do that globally you would need to script this:
dia = Repository.GetDiagram... # get the diagram itself
for do in dia.DiagramObjects {
do.ElementDisplayMode = 1 # longest, or 3: truncate (2 = wrap)
do.Update()
}
Edit: Applies only to features of a class and not its name. EA wraps names (if the rectangle is too small) at dashes and spaces (eventually a few more chars?). And this can not be altered. You might script it the following way:
dia = repository.GetDiagram.... # load the diagram
for do in dia.diagramObjects {
e = repository.getElementById(do.ElementId)
width = stringBitWidth(e.Name) # calc width of text in screen pixels; use your phantasy
currWidth = do.right - do.left
extend = (width - currWidth) / 2
do.Left -= extend
do.Right += extend
do.Update()
}

Related

How to set width of text marks in vega-lite / altair (text wrapping and line break) for long text

I am trying to display text over time using altair (vega-lite), which works fine using a layered chart, where one is created using the alt.Chart().mark_text() function to display the text.
The text though is multiple phrases and should be wrapped (with line breaks). How can this be done?
(I do not want to use fixed line breaks, e.g. \n, at distinct positions since the text wrapping should work with zooming too)
Not exactly what you want, but you can specify a character on which to break to a new line. When zooming, the text stays the same size, so it should always fit the view.
For example making a new line for every word:
.mark_text(lineBreak=' ')

How to add a small straight line (I mean like this: a̅ b̅ X̅) onto a character inside a string?

I want to add small straight line onto some desired characters/numbers inside a string inside textview. I couldn't find a solution. Maybe using NSMutableAttributedString. Meanwhile, I mean doing this programmatically. There is strikethrough style, but not overstrike style. Or maybe adding the letters "a" and "_" with different .baseline values. But how to add both characters onto each other then?
Is it possible?
EDIT: Due to make a try for the helpful answers below, I think to make the line at a spesific height is needed. "A\u{0305}" makes the up line very close to the character, as if it sticks. Is there a way to make it at specific height? For example, if we assume that all the keyboard-inputted characters are written inside every single boxes, the ceiling side of these boxes could be lined?
So this (note: see edit below) appears to be an "a tilde ogonek" (it's Lithuanian).
You can write it for instance as follows using these two Unicode characters:
let atildeogonek = "\u{0105}\u{0303}"
let title = "How to add a small straight line (I mean like this: \(atildeogonek)) onto a character inside a string?"
The first character is the a with an ogonek, the second one is the tilde.
EDIT: The initial question specifically asked about the character ą̃ ("a tilde ogonek") in the title, and I used this code to demonstrate how to use Unicode characters in a Swift string. After posting this answer, the question was edited to be more general about "a line above a character".
Programmatically, you could use a function like this:
func overline(character: Character) -> Character? {
return "\(character)\u{0305}".first
}
That will take a character as input and return a new character (glyph) that has had the Unicode combining overline character added to it. It will return nil if adding the combining overline character fails.
The code print(overline(character:"A")!), for example, returns "A̅"
Or, if you want to add an overline to every character in a string, you could use a function like this:
func overline(characters: String) -> [Character?] {
return Array(characters).map { return "\($0)\u{0305}".first
}
}
(I'm not sure if there are any characters for which the above will fail, so I'm not sure if force-unwrapping the result is safe. Thus I left the result of both functions to be optional Character/Array of Character.)
You can easily find the unicodes of ā or ą̃ by using the xcode's own Character Viewer. Just follow the following steps :
hit : Control + Command + SpaceBar
If you get a compact one like this, click the upper right corner icon to expand it.
When expanded, Click the settings gear in the corner . Select customize list.
select Enclosed Characters
Go down to the bottom and open Code tables then add Unicode.
Now, just search for your required Character and you can check its unicode value. here i am searching ā
to print unicode's value :
print("\u{0101}")

Altering visual representation of code in VSCode extension

My Question:
Is there a way to write an extension that changes what vscode displays without changing the underlying code? Vscode seems to have a ton of different types of extensions and I am having a hard time finding where to start.
The Context:
I want to try writing a vscode extension I have had an idea for for a while. (If it already exists, let me know.)
The "tab" character in ASCII is actually a "Horizontal Tabulation" key. It was originally meant for making tables in conjunction with "Vertical Tabulation." Your printer/terminal would have a column and row stop point that the HT and VT characters could advance to. It would be kinda cool to resurrect the original purpose of the tab key. In other words, code written like so:
On the disk:
#␉Comment␉Here␉for␉Columns␊
thing =␉"howdy",␉"doody",␉"mein froind",␉"!"␊
␉" I love",␉"what you've",␉"done with",␉"the place";␊
What's displayed (vertical line would be partly transparent):
# | Comment | Here | for | Columns
thing = | "howdy", | "doody", | "mein froind", | "!"
| " I love", | "what you've", | "done with", | "the place";
So, tabs could be aligned magically by looking at subsequent lines and attempting to align anything that follows a horizontal tab character. Tab would no longer represent a column of width 8 or 4, but be flexible and align with the previous and following lines of code.
This would mean you don't need to manually align anything. You could also have it so overflows of your max line length would auto-wrap and auto-align tabs. I would probably avoid using the vertical tab character, as most code interpreters might not be able to ignore it properly. Most should ignore the regular horizontal tab, though.
So, what type of extension would this be? How do I display code different from what it is on the disk? Thanks ahead of time.
I found a hack-ish way to do it. Not ideal, as rendering is choppy.
Create a decorator-type extension. When defining the decoration type, set the letter spacing (and opacity in the case of text) to basically make the content of the match invisible and space-less
const tabDecorationType = vscode.window.createTextEditorDecorationType({
letterSpacing: '-1em',
opacity: '0'
});
When setting the decorations later on, have your DecorationOptions object set the text before and after to essentially give your decoration the new text
const regEx = /\t/g;
const text = activeEditor.document.getText();
const tabs: vscode.DecorationOptions[] = [];
let match;
while (match = regEx.exec(text)) {
const startPos = activeEditor.document.positionAt(match.index);
const endPos = activeEditor.document.positionAt(match.index + 1);
const decoration: vscode.DecorationOptions = {
range: new vscode.Range(startPos, endPos),
renderOptions: {
after: {contentText: "| "},
before: {contentText: " "}, // <-- replace with correct number of spaces
}
};
tabs.push(decoration);
}
activeEditor.setDecorations(tabDecorationType, tabs);
And you essentially have replaced text. (It would take some more scanning to get the correct number of spaces for my desired implementation, but that's not really a part of the question.) This implementation is not super ideal, as it takes a second for the decorations to render and update. This makes code augmentations a little ugly when they are key to the formatting of the document.
Update Note: Descriptors seem to be picky with whitespace. They will remove all but one space before and after the descriptor and remove any new line characters. This means you have to put some character like '_' in and make the descriptor text invisible with 'color' to get a bunch of whitespace and you can't really get a newline... even more hack-ish and less ideal.

Control inter-paragraph spacing

In using OfficeR to generate MS Word documents, is there a means to control how much space appears on the page between paragraphs? Successive calls to body_add_par() insert space between which is too wide for my purpose. I can't find any reference to controlling this in officer.pdf or in the README.
What am I missing?
Inter-paragraph spacing in Word is controlled by the .SpaceBefore and .SpaceAfter settings. For example:
With Selection
With .ParagraphFormat
.SpaceBefore = 6
.SpaceAfter = 6
End With
End With
Ideally, though, you'd apply these to a Style definition (once), then apply that Style to the paragraphs concerned.

How to adjust spacing between paragraphs in iText7

In iText7 I need to create 5 lines of text at the top of a document that are centered to the page. The easiest way I found to do this is:
doc.add(new Paragraph("text of line 1").SetTextAlignment(TextAlignment.CENTER));
doc.add(new Paragraph("text of line 2").SetTextAlignment(TextAlignment.CENTER));
etc.
However there is a larger amount of space between each of the lines than I want. Within a paragraph you can set line leading, but how do I set leading between paragraphs in a document? Or am I doing this the complete wrong way to begin with?
Paragraph has 2 methods for handling what is known as the leading.
Paragraph o1 = new Paragraph("");
o1.setMultipliedLeading(1.0f);
Multiplied leading is when you specify a factor of how big the leading will be compared to the height of the font.
You can also set it document wise:
document.setProperty(Property.LEADING, new Leading(Leading.MULTIPLIED, 1.2f));
In my case with iText7, I used SetMarginTop(0f) and SetMarginBottom(0f) to make it.