Stretch component, not connector - annotations

Sometimes when a component is stretched we don't want the connector(s) to be stretched because it looks ugly. See for example the instances of Modelica.Blocks.Sources.RealExpression below
Is it possible to add a graphical annotation when instantiating a connector (or other compent) in a model to avoid this?

I am not aware of a solution which allows to use the existing RealExpression block. As a workaround you could create new versions of this block - either by extending it or by duplicating it.
Option 1: Extend RealExpression and set fixed size
You could create a new, broader real expression which extends the original real expression, hides the original icon and draws a new one.
Drawback: This requires one model per size, but if a size is used freqently this should be fine.
model RealExpression_600x200
extends Modelica.Blocks.Sources.RealExpression annotation (
IconMap(extent={{100,-100},{300,100}}, primitivesVisible=false),
DiagramMap(extent={{100,-100},{300,100}}, primitivesVisible=false));
equation
annotation (
Diagram(coordinateSystem(extent={{-300,-100},{300,100}})),
Icon(coordinateSystem(extent={{-300,-100},{300,100}}), graphics={
Rectangle(
extent={{-300,40},{300,-40}},
lineColor={0,0,0},
lineThickness=5.0,
fillColor={235,235,235},
fillPattern=FillPattern.Solid,
borderPattern=BorderPattern.Raised),
Text(
extent={{-300,100},{300,60}},
textString="%name",
lineColor={0,0,255}),
Text(
extent={{-296,15},{296,-15}},
lineColor={0,0,0},
textString="%y")}),
uses(Modelica(version="3.2.2")));
end RealExpression_600x200;
Option 2: Duplicate RealExpression and set size via parameter
You could also duplicate the RealExpression and introduce a parameter which controls the width of the graphical annotations. Common sizes can be added as a choice. You should not re-scale the component, but select the size with the parameter width instead.
block RealExpression "Real expression with varying size, set via parameter"
parameter Integer width = 10
annotation(choices(choice=20 "Regular",
choice=40 "Wide",
choice=80 "Wiiiiiiide"));
Modelica.Blocks.Interfaces.RealOutput y=0.0 "Value of Real output"
annotation (
Dialog(group="Time varying output signal"),
Placement(transformation(extent={{10*width/2,-10},{10*width/2+20,10}})));
annotation (
Icon(
coordinateSystem(
preserveAspectRatio=true,
extent={{-100,-100},{100,100}}),
graphics={
Rectangle(
extent={{-10*width/2,40},{10*width/2,-40}},
lineColor={0,0,0},
lineThickness=5.0,
fillColor={235,235,235},
fillPattern=FillPattern.Solid,
borderPattern=BorderPattern.Raised),
Text(
extent={{-10*width/2+4,15},{10*width/2-4,-15}},
lineColor={0,0,0},
textString="%y"),
Text(
extent={{-10*width/2,90},{10*width/2,50}},
textString="%name",
lineColor={0,0,255})}),
uses(Modelica(version="3.2.2")));
end RealExpression;

I don't see any way to do exactly what you want at the moment.
Note that it is possible to prevent stretching of the entire realExpression, using
annotation (Icon(coordinateSystem(preserveAspectRatio=true),...),
Diagram(coordinateSystem(preserveAspectRatio=true),...),
However, it is not specified that using this in a connector of RealExpression should prevent stretching of the connector - while still allowing stretching of the component.

Related

How to insert a non-inline picture into a word document using VB6?

I am trying to insert an image into a word document using the Microsoft word 15.0 objects library included with VB^ and the only way I've seen to insert a graphics file is through this:
oDoc.Range.InlineShapes.AddPicture ("C:\Users\name\Desktop\file.jpg")
But, I want a picture that can be positioned over the text and where I want it in the document... Is there any way to do this using VB6 Code?
Word has two different ways to manage images and other embedded objects: as InlineShapes and as Shapes. The first are treated the same as characters in the text flow; the latter have text wrap foramtting and "live" in a different layer from the text.
To insert a graphics file as a Shape:
Dim shp as Word.Shape
Set shp = oDoc.Shapes.AddPicture(FileName, LinkToFile, _
SaveWithDocument, Left, Top, Width, Height, Anchor)
The AddPicture method returns a Shape object. Often, this is useful when additional properties need to be set after the object has been inserted. For example in order to specify the text wrap formatting. If no Shape object is required a Shape can be inserted without assigning to an object. In this case, leave out the parentheses:
oDoc.Shapes.AddPicture FileName, LinkToFile, _
SaveWithDocument, Left, Top, Width, Height, Anchor
While only the FileName argument is required, the last argument - Anchor - is very important if you want to control where the image is positioned when it's inserted.
It's also possible to insert as an InlineShape then use ConvertToShape in order to have a Shape object to which text wrap formatting can be applied.
Every Shape must be associated with a Range in the document. Unless otherwise specified, this will be the first character of the paragraph wherein the current selection is. I strongly recommend passing a Range to the Shapes.AddPicture method in the Anchor argument for this reason.
Note that once a Shape has been inserted there's no direct way to change the anchor position. It can be done using cut & paste. Another possibility is to use the ConvertToInlineShape method so that you can work with the Range to move the graphic, then ConvertToShape to turn it back into a Shape, but in this case a number of positioning and wrap properties may need to be reset. Here an example of using the "convert" methods:
Sub MoveShapeToOtherRange()
Dim oDoc As Word.Document
Dim shp As Word.Shape
Dim ils As Word.InlineShape
Dim rngEnd As Word.Range, rngStart As Word.Range
Set oDoc = ActiveDocument
Set rngStart = oDoc.content
rngStart.Collapse wdCollapseStart 'start of document
Set rngEnd = Selection.Range
Set shp = oDoc.shapes.AddPicture(fileName:="C:\Test\icons\Addin_Icon16x16.png", _
Top:=0, Left:=10, anchor:=rngStart)
Set ils = shp.ConvertToInlineShape
Set rngStart = ils.Range
rngEnd.FormattedText = rngStart.FormattedText
rngStart.Delete
Set ils = oDoc.InlineShapes(1)
Set shp = ils.ConvertToShape
End Sub
By default, a Shape will insert with MoveWithText activated. That means the position on the page is not set, editing will affect the vertical position. If you want the Shape to always be centered on the page, for example, set this to false. Note, however, that if the anchor point moves to a different page, the Shape will also move to that page.
On occasion, the Left and Top arguments don't "take" when adding a Shape - you may need to set these again as properties after adding it.
Ok, What I ended up doing that worked was this:
Dim a As Object
On Error Resume Next
a = oDoc.Shapes.AddPicture("C:\Users\name\Desktop\file.jpg", , , 25, 25, 25, 25)
For some reason, This places the image at the position and size. When I looked at the docs for ".AddPicture" I realized it returns a Shapes object. So I just had it store it in a throw-away object. For some reason it then would respond with an error, but would end up placing on the doc anyways. So I used:
On Error Resume Next
This skips the error. After that, the picture places as expected and the rest of the doc is made as expected
Thank you for your answers

How can I change the font (not cell!) colour with an IF-condition?

I know how I can change the colour of a cell with the help of conditional formatting. But I would like to use a formula to achieve the following goal.
If a value <5.00% is entered into A2 via a formula, I want it to be displayed in Red 3. If it is >=5.00%, I would like it to be displayed in Green 3. Analogously, the same is true for A3/A4/A5 compared with B3/B4/B5.
STYLE is used for background colours.
I have also stumbled upon this solution, but it is suited for text replacement and not for my purpose. After creating two new custom styles, I have tried =T(STYLE(IF(A2<B2;"Red_if_lesser";"Green_if_greater_or_equal"))), but it has delivered an error (Err:522). What do I have to add to this formula in order to make it work?
For conditional formatting, it doesn’t matter if the cell value is calculated or it’s a fixed value. All you need to do is to define the appropriate rules for conditional formatting. In your case, you'll have to define two rules, one for current values < plan values, and one forcurrent values >= plan values. To change the font colour, define two new cell styles (can be done inside the conditional formatting dialogue), with an appropriate font colour:
Let’s start with the following data:
Select the cells that should be formatted based on their content. Pay attention that they are marked in this way:
Start defining the conditional formatting:
First rule: Cell value is less than B2 – apply a new style:
Set the Font Color for the new style in the Font Effects tab:
Add another formatting rule using the Add button – now with green font color:
Et voilà – the result:

Change default CSS class of Table component on SAPUI

I'm using sap.m.Table component. I'v noticed that my cells have default css class sapMListTblCell nd hegight of rows look me very large:
I want height of rows is more adjusted to cell's content.
I've seen this example. In it cells have another css class: sapUiTableTd
I want my cells of my table have that css class. I think I should change css class of my table to sapUiTableCnt (like the example). But it doesn't work.
Please, someone could tell me What I should do?
The cells have that height because UI5 is mobile first - controls are optimized for working on mobile phones. The spacing / size of various controls depends on a so called content density. Normally, you should check whether or not the user is using a mobile device and set the corresponding content density to your root view. By convention, this check is done inside the Component and then called by the root view's controller.
So, setting a compact density class would most likely solve your problem. You can also create your own density class specifically for tables (and other controls that you may want to target). You can set the compact density and specify e.g. the height of the cells:
CSS style:
.sapUiSizeCompact.myCustomSize .sapMListTblCell {
height: 1rem
}
View:
<Table class="sapUiSizeCompact myCustomSize" />
You can find a working version here (comparison between cozy, compact and our custom density class): https://jsfiddle.net/z2gkvde0/1/.

Bokeh - How to use box tool without default selections?

I have built a bokeh app that allows users to select windows in data and run python code to find and label (with markers) extreme values within these limits. For ease of interaction, I use the box select tool for the range selection. My problem arises when repeating this process for subsequent cases. After markers are placed for the results, they are rendered invisible by setting alpha to zero and another case needs to be chosen. When the new select box includes previous markers, they become visible based on the selection. How do I override this default behavior? Can markers be made unselectable? or can I add code to the customJS to hide them after they are selected?
Thanks in advance for any help!
There are a few possible approaches. If you just want non-selected glyphs to "disappear" visually, you can set a policy to do that as described here:
http://docs.bokeh.org/en/latest/docs/user_guide/styling.html#selected-and-unselected-glyphs
Basically, for bokeh.plotting, pass
nonselection_fill_alpha=0.0,
nonselection_line_alpha=0.0,
as arguments to your plot.circle call or whatever. Or if you are using the low level bokeh.models interface, something like:
renderer.nonselection_glyph = Circle(fill_alpha=0.0, line_alpha=0.0)
But be aware (I think you already are) that the invisible markers are still there, and still selectable if the user happens to draw a box over them with the selection tool.
If you truly want only a subset of the data to be visible and selectable after a selection, I'd say you want to replace the data in the column data source wholesale with the subset in your selection callback.

Using Jasper ContitionalStyles with named style references

I've got a situation where I create a report based on jrxml-files generated programmaitically and a style template with a given name and given style names. This works fine up to the point where there are conditional styles. Every example I found just uses ConditionalStyles to change some value like setting a different backcolor for specific situations. This can't be done here since there is no way of knowing what separates an even row style from an odd row style. Like wheter an odd row will get a gray background or an even row will get a green foreground and a black bottom pen.
What I tried or looked at:
Using Conditional Styles - There seems to be no way of defining a style reference just to change style values
Using a Variable for the style name - The variable didn't get evaluated
Creating a style with 2 ConditionalStyles using even and odd styles as parent styles - these were ignored when creating the jrtx-file
So... is there a way to create alternate styled rows using style references? If yes how it is done?
As there seems no solution to this, we had to change the structure of the style-files to include the conditional style instead of doing this in the document.
When walking this path and trying to change or create these style-files programmatically, be aware that in the JRXmlTemplateWriter that comes with Jasper, the method toWriteConditionalStyles is implemented as:
protected boolean toWriteConditionalStyles() {
return false;
}
Which is unfortunate. You'll have to use your own Exporter that changes this behavior.
Simply the way of knowing what separates an even row style from an odd row style.
Even row will satisfy the condition
(($V{REPORT_COUNT}%2) == 0)
Odd row will satisfy the condition
(($V{REPORT_COUNT}%2) != 0)
Then you can use a Conditional Styles with above conditions