Is there a way to force "Categorized" symbolization to use attributes in the table for e.g. color definition? - qgis

I have a map with a couple of dozen of different "categories" of polygons and would like to symbolize them using the "Categorized" symbolization in QGIS. Every category already has its color defined in a "fill_color" attribute within the table.
I would like the symbolization to honor that color definition instead of assigning some color of its own to the categories.
Is there a way to do this, without manually going through every category and changing its color?
I'm not a Python programmer, so if there is a possibility of programming this, it's beyond me.
The software itself does not offer the option to do what I need in "Categorized" symbolization, although you can do it in "Single Symbol". If you try it in "Categorized" it will let you do the same steps, but the program will nevertheless use colors of its own choosing.
Of course, if I go the "Single Symbol" way, I can't generate a proper legend of map units in Layout.

Related

AnyLogic - make many edit boxes visible depending on variable

Here is a simplified example of my problem:
I want to make the edit box 1 or 2 visible, depending on whether a checkbox of box 1 or box 2 is checked. The variables "variableCheckbox1" and "variableCheckbox2" are connected to the respective ceckboxes.
I have written a function as shown in the picture. The function is called from the EditBox 1 ("Enabled"). This is a possible solution for ONE box each.
Does anyone have an idea if there is a more elegant way to do this for a very high number of checkboxes / edit boxes?
A possible solution would be to write a function with a switch case for each variable in my model, called from each box. A very inelegant solution would be to make a single function for each box, but I don't consider that a good way.
If you want this for a large number, turn the entire setup into its own agent type: Checkbox and editbox. Instantiate as needed, you can add a parameter to specify what this is about exactly...
This would be the most generic and powerful approach...
if this works for you, you can use replications for checkboxes and editboxes and associate them together through the index... and then just add the code in the visible field of the edit box... Of course you will have to determine their positions programatically

Modifying .mo built-in files containing constants

As a part of my studies, I am interested in modifying some constant properties of a medium like water. For example, in Buildings.Media.Water that cannot be accessed by Dymola (I opened it in Visual Studio Code), I am going to change a constant e.g. density. Is there any way to do so? or should I do it through partial medium?
This question is also applied to some thermo-physical properties like thermal diffusivity that I could not find it in the constants of water.
I would be thankful for your advise.
In Dymola you should be able to modify constants if you double-click the package containing the constant(s) and then edit the text using the Modelica-Text view. This way you should be able to edit all constants in the package. Obviously write-access is required to do so (which you e.g. don't usually have for the MSL).
Using inheritance (partial medium) makes sense if you want to be able to switch between multiple media quickly or you don't have write access. For experimentation it should be fine to directly change values - being careful not to forget to revert...
Regarding the thermal diffusivity: it probably simply is not there. You could inherit from the original package and add it if that is the best solution to your needs.

How to position Canvas with agents in classical Agent-Based Modeling in AnyLogic

I'm new to AnyLogic and trying to figure out how Agent-based models should be set there. There is a famous Epidemic model, which I'm trying to reproduce. Most tutorials on classical ABM deal with old GUI settings.
For example, in version 8.5+, which is actual now, the Environment object (that was used for positioning of layouts) has been deprecated.
Now I see that new object Canvas is used to put the layout with agents on the page. But the structure of source code file is a bit unclear for me and I've failed to find relevant description how Canvas can be set for the purpose. (Besides I'm not sure that this is recommended way of doing this task.)
Question: I would love to learn the right way to arbitrary position the area with agents on the page. Below you may see what I get by default.
After some playing around, the 'minimalistic' functionality is as follows.
One should create some population with arbitrary name Person (population name people adds automatically).
The following structure of the Project is to be reproduced (arbitrary names are marked with yellow).
Comment: after adding a Canvas called mapCanvas one adds the function setCanvasCellColor with following body:
mapCanvas.fillCircle(person.getX(), person.getY(), 3, color);
It is clear that former two arguments stand for coordinates of a given point, then its size (i.e. 3) and color. Do not forget to add two arguments used in the body, namely, person as Person and color as Color.
From Entry Action of the statechart named state call the just made function. I've put black color here just for the sake of demonstration; chartreuse constant gets used instead in the Epidemic example.
main.setCanvasCellColor(this, black);
Finally, you may run the model to get the following picture.
Note
If one is reluctant to bother with Canvas, use Main - Presentation - xxx_presentation and click Draw agent with offset to this position checkbox.

Change default group colors in Zeppelin visualizations

I have a bunch of data that I'm putting into a scatter plot, but the default color ordering is "blue", "lighter blue", and then finally "orange". My data comes in two groups, with constant group names, and no mater what I do, they're always the blue and lighter blue. Which does NOT make for a good visualization.
So far, I haven't found a way to modify the color ordering, or to set specific colors for the known groups. I also haven't been able to change the colors by adding a dummy group (of one element) and playing with the ordering in the SQL statement.
Any help?
Here's a workaround/hack for that missing Zeppelin feature.
Charting in Zeppelin is based on nvd3 (which in turn uses the D3 library). As Zeppelin simply doesn't care about colors yet, it'll always use the nvd3 default, which is defined in the utils.js function nv.utils.defaultColor.
So, to change the color scheme, you can simply override this function. Try out the following JavaScript code in your browser's console. For available color schemes, see the API documentation (note, that Zeppelin still uses the old 3.x version of D3).
nv.utils.defaultColor = function() {
return nv.utils.getColor(d3.scale.category10().range());
}
The remaining problem is, how to permanently add this to your Zeppelin instance, which depends on your environment. It is sufficient to add the above code to the end of your index.html, however this involves modifying the zeppelin-web-x.y.z.war file.
In the end, with above code, you get something like this.

Sorting object's run states

On object's diagram, I have two different objects inherited from the same class. Unfortunately displayed run states are sorted in a different way. I am trying to sort it but the order of displayed values doesn't change.
Is there any way to sort it? I've tried to set 'Sort Features Alphabetically' but nothing happened.
You need to sort that "manually". t_object.runstate holds
#VAR;Variable=<name>;Value=<val>;Note=<note>;Op=<op>;#ENDVAR
and it will appear in the order right there. So just disassemble the string, re-order as needed and replace it.
EAUI: The sort triangle in the Run State editor has only effect in the editor itself. It does not re-sort the real list. Report a bug (also about a missing "green arrow" which IIRC can be emulated by a strange key shortcut).