How can graphic objects be drawn in AnyLogic during runtime? - anylogic

I am trying to add reactangles to the graphic screen in Anylogic during runtime. This is what I have so far:
ShapeRectangle a = new ShapeRectangle(SHAPE_DRAW_2D ,true,
10,
10,
2,
0,
black,
black,
20,
20,
5,
0.5,
LINE_STYLE_SOLID);
I bet the object is created. However, it is not printed on the canvas. How can I do that?

You are just missing that you need to add the shape to the presentation like this:
presentation.add(a);

Related

is it possible for syncfusion chart plotband to have a dynamic associatedAxisEnd value?

I want to be able to have a vertical line from the x-axis to the height of the y value, which is dynamic as it is being taken from a database.
example: for the data point 1 Jan, I want to have a plotband associatedAxisEnd of 45 , 2 Jan associatedAxisEnd of 65 etc...
I'm only able to create a constant associatedAxisEnd height currently, is there a way to be able to loop through the chart data and set the associatedAxisEnd height dynamically?
primaryXAxis: CategoryAxis(
axisLine: const AxisLine(width: 3),
majorGridLines: const MajorGridLines(width: 0,
color: Colors.transparent),
plotBands:
<PlotBand>[
PlotBand(
isVisible: true,
isRepeatable: true,
repeatEvery: 2,
size: 1,
borderWidth: 1,
repeatUntil: 6,
associatedAxisEnd: 50, // is it possible to have a loop on this line?
borderColor: Colors.grey,
dashArray : const <double>[5, 5]
),
]
)
You cannot have a loop when setting values for the PlotBand’s associatedAxisEnd property. However, you can achieve your requirement by adding individual plot band lines for the chart data points as per required.
We have created a simple sample in which we have added plot band lines for the chart data points by lopping through the chart data and attached the sample below for reference. Also appended the user guide documentation link for plot line rendering below for reference.
https://help.syncfusion.com/flutter/cartesian-charts/axis-customization#plot-line
Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/i404038-1323531402

How to show/hide labels according to zoom levels with expressions in mapbox-gl-js / maplibre-gl?

I have a point layer with an icon, and I would like to display the labels in addition to the icon only from a certain zoom level (9). I would like to avoid creating a dedicated label layer. Looking at the expression documentation, Stet and Zoom should give me the desired result, but it doesn't work.
Following this answer, I try to change the size of the text depending on the zoom level, but no matter the zoom, the text will always have the default size (here 7)
Am I missing something or is it a bug? I'm using Maplibre
layout: {
"icon-image": "border_crossing",
"icon-size": 0.5,
"icon-allow-overlap": true,
'text-field': ['get', 'loc_type'],
'text-variable-anchor': ['top'],
'text-radial-offset': 0.5,
'text-justify': 'auto',
"text-size": [ "step",
["zoom"],
0,0,
9,15,
7
]
}
There are various ways. One would be:
'text-field`: ["step", ["zoom"], "", 9, ["get", "loc_type"]]
It looks like you had a bug in your step code.

FL Chart vertical dotted lines independent from dots

I am using FLChart in my app to display some charts. That is working just fine. However I would like to be able to draw some vertical dotted lines into my graph like this:
As you can see, some of them should also have Numbers on top of them. Ive searched for quite some time now but could not find anything like this.
I found somehting similar looking on their example :
But it is not quite the same. The lines should be independent from any dots. Is that possible?
If I understand your goal correctly, you simply want to get the result of the given example except for the dots for each data point.
You can get rid of the points by changing the FlDotData passed to the TouchedSpotIndicatorData. Going back to the example code you linked, you could replace:
FlDotData(
show: true,
getDotPainter: (spot, percent, barData, index) =>
FlDotCirclePainter(
radius: 8,
color: lerpGradient(
barData.colors,
barData.colorStops!,
percent / 100,
),
strokeWidth: 2,
strokeColor: Colors.black,
),
),
with:
FlDotData(
show: false,
)
You can draw vertical dotted line with this code snippet. Line chart data has property named extraLinesData. You can use it like below.
return LineChartData(
extraLinesData: ExtraLinesData(verticalLines: <VerticalLine>[
VerticalLine(x: 2, color: Constants.PRIMARY_COLOR_1, dashArray: [4,4]),
],) ...,

FPDF align values on right

I am using FPDF to generate a report, and i need to align the number on right taking the number on top(Year) by reference.
But I am having a problem on this align.
If i use a function Cell like this:
$pdf->Cell(0,5,$alue,'B',1,'D');
All values stay on right Overlapping.
I tried to use a function SetX but did not changed anything.
how it is now
Take a look at the documentation. It states that:
Cell width. If 0, the cell extends up to the right margin.
Since you're right-aligning your text and your Cell sits on the right margin of the page, it makes sense that it does not align properly.
Try specifying a width for your cell. For example, replace your example line of code with:
$pdf->Cell(50,5,$alue,'B',1,'D');
<?php
//right align
$pdf->Cell(50, 5, $alue, 0, 0, 'R' );
//Left Align
$pdf->Cell(50, 5, $alue, 0, 0, 'L' );
//Center Align
$pdf->Cell(50, 5, $alue, 0, 0, 'C' );
?>

Layer created is empty even after assigning content to it

I just trying to do a quick prototype following this tutorial:
https://www.youtube.com/watch?v=3zaxrXK7Nac
I'm using my own design for this, the problem is as follows:
When I create a new layer time 8:13 of the posted video and I try to set one of my imported layers as the content of this new layer by using the property image, I get no results.
If I bring this new layer to the screen I can only see black background with transparency, according to the tutorial, it should has the layer I'm assign to it via the image property.
Here is an example of my code:
sketch = Framer.Importer.load("imported/Untitled#2x")
explore_layer = new Layer
width: 750
height: 1334
image: sketch.explore.explore_group
x: screen.width
sketch.Tab_3.on Events.Click, ->
explore_layer.animate
properties:
x: 0
y: 0
curve: "spring(400, 35, 0)"
Here is also a screenshot of my layers
https://gyazo.com/f3fccf7f38813744ea17d259463fabdc
Framer will always import the groups in the selected page of Sketch, and all the groups on that page will transformed into layers that are available on the sketch object directly.
Also: you're now setting the image of a layer to a layer object itself, instead of the image of the sketch layer.
So to get it to work, you need to do a couple of things:
Place all the elements that you want to use on the same page in Sketch
After importing, access those elements directly from the sketch object (so sketch.explore_group instead of sketch.explore.explore_group)
Use the image of the sketch layer, or use the sketch layer itself in your prototype.
Here's an example how it that would look:
sketch = Framer.Importer.load("imported/Untitled#2x")
explore_layer = new Layer
width: 750
height: 1334
image: sketch.explore_group.image
x: screen.width
sketch.Tab_3.on Events.Click, ->
explore_layer.animate
properties:
x: 0
y: 0
curve: "spring(400, 35, 0)"
Or even shorter, and with an updated animation syntax:
sketch = Framer.Importer.load("imported/Untitled#2x")
sketch.explore_group.x = screen.width
sketch.Tab_3.on Events.Click, ->
sketch.explore_group.animate
x: 0
y: 0
options:
curve: Spring(tension:400, friction:35)