how to fill color in sld with the feature's attribute - colors

for example:
here is a grass feature like this:
id,area, level
1,geometry, 24
2,geometry, 56
...
i wount to write a sld file that display color according to the attribute level, like this :
<?xml version="1.0" encoding="UTF-8"?>
<StyledLayerDescriptor version="1.0.0" xmlns="http://www.opengis.net/sld" xmlns:ogc="http://www.opengis.net/ogc"
xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.opengis.net/sld http://schemas.opengis.net/sld/1.0.0/StyledLayerDescriptor.xsd">
<NamedLayer>
<Name>grass</Name>
<UserStyle>
<Name>grass</Name>
<Title>grass polygon</Title>
<Abstract>grass fill with level</Abstract>
<FeatureTypeStyle>
<Rule>
<PolygonSymbolizer>
<Fill>
<CssParameter name="fill">rgb(**level**, 0, 255)</CssParameter>
</Fill>
<Stroke />
</PolygonSymbolizer>
</Rule>
</FeatureTypeStyle>
</UserStyle>
</NamedLayer>
</StyledLayerDescriptor>

Have a look at the categorize and interpolate functions:
http://docs.geoserver.org/latest/en/user/styling/sld-tipstricks/transformation-func.html

Related

How to decrease the size of thumb in switch java/kotlin?

Hye there, I have created 4 SVG files 2 of them represent the thumb and 2 others represent the track as ON/OFF, and when I implemented them on the Switch button, I had no problem with the track but the thumb cirlce is forcing the track to take it size, for example if the size of the thumb = 20 then the track high should = 20 as well, and that make 2 problems, one, it distruct the shape of the svg, two, it is not showing as I want it to be, I want the thumb to be smaller and to fit inside the track like that:the shape I want to show
and here is my result:
this is what it show
this is the switch code:
<Switch
android:id="#+id/nightLight"
android:layout_centerHorizontal="true"
android:track="#drawable/night_light_track"
android:thumb="#drawable/night_light_thumb"
android:checked="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
this is the drawables:
night_light_thumb:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="false">
<shape android:shape="oval">
<solid android:color="#color/C"/>
<size android:height="32dp" android:width="32dp"/>
</shape>
</item>
<item android:state_checked="true">
<shape android:shape="oval">
<solid android:color="#4E505F"/>
<size android:height="32dp" android:width="32dp"/>
</shape>
</item>
</selector>
night_light_track:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="false"
android:drawable="#drawable/light_track"/>
<item android:state_checked="true"
android:drawable="#drawable/night_track"/>
</selector>
night_track:
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="72dp"
android:height="32dp"
android:viewportWidth="72"
android:viewportHeight="32">
<group>
<clip-path
android:pathData="M56,0H16C7.2,0 0,7.2 0,16l0,0c0,8.8 7.2,16 16,16h40c8.8,0 16,-7.2 16,-16l0,0C72,7.2 64.8,0 56,0z"/>
<path
android:pathData="M56,0H16C7.2,0 0,7.2 0,16l0,0c0,8.8 7.2,16 16,16h40c8.8,0 16,-7.2 16,-16l0,0C72,7.2 64.8,0 56,0z"
android:fillColor="#2E2F38"/>
</group>
<group>
<clip-path
android:pathData="M56,0H16C7.2,0 0,7.2 0,16l0,0c0,8.8 7.2,16 16,16h40c8.8,0 16,-7.2 16,-16l0,0C72,7.2 64.8,0 56,0z"/>
<path
android:pathData="M16.5,10.2c-1.8,1.3 -3,3.4 -3,5.8c0,3.9 3.1,7 7,7c2.4,0 4.5,-1.2 5.8,-3c-0.3,0 -0.5,0 -0.8,0c-5,0 -9,-4 -9,-9C16.5,10.7 16.5,10.5 16.5,10.2zM11.5,16c0,-4 2.6,-7.3 6.1,-8.5l1.3,1.3c-0.2,0.7 -0.4,1.5 -0.4,2.3c0,3.9 3.1,7 7,7c0.8,0 1.5,-0.1 2.3,-0.4l1.3,1.3c-1.2,3.5 -4.6,6.1 -8.5,6.1C15.5,25 11.5,21 11.5,16z"
android:strokeAlpha="0.7"
android:fillColor="#4B5EFC"
android:fillType="evenOdd"
android:fillAlpha="0.7"/>
</group>
</vector>
light_track:
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="72dp"
android:height="32dp"
android:viewportWidth="72"
android:viewportHeight="32">
<group>
<clip-path
android:pathData="M56,0H16C7.2,0 0,7.2 0,16l0,0c0,8.8 7.2,16 16,16h40c8.8,0 16,-7.2 16,-16l0,0C72,7.2 64.8,0 56,0z"/>
<path
android:pathData="M56,0H16C7.2,0 0,7.2 0,16l0,0c0,8.8 7.2,16 16,16h40c8.8,0 16,-7.2 16,-16l0,0C72,7.2 64.8,0 56,0z"
android:fillColor="#FFFFFF"/>
</group>
<group>
<clip-path
android:pathData="M56,0H16C7.2,0 0,7.2 0,16l0,0c0,8.8 7.2,16 16,16h40c8.8,0 16,-7.2 16,-16l0,0C72,7.2 64.8,0 56,0z"/>
<path
android:pathData="M51,6v1v2v1h2V9V7V6H51zM62,15h-1h-2h-1v2h1h2h1V15zM45,15h1v2h-1h-2h-1v-2h1H45zM51,22v1v2v1h2v-1v-2v-1H51zM46.3,23.1l-0.7,0.7l-1.4,-1.4l0.7,-0.7l1.4,-1.4l0.7,-0.7l1.4,1.4l-0.7,0.7L46.3,23.1zM56.9,12.5l0.7,-0.7l1.4,-1.4l0.7,-0.7l-1.4,-1.4l-0.7,0.7l-1.4,1.4l-0.7,0.7L56.9,12.5zM44.9,10.3l-0.7,-0.7l1.4,-1.4l0.7,0.7l1.4,1.4l0.7,0.7l-1.4,1.4l-0.7,-0.7L44.9,10.3zM55.5,20.9l0.7,0.7l1.4,1.4l0.7,0.7l1.4,-1.4l-0.7,-0.7l-1.4,-1.4l-0.7,-0.7L55.5,20.9zM54,16c0,-1.1 -0.9,-2 -2,-2s-2,0.9 -2,2s0.9,2 2,2S54,17.1 54,16zM52,12c2.2,0 4,1.8 4,4s-1.8,4 -4,4s-4,-1.8 -4,-4S49.8,12 52,12z"
android:strokeAlpha="0.7"
android:fillColor="#4B5EFC"
android:fillType="evenOdd"
android:fillAlpha="0.7"/>
</group>
</vector>
What I did try is to change the size of the thumb same as the size of the track so it don't distruct the shape, so we don't stay having 2 problems, but still couldn't change the size of the thumb inside the track.
The switch size adjust as you have stated. To get around this, make a thumb that has two concentric circles inside a Layer List. The outer circle will be the size you want the track to be with a transparent color. The inner circle will be the same as the outer circle but will change color of the inner circle if that's what you want. This way, the thumb will appear to be inset inside the track but in actuality it will just have a transparent annular ring.
night_light_thumb.xml
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="false">
<layer-list>
<item>
<shape android:shape="oval">
<solid android:color="#android:color/transparent" />
<size android:width="32dp" android:height="32dp" />
</shape>
</item>
<item android:bottom="4dp" android:left="4dp" android:right="4dp" android:top="4dp">
<shape android:shape="oval">
<solid android:color="#color/C" />
<size android:width="24dp" android:height="24dp" />
</shape>
</item>
</layer-list>
</item>
<item android:state_checked="true">
<layer-list>
<item>
<shape android:shape="oval">
<solid android:color="#android:color/transparent" />
<size android:width="32dp" android:height="32dp" />
</shape>
</item>
<item android:bottom="4dp" android:left="4dp" android:right="4dp" android:top="4dp">
<shape android:shape="oval">
<solid android:color="#4E505F" />
<size android:width="24dp" android:height="24dp" />
</shape>
</item>
</layer-list>
</item>
</selector>
There are probably other ways to do this, but the idea is to build a transparent area around the visible thumb.
Update
Here is another way to do it using inset of the item attribute of layer list. This way involve less drawing and is shorter.
<selector>
<item android:state_checked="false">
<layer-list>
<item android:bottom="4dp" android:left="4dp" android:right="4dp" android:top="4dp">
<shape android:shape="oval">
<solid android:color="#android:color/holo_red_light" />
<size android:width="34dp" android:height="34dp" />
</shape>
</item>
</layer-list>
</item>
<item android:state_checked="true">
<layer-list>
<item android:bottom="4dp" android:left="4dp" android:right="4dp" android:top="4dp">
<shape android:shape="oval">
<solid android:color="#4E505F" />
<size android:width="34dp" android:height="34dp" />
</shape>
</item>
</layer-list>
</item>
</selector>

How to change textView shape and color in Android Studio

I have looked everywhere to change the textView shape AND color and the only solution I can find is to make a drawable resource file. Which I did:
rounded_blue.xml
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#00BCD4" />
<stroke
android:width="3dp"
android:color="#ffffff" />
<corners android:radius="30dp" />
<padding
android:bottom="0dp"
android:left="0dp"
android:right="0dp"
android:top="0dp" />
</shape>
But when I apply it to my textView I get the shape but not the color. The color goes to default.
<Button
android:id="#+id/loginButton"
android:layout_width="249dp"
android:layout_height="45dp"
android:text="Login"
android:background="#drawable/rounded_blue"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="#+id/button_standard"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="#+id/button_standard"
app:layout_constraintTop_toBottomOf="#+id/edittext_password"
app:layout_constraintVertical_bias="0.086" />```
[This is what I get ][1]
[1]: https://i.stack.imgur.com/f5P8Y.png
The edges are rounded as I wanted, but I want to change the button color. Why won't the color translate over as well?T

Multifield inside multifield

Below is my dialog.xml file
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
jcr:primaryType="cq:Dialog"
title="CQ Dialog"
xtype="dialog">
<items
jcr:primaryType="cq:Widget"
xtype="tabpanel">
<items jcr:primaryType="cq:WidgetCollection">
<tab1
jcr:primaryType="cq:Panel"
title="Tab 1">
<items jcr:primaryType="cq:WidgetCollection">
<addcolumn
jcr:primaryType="cq:Widget"
fieldDescription="Click + to add column"
fieldLabel="Add column"
name="./addcolumn"
xtype="multicompositefield">
<fieldConfigs jcr:primaryType="cq:WidgetCollection">
<countrydetails
jcr:primaryType="cq:Widget"
fieldDescription="Click + to add country details"
fieldLabel="Add country details"
name="./countrydetails"
xtype="multifield">
<fieldConfig
jcr:primaryType="cq:Widget"
hideLabel="false"
xtype="multifieldpanel">
<items jcr:primaryType="cq:WidgetCollection">
<countryname
jcr:primaryType="cq:Widget"
fieldLabel="Country name"
name="./countryname"
width="200"
xtype="textfield"/>
<countryicon
jcr:primaryType="cq:Widget"
fieldLabel="Country icon"
name="./countryicon"
width="200"
xtype="pathfield"/>
<linkurl
jcr:primaryType="cq:Widget"
fieldLabel="Link url"
name="./linkurl"
width="200"
xtype="pathfield"/>
</items>
</fieldConfig>
</countrydetails>
</fieldConfigs>
</addcolumn>
</items>
</tab1>
</items>
</items>
</jcr:root>
I was just trying to create multifield inside another multifield.
Issue I am facing is, once I filled the dialog field with values and when I reopen the dialog, all fields and filled data is cleared and dialog is empty.
Any suggestions what went wrong in my dialog
Thanks
This is possible but not just with the dialog structure you posted. You have to take care of field value serialisation for nested components.
Your values are blanking out because the value map handling of widgets is not compatible with nested values. A good read is at:
https://helpx.adobe.com/experience-manager/using/nested_multifield.html

How to group properly excel data source with rowspan?

From my understanding, <groupExpression> tag will be the one that decides whether a new group will be created or not, if there's a change to the element inside <groupExpression>, a new group will be created.
I want my report to look similar to my Excel data source (refer below) hence I want to group the ID and Name in the Excel file. In my jasperReport.jrxml (refer below), my <groupExpression> for Group1 is the ID column of my Excel File. But when I preview the report (refer below), the ID and Name column is not grouped, instead, there's a null string.
How to properly group them and eliminate the null string?
Excel datasource:
jasperReport.jrxml
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.2.0.final using JasperReports Library version 6.2.0 -->
<!-- 2016-01-26T15:33:41 -->
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="FirstJasperReport" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="8b8832df-588e-4202-826e-a6b3efcbd22b">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="ExcelDataBase"/>
<queryString>
<![CDATA[]]>
</queryString>
<field name="ID" class="java.lang.Integer"/>
<field name="Name" class="java.lang.String"/>
<field name="Title" class="java.lang.String"/>
<field name="Balance" class="java.lang.Integer"/>
<variable name="Balance1" class="java.lang.Integer" resetType="Group" resetGroup="Group1" calculation="Count">
<variableExpression><![CDATA[$F{Balance}]]></variableExpression>
</variable>
<variable name="Balance2" class="java.lang.Integer" resetType="Group" resetGroup="Group1" calculation="Sum">
<variableExpression><![CDATA[$F{Balance}]]></variableExpression>
</variable>
<group name="Group1">
<groupExpression><![CDATA[$F{ID}]]></groupExpression>
<groupHeader>
<band height="30">
<rectangle>
<reportElement x="0" y="0" width="400" height="30" backcolor="#DEFCF2" uuid="de6c2f8d-afa6-45b4-b40e-574f2e07057e"/>
</rectangle>
<textField>
<reportElement x="0" y="0" width="100" height="30" uuid="c028645d-9b29-42d3-b91e-d47f15a5b44a"/>
<textFieldExpression><![CDATA[$F{ID}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="100" y="0" width="100" height="30" uuid="85d2844f-ef91-47a1-9223-c6943a25fe4d"/>
<textFieldExpression><![CDATA[$F{Name}]]></textFieldExpression>
</textField>
</band>
</groupHeader>
......
Preview result:
How to make title1 and title2 appear under the group test1, without the null string (similar to the Excel source file)?
The problem is that the excel datasource is passing $F{ID}==null for second record. This generates the null group (as you can see also the name is null).
The easiest way to fix it is to not use rowspan in excel (include all data in the excel sheet).
If this is not possible you need to save the first $F{ID} value and return this if $F{ID}==null
Example
<variable name="First_ID" class="java.lang.Integer" resetType="Group" resetGroup="Group1" calculation="First">
<variableExpression><![CDATA[$F{ID}]]></variableExpression>
</variable>
In group return variable $V{First_ID} if $F{ID}==null
<group name="Group1">
<groupExpression><![CDATA[$F{ID}==null?$V{First_ID}:$F{ID}]]></groupExpression>
... your groupHeader ....
</group>

Add start and end attribute to node and edge in gexf file

I have a .gexf file that contains nodes and edges with IDs and labels. I generated this .gexffile from a .gml file using networkx. Here's the code for that:
import networkx as nx
G = nx.read_gml('data/gml/test.gml') # read in gml file as Graph
nx.write_gexf(G, "output/test.gexf") # write to gexf format
The next thing I want to do, is to add a startand end attribute to every node and every edge in my file.
So basically, I want this:
<?xml version='1.0' encoding='utf-8'?>
<gexf version="1.1" xmlns="http://www.gexf.net/1.1draft" xmlns:viz="http://www.gexf.net/1.1draft/viz" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3.org/2001/XMLSchema-instance">
<graph defaultedgetype="undirected" mode="static">
<nodes>
<node id="clock" label="clock" />
<node id="beach" label="beach" />
<node id="sun" label="sun" />
<node id="sea" label="sea" />
<node id="sand" label="sand" />
<node id="guitar" label="guitar" />
(...)
</nodes>
<edges>
<edge id="0" source="ice" target="shoe" weight="0.9995600294856769" />
<edge id="1" source="ice" target="toothbrush" weight="0.9992457544219484" />
<edge id="1533" source="snake" target="ant" weight="0.9999144063155566" />
(...)
<edge id="1534" source="mosquito" target="jellyfish" weight="0.9994175606336606" />
<edge id="1535" source="ant" target="star" weight="0.9994226236705537" />
</edges>
</graph>
</gexf>
to look like this (note the dynamicmode and start and end attributes):
<?xml version='1.0' encoding='utf-8'?>
<gexf version="1.1" xmlns="http://www.gexf.net/1.1draft" xmlns:viz="http://www.gexf.net/1.1draft/viz" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3.org/2001/XMLSchema-instance">
<graph defaultedgetype="undirected" mode="dynamic">
<nodes>
<node id="clock" label="clock" start="2000-02-20" end="2000-02-22" />
<node id="beach" label="beach" start="2000-02-20" end="2000-02-22" />
<node id="sun" label="sun" start="2000-02-20" end="2000-02-22" />
<node id="sea" label="sea" start="2000-02-20" end="2000-02-22" />
<node id="sand" label="sand" start="2000-02-20" end="2000-02-22" />
<node id="guitar" label="guitar" start="2000-02-20" end="2000-02-22" />
(...)
</nodes>
<edges>
<edge id="0" source="ice" target="shoe" weight="0.9995600294856769" start="2000-02-20" end="2000-02-22" />
<edge id="1" source="ice" target="toothbrush" weight="0.9992457544219484" start="2000-02-20" end="2000-02-22" />
<edge id="1533" source="snake" target="ant" weight="0.9999144063155566" start="2000-02-20" end="2000-02-22" />
(...)
<edge id="1534" source="mosquito" target="jellyfish" weight="0.9994175606336606" start="2000-02-20" end="2000-02-22" />
<edge id="1535" source="ant" target="star" weight="0.9994226236705537" start="2000-02-20" end="2000-02-22" />
</edges>
</graph>
</gexf>
Unfortunately I was not able to find any documentation (neither for networkx nor for pygexf) on how to write a dyamic gexf file and add a startand end attribute to every (already existing) node and edge. Can anyone please help me with this?
UPDATE:
When I use
nx.set_edge_attributes(G, 'start', '2000-02-20')
nx.set_edge_attributes(G, 'end', '2000-02-22')
To set the edge attributes, I get the correct output, e.g.:
<edge id="0" source="great" target="wait" weight="0.998675772419067" start="2000-02-20" end="2000-02-22" />
However, when I do:
nx.set_node_attributes(G, 'start','2000-02-20')
nx.set_node_attributes(G, 'end','2000-02-22')
I get:
<node id="blue" label="blue">
<attvalues>
<attvalue for="0" value="2000-02-20" />
<attvalue for="1" value="2000-02-22" />
</attvalues>
How can I set the start and endattribute within the node tag?
Came across that same problem. Networkx 2.1 still does not support that, but there is a workaround:
Write the .gexf file as usual
Download Gephi 0.9.2 and open the .gexf file
Go to Data Laboratory and press 'Merge Columns'. Now select the start and end column and 'Merge Strategy': 'Create time interval'. Now your Interval column is filled with <[start, end]>
Go to File > Export > Graph file... and select File Format:GEXF Files. Your nodes now contain the start and end attribute.

Resources