Intersection of objects in a UML diagram when one element belongs to two groups - plantuml

Please tell me how to make [VirtualService] as VS in this code so that it is both in the "Ingress" group and in the "Application" group. it turns out that the intersection and the component [VirtualService] can be either in the "Ingress" group, or in the "Application", and you need both there and there. Help please
#startuml
' Remove shadows
skinparam shadowing false
skinparam BackgroundColor transparent
skinparam componentStyle rectangle
skinparam roundCorner 15
left to right direction
skinparam linetype polyline
skinparam linetype ortho
И3#transparent;line:transparent;text:transparent
rectangle "Кластер OpenShift" #MOTIVATION {
component "Точка входа" as TV #white{
[Rout] as ROUT #grey;text:white
И3->ROUT #blue
И3<..ROUT #blue
}
rectangle "OS Namespase" as OS #white {
component Application as PR #LightPink {
[VirtualService] as VS #grey;text:white
[App Service] as AS #grey;text:white
[App\nPod] as AP
}
component Ingress as IG #LightSkyBlue {
[Ingress\nService] as IS #grey;text:white
[Geteway)] as G #grey;text:white
[Ingress\nPod] as IP
[VirtualService] as VS #grey;text:white
}
component Приложение as PR #LightPink {
[VirtualService] as VS #grey;text:white
[App Service] as AS #grey;text:white
[App\nPod] as AP
}
}
}
ROUT ->IS #blue
ROUT <.. IS #blue
IS ->G #blue
IS <..G #blue
G->IP #blue
G<..IP #blue
IP->VS #blue
IP<..VS #blue
VS->AS #blue
VS<..AS #blue
AS->AP #blue
AS<..AP #blue
#enduml

Since GraphViz is the underlying engine, it's not possible (see this answer).
However, you could be creative and create a shared group that has both colors.
#startuml
' Remove shadows
skinparam shadowing false
skinparam BackgroundColor transparent
skinparam componentStyle rectangle
skinparam roundCorner 0
left to right direction
skinparam linetype ortho
И3#transparent;line:transparent;text:transparent
rectangle "Кластер OpenShift" #MOTIVATION {
component "Точка входа" as TV #white{
[Rout] as ROUT #grey;text:white
И3->ROUT #blue
И3<..ROUT #blue
}
rectangle "OS Namespace" as OS #white {
rectangle Application as PR #LightPink;line:transparent {
[App Service] as AS #grey;text:white
[App\nPod] as AP
}
rectangle Ingress as IG #LightSkyBlue;line:transparent {
[Ingress\nService] as IS #grey;text:white
[Gateway] as G #grey;text:white
[Ingress\nPod] as IP
}
rectangle "//(shared)//\n" as hidden #LightSkyBlue|LightPink;line:transparent{
[VirtualService] as VS #grey;text:white
}
}
}
ROUT ->IS #blue
ROUT <.. IS #blue
IS ->G #blue
IS <..G #blue
G-> IP #blue
G<..IP #blue
IP->VS #blue
IP<..VS #blue
VS->AS #blue
VS<..AS #blue
AS->AP #blue
AS<..AP #blue
#enduml

Related

Scaling part of a PlantUML diagram

Scaling is controlled by the scale keyword. I'm curious if it's possible to scale part of a PlantUML diagram somehow or at the very least: scale the font size for part of a diagram.
It doesn't seem like scale may be scoped to part of a diagram (and I have not found any examples that suggest that is possible). Conceivably it might be used in the following manner, but this example scales the entire image:
#startuml
package "Some Group" {
scale 0.5
HTTP - [First Component]
[Another Component]
}
node "Other Groups" {
FTP - [Second Component]
[First Component] --> FTP
}
#enduml
I do not think currently there is a way to achieve it. From the source code of the PlantUML scale command:
protected CommandExecutionResult executeArg(AbstractPSystem diagram, LineLocation location, RegexResult arg) {
double scale = Double.parseDouble(arg.get("SCALE", 0));
if (scale == 0) {
return CommandExecutionResult.error("Scale cannot be zero");
}
if (arg.get("DIV", 0) != null) {
final double div = Double.parseDouble(arg.get("DIV", 0));
if (div == 0) {
return CommandExecutionResult.error("Scale cannot be zero");
}
scale /= div;
}
diagram.setScale(new ScaleSimple(scale));
return CommandExecutionResult.ok();
}
The location of scale is not used, and PlantUML just sets the scale of diagram by diagram.setScale(new ScaleSimple(scale)).
You can verify this kind of action by:
#startuml
package "Some Group" {
scale 0.5
HTTP - [First Component]
[Another Component]
}
node "Other Groups" {
scale 5
FTP - [Second Component]
[First Component] --> FTP
}
#enduml
The scale 0.5 is overridden by the scale 5 command.

Reduce space between legend and chart in jfree Pie chart

I placed the legend in the top left corner and there is an unnecessary gap between the chart and the legend.
How to reduce this?
There is considerable amount of space between pie chart and its border.
public void setPie() {
RingPlot plot = (RingPlot) this.chart.getPlot();
plot.setSectionPaint("", WHITE_COLOR);
plot.setCircular(true);
plot.setShadowPaint(null);
}
public void setLegend() {
LegendTitle legend = this.chart.getLegend();
legend.setVerticalAlignment(VerticalAlignment.TOP);
legend.setVisible(true);
legend.setPosition(RectangleEdge.LEFT);
Rectangle rect = new Rectangle(LEGEND_LENGTH, LEGEND_WIDTH);
RingPlot plot = (RingPlot) this.chart.getPlot();
plot.setLegendItemShape((Shape) rect);
}
You could try tweaking the margins around the LegendTitle. Something like:
chart.getLegend().setMargin(top, left, bottom, right);
EDIT: As suggested in the post in the comments, you could try to draw the legend manually at a given position:
//Print legend at X & Y location
Rectangle2D r2DD = new Rectangle2D.Double(119, 47, 120, 180);
LegendTitle legend = new LegendTitle(chart.getPlot());
legendTitle.draw(g2,r2DD);
But I'm not sure how to implement it, as you need access to the ChartPanel's Graphics2D. Perhaps by extending ChartPanel and overriding paintComponent(Graphics g) ?

Prevent WPF Image in border from panning too far

I have a WPF Image inside a Border I currently am able to click and drag to pan the image. I want to prevent users from dragging the image off the screen. Perhaps a minimum of 100 pixels should be showing at any border. That is, if a user drags the image all the way to the left, most of the image will disappear, but 100 pixels will still be hanging out toward the left boundary of the border.
Here's my current code for the MouseMove and LeftClick event:
private void img_Box_MouseMove(object sender, MouseEventArgs e)
{
if (!img_Box.IsMouseCaptured) return;
var tt = (TranslateTransform)((TransformGroup)img_Box.RenderTransform).Children.First(tr => tr is TranslateTransform);
Vector v = start - e.GetPosition(img_Border);
tt.X = origin.X - v.X;
tt.Y = origin.Y - v.Y;
}
private void img_Box_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
img_Box.CaptureMouse();
var tt = (TranslateTransform)((TransformGroup)img_Box.RenderTransform).Children.First(tr => tr is TranslateTransform);
start = e.GetPosition(img_Border);
origin = new System.Windows.Point(tt.X, tt.Y);
}
I think I should be able to put a pretty simple condition on that to achieve my desired result, but I can't figure out what the condition should be.

Using Shift key Multi selection of checkbox( Find Controls within 2 points/ rectangle

In order to select multiple checkbox within Wrap panel using Shift Key.
Capturing the Mouse down event position on Shift Keydown, on second mouse down with shift keydown, getting the 2 positions of the selection, then Need to Select the checkbox control with in the selected area.
How do I find the controls within 2 positions (System.Window.Point) or System.Windows.rect. The following code is selecting all of the checkbox within the wrappanel(lesscolorpanel).
private System.Windows.Point startPoint;
System.Windows.Point checkpPoint;
private System.Windows.Point PointWhereMouseIs;
private void LessColourPanel_OnPreviewMouseDown(object sender, MouseButtonEventArgs e)
{
if (Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift))
{
if (startPoint == checkpPoint)
{
//GET THE MOUSE POSITION
startPoint = Mouse.GetPosition(lessColourPanel);
PointWhereMouseIs = checkpPoint;
}
else if(PointWhereMouseIs==checkpPoint)
{
//CAPTURE END MOUSE POSITION
PointWhereMouseIs = Mouse.GetPosition(lessColourPanel);
//FIND CONTROLS WIHIN RECTANGLE
Rect selareaRect = new Rect(startPoint, PointWhereMouseIs);
foreach (System.Windows.Controls.CheckBox chkitemBox in FindVisualChildren<System.Windows.Controls.CheckBox>(lessColourPanel))
{
var rectBounds = VisualTreeHelper.GetDescendantBounds(chkitemBox);
Vector vector = VisualTreeHelper.GetOffset(chkitemBox);
rectBounds.Offset(vector);
if (rectBounds.IntersectsWith(selareaRect))
{
chkitemBox.IsChecked = true;
}
}
startPoint = checkpPoint;
}
}
}
Got it, and for viewers refer Ashley Davis post
The credit goes to Ashley Davis.

Scroll with mousewheel and zoom image with panning

I would like to make a small silverlight app which displays one fairly large image which can be zoomed in by scrolling the mouse and then panned with the mouse.
it's similar to the function in google maps and i do not want to use deepzoom.
here is what i have at the moment. please keep in mind that this is my first silverlight app:
this app is just for me to see it's a good way to build in a website. so it's a demo app and therefor has bad variable names.
the initial image is 1800px width.
private void sc_MouseWheel(object sender, MouseWheelEventArgs e)
{
var st = (ScaleTransform)plaatje.RenderTransform;
double zoom = e.Delta > 0 ? .1 : -.1;
st.ScaleX += zoom;
st.ScaleY += zoom;
}
this works, but could use some smoothing and it's positioned top left and not centered.
the panning is like this:
found it # Pan & Zoom Image
and converted it to this below to work in silverlight
Point start;
Point origin;
bool captured = false;
private void plaatje_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
plaatje.CaptureMouse();
captured = true;
var tt = (TranslateTransform)((TransformGroup)plaatje.RenderTransform)
.Children.First(tr => tr is TranslateTransform);
start = e.GetPosition(canvasje);
origin = new Point(tt.X, tt.Y);
}
private void plaatje_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
plaatje.ReleaseMouseCapture();
captured = false;
}
private void plaatje_MouseMove(object sender, MouseEventArgs e)
{
if (!captured) return;
var tt = (TranslateTransform)((TransformGroup)plaatje.RenderTransform).Children.First(tr => tr is TranslateTransform);
double xVerschuiving = start.X - e.GetPosition(canvasje).X;
double yVerschuiving = start.Y - e.GetPosition(canvasje).Y;
tt.X = origin.X - xVerschuiving;
tt.Y = origin.Y - yVerschuiving;
}
so the scaling isn't smooth and the panning isn't working, because when i click it, the image disappears.
first thing I noticed was this:
var st = (ScaleTransform)plaatje.RenderTransform;
and
(TransformGroup)plaatje.RenderTransform
. So in one handler, you're casting "plaatje.RenderTransform" to ScaleTransform, in the other you're casting to TransformGroup?
This is probably causing an exception, making your image disappear.
For the zooming part, you might want to try setting the RenderTransformOrigin of the object you want to scale ("plaatje"?) to "0.5,0.5", meaning the center of the UI element. So the image will be scaled around its center point instead of its top left corner.
Cheers, Alex

Resources