Is there a way to place node name to the right in PlantUML? - plantuml

To increase readability I would like to place (interface) node names to the right of the node. Is this somehow possible?
#startuml
left to right direction
() "longer_interface_name" as interface
[component one] --> interface
[component two] --> interface
[component three] --> interface
[component four] --> interface
[component five] --> interface
#enduml
leads to
but I'd like to have something like

Related

Can states in a Plant UML state diagram be positioned relative to another state?

I've made a plantuml state diagram which looks like this:
I'd like to position "MainActivity" state to the right of the "Idle" state, such that the arrows for [instruction] and [done] end up horizontal.
I know this is can be done for notes and text, but I haven't seen any syntax for the states themselves.
Is this possible in PlantUML?
For reference, this is my PlantUML script:
#startuml
skinparam state {
StartColor PaleGreen
EndColor Red
BackgroundColor Gold
BackgroundColor<<Junction>> GreenYellow
BorderColor Gray
FontName Consolas
}
[*] -> Creating
Creating --> Idle : initialised
Idle : wait here for instructions
Idle --> MainActivity : [instruction]
state MainActivity {
[*] --> DoFirstThing
DoFirstThing --> FirstThingSuccess : [OK]
DoFirstThing --> FirstThingFailed : [not OK]
FirstThingSuccess --> SecondThing
SecondThing --> SecondThingFailed
SecondThing --> SecondThingSuccess
SecondThingSuccess --> WritingReport
SecondThingFailed --> WritingReport
FirstThingFailed --> WritingReport
WritingReport --> [*]
}
MainActivity --> Idle : [done]
#enduml
Yes. You can define the direction of the arrows by inserting them in between the dashes of the arrow notation, such as "MainActivity -left-> Idle" (see section 7.5 in the PlantUML reference guide).
The following code :
plantuml
#startuml
skinparam state {
StartColor PaleGreen
EndColor Red
BackgroundColor Gold
BackgroundColor<<Junction>> GreenYellow
BorderColor Gray
FontName Consolas
}
[*] -> Creating
Creating --> Idle : initialised
Idle : wait here for instructions
Idle -left-> MainActivity : [instruction]
state MainActivity {
[*] --> DoFirstThing
DoFirstThing --> FirstThingSuccess : [OK]
DoFirstThing --> FirstThingFailed : [not OK]
FirstThingSuccess --> SecondThing
SecondThing --> SecondThingFailed
SecondThing --> SecondThingSuccess
SecondThingSuccess --> WritingReport
SecondThingFailed --> WritingReport
FirstThingFailed --> WritingReport
WritingReport --> [*]
}
MainActivity -left-> Idle : [done]
#enduml
gives you this diagramme :
(PS : You could do the same for the "Creating" state to make it look more consisten)

In clojurescript, how to evaluate a list

Suppose having
(def defining-list `(def one 1))
How can I evaluate defining-list so that one becomes 1 ?
(in clojurescript)
EDIT:
I will give an idea of the broader image and what I am trying to accomplish here to avoid falling into an X/y problem.
I am trying to use cljsjs/material-ui from cljsjs package
Instead of defining each time a react component to use it as following:
(def app-bar
(r/adapt-react-class (aget js/MaterialUI (name :AppBar)))
I would like to define all the components from an array of tags:
(def material-ui-tags '[AppBar Avatar Backdrop])
So I was thinking if it's possible to do this without the usage of a macro as I found this
Something like:
(doseq [component material-ui-tags]
`(def ~(symbol (->kebab-case component)) (r/adapt-react-class (aget js/MaterialUI ~(name component)))))
But the above does only create a list of defs, I would like to evaluate these. In clojure eval would do the trick.
With reagent, you can use :> as shorthand for adapt-react-class as documented in https://github.com/reagent-project/reagent/blob/master/docs/InteropWithReact.md
Also, you can use dot notation with js/ and I think in shadow-cljs or cljs above 1.9.854 you can require to import the symbol instead of using aget.
In your case, it would be something like:
(ns example.core
(:require [MaterialUI]))
(defn component-two []
[:> MaterialUI/AppBar {:some-prop "some-value"}
[:div "children-here"]])
(defn component-two []
;; If the require above doesn't work
[:> js/MaterialUI.AppBar {:some-prop "some-value"}
[:div "children-here"]])
To do what you wanted using def, you either need eval or macro. Eval is not ideal as Jared Smith explained in the comment.
The example that you linked from reagent-material-ui uses macro. Invoking a macro actually performs expansion and then evaluation. So your code needs to be something like this:
clj file
(def material-ui-tags '[AppBar Avatar Backdrop])
(defmacro adapt-components []
(for [component material-ui-tags]
`(def ~(symbol (->kebab-case component)) (reagent.core/adapt-react-class (aget js/MaterialUI ~(name component))))))
cljs file
(adapt-components) ;; your defs will be available below this line
(defn my-component []
[app-bar ...])

Abdera parser: how to acess element with different namespaces

Let's say I have an Atom entry like this:
<entry xmlns:custom="http://custom.xsd">
<title>test</title>
<custom:solution>42</custom:solution>
</entry>
If I load the entry into Apache Abdera, I get a nice org.apache.abdera.model.Entry instance. And I can now conveniently access all standard Atom elements with getters.
But how would I read the value 42 from the custom:solution element?
You can use something like:
for (Element element : (List<Element>)entry.getExtensions(" <UrI for custom namespace>")) {
System.out.println(element.getText());// gives you 42
}

Problems with navigating xml nodes to display in a datagrid

i am using WPF and a slightly unusual xml file which I am trying to use to populate a datagrid. Between the root node and the order node which repeats there are four nodes that are children of the root and appear only at the top that I cannot seem to navigate through to get to the order nodes. If i remove these first four nodes it populates as expected.
This is the xml that does not work:
<evec_api method="quicklook" version="2.0">
<quicklook>
<item>40</item>
<itemname>Megacyte</itemname>
<regions/><hours>360</hours>
<minqty>10001</minqty>
<sell_orders>
<order id="2686762970">
<region>10000002</region>
<station>60003760</station>
<station_name>Jita IV - Moon 4 - Caldari Navy Assembly Plant</station_name>
<security>0.9</security>
<range>32767</range>
<price>2534.98</price>
<vol_remain>750000</vol_remain>
<min_volume>1</min_volume>
<expires>2013-03-13</expires>
<reported_time>12-13 10:54:11</reported_time>
</order>
<order id="2686763351">
<region>10000002</region>
<station>60003760</station>
<station_name>Jita IV - Moon 4 - Caldari Navy Assembly Plant</station_name>
<security>0.9</security>
<range>32767</range>
<price>2545.99</price>
<vol_remain>709273</vol_remain>
<min_volume>1</min_volume>
<expires>2013-03-13</expires>
<reported_time>12-13 10:54:11</reported_time>
</order>
</sell_orders>
</quicklook>
</evec_api>
XAML(that doesn't work with the above):
<DataGrid x:Name="grid" ItemsSource="{Binding Path=Element
Element[item].Element[itemname].Element[regions].Element[minqty]
.Element[sell_orders].Elements[order]}">
This is the xml minus the first four nodes that does work:
<evec_api method="quicklook" version="2.0">
<quicklook>
<sell_orders>
<order id="2686762970">
<region>10000002</region>
<station>60003760</station>
<station_name>Jita IV - Moon 4 - Caldari Navy Assembly Plant</station_name>
<security>0.9</security>
<range>32767</range>
<price>2534.98</price>
<vol_remain>750000</vol_remain>
<min_volume>1</min_volume>
<expires>2013-03-13</expires>
<reported_time>12-13 10:54:11</reported_time>
</order>
<order id="2686763351">
<region>10000002</region>
<station>60003760</station>
<station_name>Jita IV - Moon 4 - Caldari Navy Assembly Plant</station_name>
<security>0.9</security>
<range>32767</range>
<price>2545.99</price>
<vol_remain>709273</vol_remain>
<min_volume>1</min_volume>
<expires>2013-03-13</expires>
<reported_time>12-13 10:54:11</reported_time>
</order>
</sell_orders>
</quicklook>
</evec_api>
XAML(that works with the xml above):
<DataGrid x:Name="grid" ItemsSource="{Binding Path=Element
[quicklook].Element[sell_orders].Elements[order]}">
Any help would be appreciated.
you dont have to navigate through those not needed tags so your last binding should work for both xmls
good luck

xsl-fo header - image left, three lines of text right, top aligned

Using apache FOP, want to create a header with a logo aligned left, three-line address aligned right, both aligned top.
Following works ok if done inside of flow, but in a static-content header ('xsl-region-before') it gets the left & right correct but aligns the logo below the address block, as if the table definition were being ignored completely.
I've tried other options, like trying to inline the two, or use floats, with similar results. The header just treats them like separate blocks and stacks them. Anyone have any suggestions?
I found this other issue asking the same question about footers, alas no replies:
Need instream-foreign-object and text to both align to the bottom in XSL-FO
Relevant snippet follows:
<fo:layout-master-set>
<fo:simple-page-master page-height="8.5in" page-width="11in" master-name="only" margin=".5in .5in .5in .5in">
<fo:region-body region-name="xsl-region-body" margin-top="1in" margin-bottom=".5in"/>
<fo:region-before region-name="xsl-region-before"/>
<fo:region-after region-name="xsl-region-after"/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="only">
<fo:static-content flow-name="xsl-region-before">
<fo:block font-size="7pt">
<fo:table width="10in">
<fo:table-column/>
<fo:table-column/>
<fo:table-body>
<fo:table-row>
<fo:table-cell>
<fo:block>
<fo:external-graphic src="img/print_logo.png" content-width="2in"/>
</fo:block>
</fo:table-cell>
<fo:table-cell display-align="center">
<fo:block text-align="right">
123 Credibility Street
</fo:block>
<fo:block text-align="right">
Chicago, IL 60606
</fo:block>
<fo:block text-align="right">
312-123-4567
</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
</fo:block>
</fo:static-content>
I managed to achieve the desired effect by putting the two elements in two separate block-containers with absolute positioning:
<fo:static-content flow-name="xsl-region-before">
<fo:block-container position="absolute">
<fo:block>
<fo:external-graphic src="img/print_logo.png" content-width="2in"/>
</fo:block>
</fo:block-container>
<fo:block-container position="absolute">
<fo:block text-align="right">
123 Credibility Street
</fo:block>
<fo:block text-align="right">
Chicago, IL 60606
</fo:block>
<fo:block text-align="right">
312-123-4567
</fo:block>
</fo:block-container>
</fo:static-content>
It's late to reply, but query must be answered. So here is it:
Yes, absolute positioning is required here, but more important is the sequence of block-container you place.
The contents with last container will be on top of others.

Resources