How do I avoid labels overflowing container boundaries with PlantUML? - plantuml

I'm trying to find a way to make sure labels of items in a container do not overflow or overlap container boundaries. So far I could not find any setting that would help.
This content:
#startuml
left to right direction
node "inner" {
()XyzAdapter
}
node "inner-impl" {
[XTXAdapter] - XyzAdapter
}
node "Other Groups" {
FTP - [Second Component]
[First Component] --> FTP
}
#enduml
Creates the following rendering in every online/offline PlantUML setup I could get my hands on:
As you can see, both FTP and XyzAdapter are rendered without any concern for their container boundaries.
It is even worse from within Vs. Code using the PlantUML plugin because it also decreases the space between containers.
Are there any parameters or tricks I can use to avoid this? You can use both liveuml and planttext to observe this behaviour.

If you do not insist on keeping the exact same layout, you could add another dash ("-") where you have only used one in order to have two dashes for all your edges. That renders a diagram like the one below with all labels being legible.
#startuml
left to right direction
node "inner" {
()XyzAdapter
}
node "inner-impl" {
[XTXAdapter] -- XyzAdapter
}
node "Other Groups" {
FTP -- [Second Component]
[First Component] --> FTP
}
#enduml

Related

What is the purpose of some fields in DSL in Dasha?

I want to know for what we need following fields:
node
do
digression
disable
goto
next
transitions
set
exit
node call_reason
{
do
{
digression disable sayHi;
goto next;
}
transitions
{
next: goto how_are_you;
}
}
I suppose, you are asking this question because you are a little bit confused about syntax, I'll try to make it clear.
Nodes and Transitions
DashaScript is the language for describing automated conversations. Basically, any conversation script consists of
nodes - states of your conversation (please, see node doc)
transitions - relations between nodes that are described by conditions of switching from the current node to the another. There are three different kinds of transitions, e.g. instant transition that is used in code of your example (please, see transitions doc).
In some sense, the scripted conversation can be thought of as a graph. In this case, nodes and transitions can be interpreted as vertices and edges of a graph, respectively.
Hence, node and transition define the structure of your conversation script.
Every node has subsection do where you can specify actions and instructions you want to be performed in this particular node.
Also, node may have subsection transitions which is used to specify conditions of switching a current state to another.
Every event-transition (like transition on event and timer transition) specified in this section has the following syntax: <transition_name>: goto <node_name> on <switching_condition>.
Instant transitions (like the one used in your code) have no conditions: <transition_name>: goto <node_name>. To execute such transition, it must be called in section do of current node with goto instruction.
Also, there are special nodes that can be visited from any state. These nodes are called digressions. (see digressions doc). They are used to make fast reactions in your conversation and return to main branch of conversation. To control digression, we have mechanism of enabling/disabling them (see digression-control doc).
So, in your example, the node with name call_reason has section do where you disable degression-node and then instant transition with name next is executed.
All entities of DashaScript language mentioned above are described in program structure docs. I would recommend you to check it out, since there are more important entities that you might need to know about.
Set
set is the instruction that is used for assigning a value for some variable. Example:
node some_node
{
do {
var some_variable: number = 1;
set some_variable = 2; // now some_variable has value of 2
}
}
Exit
exit is the instruction that interrupts the dialog.

PlantUml define relative position of components

I'm actually trying to generate a component diagram with PlantUml. Is it possible to define the relative position of the different components? What I want to define is: ComponentB is left from ComponentA. ComponentC is below ComponentA, ...
A typical approach is to mark a line as hidden.
One thing to keep in mind is that hidden is only supported for left-to-right ->, and top-to-bottom --> lines, so you need to place the left and right side accordingly (syntax X <[hidden]- Y doesn't seem to be supported).
#startuml
class ComponentA
ComponentB -[hidden]> ComponentA
ComponentA -[hidden]-> ComponentC
#enduml
See also How to correct PlantUML Line Path for more positioning tips.
You can follow guidelines from here:
Layout of grouping component
In general when you write connections like -> you just have to know that there is special notation for right arrow, left arrow, bottom arrow, top arrow:
This has special meaning for plantUml:
-l->
-r->
-u->
-d->
It means to place arrow on the left or right or up or down if possible.
Lets imagine this diagram:
#startuml
node "My system" {
[A] -> [B]
[C] -> [B]
}
#enduml
This looks horrible, you can fix this by directing PlanUml with arrow directions.
#startuml
node "My system" {
[A] -d-> [B]
[C] -r-> [B]
}
#enduml
Will generate this:

I want to conditionally split a List if exxchange is a List and continue processing

I'm trying to conditionally split an exchange into its contents if it is a List, otherwise leave it as a single item and have both go to the same processor
I ideally do not want to set up lots of inbetween direct:endpoints to achieve this
from( X )
.when( body().isInstanceOf( List.class )
.split( body() )
.setHeader( "x", constant( "I don't care " ) // this needs to be set as split must have at least one child node
.process( ? ) // here the exchange.in.body is now a single item from the List // this is what I want to continue outside of this when block
.end() // also tried .end().end() and .endChoice()
.process( ... ) // here the exchange in is a List again, I want it to be the single items, split
I do not understand why the exchange is not left as single units, that is how it becomes a List again when it leaves the when 'block'.
I get the feeling Camel 'expects' me to use direct:endpoints to achieve this, but I find readability decreases quickly the more direct points are used and want to avoid them if possible.
Currently the way camel's split component is setup only the code underneath a list will process as individual records. Once you close the split block you are back to a single exchange. The only way to break that up would be to leverage a mid point like a direct endpoint. If you want to break up the logic you can always create separate route builder classes. The other option is to request a feature on the forums.
Use the aggregation strategy on the splitter to build the output you want from the splitter. There you can store the splitted sub message you want, instead of the original message that the splitter uses today.

PostGIS's st_overlaps method is only returning results overlapping the LinearRing which makes up the exterior of the polygon I'm searching under

I'm using PostGIS on ruby/rails, and have created a simple box-like polygon under which I wish to search for land parcels in a county. The st_overlaps tool has worked for this before and it has worked this time, sort of.
So I created the polygon to search for parcels (multi-polygons, as it turns out) underneath it
factory = RGeo::Cartesian.factory
coords = [[1554780, 1101102], [1561921, 1062647], [1634713, 1097531], [1630867, 1140657]]
points = coords.map { |pair| RGeo::WKRep::WKTParser.new.parse("POINT (#{pair.first} #{pair.last})") }
ring = factory.linear_ring(points)
polygon = factory.polygon(ring)
After running the active record call:
Parcel.where{st_overlaps(:parcel_multipolygon, polygon)}
I get 157 results. Far less than expected. I exported them a kml file using a custom script of mine. I will upload it soon for viewing.
What you'll see in that kml once loaded in Google Earth, is a parallelogram of pins marking parcels whose areas (polygons) are clearly saddling the outer ring of the parameter-polygon I created to search under. There are so many parcels along these invisible lines in such a clear, distinct shape, the fact that there are no pins in the middle of the shape clearly indicate that the search results were only at the overlappings of parcel multipolygons with the exterior edges (LinearRing) of the search polygon.
Based on my re-reading of the documentation for st_overlaps, I'm left puzzled as to what seems to be the problem here.
Here's a link to view the kmz export. (coordinates converted to geographic before export). You can view it in your browser. The search-polygon itself is not included, but its easy to see where its exterior ring is
https://docs.google.com/file/d/0B5inC0VAuhH1TXdTbWQ2RngxZk0/edit?usp=sharing
I think it is behaving as expected. St_overlaps will give features that actually lie on top of each other. If you want all features inside the polygon try ST_Intersects.

Question about web programming, maps to be specific

The prof gave us an assigment to finish in the next couple of months, we have to write a web app that is basically a mapping system for a floor of a building. Like a very very simple version of google maps, people need to be able to look up a room and be able to get directions from one part of the floor to another. I have never done any major web programming and don't even know how to start. Is there a google maps or mapquest API that I can use or do I have to start it from scratch? I'm not asking anyone to solve it for me, just nudge me in the right direction so as where to start.
I would suggest thinking of the task as three parts:
Displaying the image of the map
(probably, for best efficiency, as
lazily-loaded tiles like Google Maps
does)
Representing the rooms and the
connections between them, probably
as a graph. Using a graph
allows you to easily use a
well-documented algorithm like
A* or Dijkstra's to find
the shortest route from point A to
point B.
Converting from a click on the image
to a node on the graph, and from a
node on the graph to a point in the
image. Probably each node should
just store a pair of (x,y)
coordinates.
With an arrangement like this, all your code has to do is:
The first time the user clicks
{
Identify the nearest node to their click as node A;
}
The second time the user clicks
{
Identify the nearest node to their click as node B;
Use Dijkstras Algorithm or A* to find the shortest route from node A to node B;
For each edge in the resulting route
{
Add a line to the image of the map;
}
Mark node A with a green dot and node B with a red dot (or something);
}

Resources