GeoPubby  Version 0.1.0.0
StyleObject Class Reference

An object containing style definitions to apply on geospatial objects. More...

Collaboration diagram for StyleObject:

Public Member Functions

 StyleObject ()
 
 StyleObject (String propertyNamespace)
 
String toString ()
 
String toJSON ()
 Exports the StyleObject to JSON. More...
 
String getCommonPrefixes ()
 
String toRDF ()
 
String toRDF (String target)
 
String conditionsToSHACL (String curind, String targetStyle)
 
String mapToCSS (Map< String, String > map)
 
String toHTML ()
 Exports the StyleObject to HTML. More...
 
String toXML ()
 Exports the StyleObject to XML. More...
 

Public Attributes

String pointStyle
 A point style definition in CSS. More...
 
String pointImage
 An SVG definition oder an image path to indicate an icon for a point. More...
 
String lineStringStyle
 A hatch definition in CSS. More...
 
String lineStringImage
 An SVG definition oder an image path to indicate an icon for a LineString. More...
 
String polygonStyle
 A Polygon style definition in CSS. More...
 
String polygonImage
 An SVG definition oder an image path to indicate an icon for a Polygon. More...
 
String hatch
 A hatch definition in CSS. More...
 
String lineStringImageStyle
 A style definition of an image which is enclosed in a LineString. More...
 
String rasterStyle
 A style definition of an image which is applied to a raster. More...
 
Map< String, String > rasterColorMap =new TreeMap<String,String>()
 
String styleName
 An identifier of a given style. More...
 
String styleId
 
String styleDescription
 A description of a given style. More...
 
String popupStyle
 A style definition for the map popup. More...
 
String textStyle
 A style definition for the map popup. More...
 
List< Conditionconditions
 
String sldString =""
 
String qmlString =""
 

Private Attributes

String propertyNamespace =""
 

Detailed Description

An object containing style definitions to apply on geospatial objects.

Constructor & Destructor Documentation

◆ StyleObject() [1/2]

100  {
101  this("");
102  }

◆ StyleObject() [2/2]

StyleObject ( String  propertyNamespace)
104  {
106  }
String propertyNamespace
Definition: StyleObject.java:94

References StyleObject.propertyNamespace.

Member Function Documentation

◆ conditionsToSHACL()

String conditionsToSHACL ( String  curind,
String  targetStyle 
)
238  {
239  if(conditions.isEmpty())
240  return "";
241  StringBuilder builder=new StringBuilder();
242  builder.append(curind+" sh:rule ["+System.lineSeparator());
243  builder.append("a sh:TripleRule ;"+System.lineSeparator());
244  builder.append("sh:subject sh:this ;"+System.lineSeparator());
245  builder.append("sh:predicate geo:style ;"+System.lineSeparator());
246  builder.append("sh:object "+targetStyle+" ; "+System.lineSeparator());
247  for(Condition cond:conditions) {
248  builder.append(cond.toSHACL());
249  }
250  builder.append("]."+System.lineSeparator());
251  return builder.toString();
252  }
List< Condition > conditions
Definition: StyleObject.java:92

References StyleObject.conditions.

Referenced by StyleObject.toRDF().

◆ getCommonPrefixes()

String getCommonPrefixes ( )
162  {
163  StringBuilder builder=new StringBuilder();
164  builder.append("@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> ."+System.lineSeparator());
165  builder.append("@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> ."+System.lineSeparator());
166  builder.append("@prefix geo: <http://www.opengis.net/ont/geosparql#> ."+System.lineSeparator());
167  builder.append("@prefix geost: <http://www.opengis.net/ont/geosparql/style#> ."+System.lineSeparator());
168  builder.append("@prefix sh: <http://www.w3.org/ns/shacl#> ."+System.lineSeparator());
169  return builder.toString();
170  }

◆ mapToCSS()

String mapToCSS ( Map< String, String >  map)
254  {
255  StringBuilder result=new StringBuilder();
256  result.append("\"");
257  for(String key:map.keySet()) {
258  result.append(key+":"+map.get(key)+";");
259  }
260  result.append("\"");
261  return result.toString();
262  }

Referenced by SLDParser.endElement().

◆ toHTML()

String toHTML ( )

Exports the StyleObject to HTML.

Returns
A HTML table containing the StyleObject information
268  {
269  StringBuilder result=new StringBuilder();
270  result.append("<table border=1><tr><th>Styleaspect</th><th>CSS</th></tr>");
271  result.append("<tr><td>pointStyle</td><td>"+(pointStyle!=null?pointStyle.replace("\"","").replace("\\",""):"")+"</td></tr>");
272  result.append("<tr><td>pointImage</td><td>"+(pointImage!=null?pointImage.replace("\"","").replace("\\",""):"")+"</td></tr>");
273  result.append("<tr><td>lineStringStyle</td><td>"+(lineStringStyle!=null?lineStringStyle.replace("\"","").replace("\\",""):"")+"</td></tr>");
274  result.append("<tr><td>lineStringImage</td><td>"+(lineStringImage!=null?lineStringImage.replace("\"","").replace("\\",""):"")+"</td></tr>");
275  result.append("<tr><td>lineStringImageStyle</td><td>"+(lineStringImageStyle!=null?lineStringImageStyle.replace("\"","").replace("\\",""):"")+"</td></tr>");
276  result.append("<tr><td>polygonStyle</td><td>"+(polygonStyle!=null?polygonStyle.replace("\"","").replace("\\",""):"")+"</td></tr>");
277  result.append("<tr><td>polygonImage</td><td>"+(polygonImage!=null?polygonImage.replace("\"","").replace("\\",""):"")+"</td></tr>");
278  result.append("<tr><td>popupStyle</td><td>"+(popupStyle!=null?popupStyle.replace("\"","").replace("\\",""):"")+"</td></tr>");
279  result.append("<tr><td>hatch</td><td>"+(hatch!=null?hatch.replace("\"","").replace("\\",""):"")+"</td></tr>");
280  result.append("<tr><td>styleDescription</td><td>"+styleDescription+"</td></tr>");
281  result.append("<tr><td>styleName</td><td>"+styleName+"</td></tr></table>");
282  return result.toString();
283  }
String lineStringImageStyle
A style definition of an image which is enclosed in a LineString.
Definition: StyleObject.java:61
String polygonStyle
A Polygon style definition in CSS.
Definition: StyleObject.java:46
String polygonImage
An SVG definition oder an image path to indicate an icon for a Polygon.
Definition: StyleObject.java:51
String pointImage
An SVG definition oder an image path to indicate an icon for a point.
Definition: StyleObject.java:31
String pointStyle
A point style definition in CSS.
Definition: StyleObject.java:26
String hatch
A hatch definition in CSS.
Definition: StyleObject.java:56
String styleName
An identifier of a given style.
Definition: StyleObject.java:73
String lineStringImage
An SVG definition oder an image path to indicate an icon for a LineString.
Definition: StyleObject.java:41
String lineStringStyle
A hatch definition in CSS.
Definition: StyleObject.java:36
String popupStyle
A style definition for the map popup.
Definition: StyleObject.java:85
String styleDescription
A description of a given style.
Definition: StyleObject.java:80

References StyleObject.hatch, StyleObject.lineStringImage, StyleObject.lineStringImageStyle, StyleObject.lineStringStyle, StyleObject.pointImage, StyleObject.pointStyle, StyleObject.polygonImage, StyleObject.polygonStyle, StyleObject.popupStyle, StyleObject.styleDescription, and StyleObject.styleName.

◆ toJSON()

String toJSON ( )

Exports the StyleObject to JSON.

Returns
The JSONObject containing the style information
147  {
148  JSONObject result=new JSONObject();
149  result.put("pointStyle",(pointStyle!=null?pointStyle.replace("\"","").replace("\\",""):null));
150  result.put("pointImage",(pointImage!=null?pointImage.replace("\"","").replace("\\",""):null));
151  result.put("lineStringStyle",(lineStringStyle!=null?lineStringStyle.replace("\"","").replace("\\",""):null));
152  result.put("lineStringImage",(lineStringImage!=null?lineStringImage.replace("\"","").replace("\\",""):null));
153  result.put("lineStringImageStyle",(lineStringImageStyle!=null?lineStringImageStyle.replace("\"","").replace("\\",""):null));
154  result.put("polygonStyle",(polygonStyle!=null?polygonStyle.replace("\"","").replace("\\",""):null));
155  result.put("polygonImage",(polygonImage!=null?polygonImage.replace("\"","").replace("\\",""):null));
156  result.put("popupStyle",(popupStyle!=null?popupStyle.replace("\"","").replace("\\",""):null));
157  result.put("hatch",(hatch!=null?hatch.replace("\"","").replace("\\",""):null));
158  result.put("styleName",styleName);
159  return result.toString(2);
160  }

References StyleObject.hatch, StyleObject.lineStringImage, StyleObject.lineStringImageStyle, StyleObject.lineStringStyle, StyleObject.pointImage, StyleObject.pointStyle, StyleObject.polygonImage, StyleObject.polygonStyle, StyleObject.popupStyle, and StyleObject.styleName.

◆ toRDF() [1/2]

String toRDF ( )
172  {
173  return toRDF(null);
174  }
String toRDF()
Definition: StyleObject.java:172

Referenced by SLDParser.main().

◆ toRDF() [2/2]

String toRDF ( String  target)
177  {
178  StringBuilder ttl=new StringBuilder();
179  if(this.styleId==null || this.styleName==null)
180  return "";
181  String curstyleid=this.styleId+"_"+this.styleName.replace(" ", "_");
182  String curstyleind="geo:"+curstyleid;
183  if(target==null && propertyNamespace!=null && !propertyNamespace.isEmpty()) {
184  target="<"+propertyNamespace+curstyleid+">";
185  }else if(target==null){
186  target="geo:"+curstyleid;
187  }else if(target.startsWith("http")) {
188  target="<"+target+">";
189  }
190  if(propertyNamespace!=null && !propertyNamespace.isEmpty()) {
191  curstyleind="<"+propertyNamespace+curstyleid+">";
192  }
193  ttl.append(target+" rdf:type rdfs:Class, sh:NodeShape . "+System.lineSeparator());
194  ttl.append(curstyleind+" rdf:type geo:Style . "+System.lineSeparator());
195  if(!sldString.isEmpty()) {
196  ttl.append(curstyleind+" geost:asSLD \""+this.sldString.replace("\"", "'")+"\"^^geost:sldLiteral . "+System.lineSeparator());
197  }
198  if(!qmlString.isEmpty()) {
199  ttl.append(curstyleind+" geost:asQML \""+this.sldString.replace("\"", "'")+"\"^^geost:qmlLiteral . "+System.lineSeparator());
200  }
201  ttl.append(curstyleind+" rdfs:label \""+this.styleName+"\"@en . "+System.lineSeparator());
202  ttl.append(curstyleind+" rdfs:comment \""+this.styleName+"\"@en . "+System.lineSeparator());
203  if(pointStyle!=null) {
204  ttl.append(curstyleind+" geost:pointStyle \""+this.pointStyle+"\"^^geost:cssLiteral . "+System.lineSeparator());
205  }
206  if(pointImage!=null) {
207  ttl.append(curstyleind+" geost:pointImage \""+this.pointImage+"\"^^geost:svgLiteral . "+System.lineSeparator());
208  }
209  if(lineStringStyle!=null) {
210  ttl.append(curstyleind+" geost:lineStringStyle \""+this.lineStringStyle+"\"^^geost:cssLiteral . "+System.lineSeparator());
211  }
212  if(lineStringImage!=null) {
213  ttl.append(curstyleind+" geost:lineStringImage \""+this.lineStringImage+"\"^^geost:svgLiteral . "+System.lineSeparator());
214  }
215  if(lineStringImageStyle!=null) {
216  ttl.append(curstyleind+" geost:lineStringImageStyle \""+this.lineStringImageStyle+"\"^^geost:cssLiteral . "+System.lineSeparator());
217  }
218  if(polygonStyle!=null) {
219  ttl.append(curstyleind+" geost:polygonStyle \""+this.polygonStyle+"\"^^geost:cssLiteral . "+System.lineSeparator());
220  }
221  if(polygonImage!=null) {
222  ttl.append(curstyleind+" geost:polygonImage \""+this.polygonImage+"\"^^geost:svgLiteral . "+System.lineSeparator());
223  }
224  if(hatch!=null) {
225  ttl.append(curstyleind+" geost:hatch \""+this.hatch+"\"^^geost:cssLiteral . "+System.lineSeparator());
226  }
227  if(popupStyle!=null) {
228  ttl.append(curstyleind+" geost:popupStyle \""+this.popupStyle+"\"^^geost:cssLiteral . "+System.lineSeparator());
229  }
230  if(propertyNamespace!=null && !propertyNamespace.isEmpty()) {
231  ttl.append(this.conditionsToSHACL(target,"<"+propertyNamespace+curstyleid+">"));
232  }else {
233  ttl.append(this.conditionsToSHACL(target,"geo:"+curstyleid));
234  }
235  return ttl.toString().replace("\"\"", "\"");
236  }
String qmlString
Definition: StyleObject.java:98
String styleId
Definition: StyleObject.java:75
String sldString
Definition: StyleObject.java:96
String conditionsToSHACL(String curind, String targetStyle)
Definition: StyleObject.java:238

References StyleObject.conditionsToSHACL(), StyleObject.hatch, StyleObject.lineStringImage, StyleObject.lineStringImageStyle, StyleObject.lineStringStyle, StyleObject.pointImage, StyleObject.pointStyle, StyleObject.polygonImage, StyleObject.polygonStyle, StyleObject.popupStyle, StyleObject.propertyNamespace, StyleObject.qmlString, and StyleObject.sldString.

◆ toString()

String toString ( )
109  {
110  StringBuilder builder=new StringBuilder();
111  builder.append("StyleObject [styleId=" +styleId+","+System.lineSeparator()+" styleName=\""+styleName+"\","+System.lineSeparator());
112  if(pointStyle!=null) {
113  builder.append(" pointStyle=" + pointStyle+System.lineSeparator());
114  }
115  if(pointImage!=null) {
116  builder.append(" pointImage=" + pointImage+System.lineSeparator());
117  }
118  if(lineStringStyle!=null) {
119  builder.append(" lineStringStyle=" + lineStringStyle+System.lineSeparator());
120  }
121  if(lineStringImage!=null) {
122  builder.append(" lineStringImage=" + lineStringImage+System.lineSeparator());
123  }
124  if(polygonStyle!=null) {
125  builder.append(" polygonStyle=" + polygonStyle+System.lineSeparator());
126  }
127  if(polygonImage!=null) {
128  builder.append(" polygonImage=" + polygonImage+System.lineSeparator());
129  }
130  if(hatch!=null) {
131  builder.append(" hatch=" + hatch+System.lineSeparator());
132  }
133  if(popupStyle!=null) {
134  builder.append(" popupStyle=" + popupStyle+System.lineSeparator());
135  }
136  if(rasterColorMap!=null) {
137  builder.append(" rasterColorMap=" + rasterColorMap+System.lineSeparator());
138  }
139  builder.append(" conditions: "+this.conditions+"]"+System.lineSeparator());
140  return builder.toString();
141  }
Map< String, String > rasterColorMap
Definition: StyleObject.java:68

References StyleObject.hatch, StyleObject.lineStringImage, StyleObject.lineStringStyle, StyleObject.pointImage, StyleObject.pointStyle, StyleObject.polygonImage, StyleObject.polygonStyle, StyleObject.popupStyle, StyleObject.rasterColorMap, StyleObject.styleId, and StyleObject.styleName.

◆ toXML()

String toXML ( )

Exports the StyleObject to XML.

Returns
A String representation of the XML serialization
289  {
290  StringWriter strwriter = new StringWriter();
291  XMLOutputFactory output = XMLOutputFactory.newInstance();
292  XMLStreamWriter writer;
293  try {
294  writer = new IndentingXMLStreamWriter(output.createXMLStreamWriter(strwriter));
295  writer.writeStartDocument();
296  writer.writeStartElement("style");
297  writer.writeStartElement(styleName);
298  writer.writeStartElement("pointStyle");
299  writer.writeCharacters(pointStyle);
300  writer.writeEndElement();
301  writer.writeStartElement("pointImage");
302  writer.writeCharacters(pointImage);
303  writer.writeEndElement();
304  writer.writeStartElement("lineStringStyle");
305  writer.writeCharacters(lineStringStyle);
306  writer.writeEndElement();
307  writer.writeStartElement("lineStringImage");
308  writer.writeCharacters(lineStringImage);
309  writer.writeEndElement();
310  writer.writeStartElement("lineStringImageStyle");
311  writer.writeCharacters(lineStringImageStyle);
312  writer.writeEndElement();
313  writer.writeStartElement("polygonStyle");
314  writer.writeCharacters(polygonStyle);
315  writer.writeEndElement();
316  writer.writeStartElement("popupStyle");
317  writer.writeCharacters(popupStyle);
318  writer.writeEndElement();
319  writer.writeStartElement("polygonImage");
320  writer.writeCharacters(polygonImage);
321  writer.writeEndElement();
322  writer.writeStartElement("hatch");
323  writer.writeCharacters(hatch);
324  writer.writeEndElement();
325  writer.writeEndElement();
326  writer.writeEndElement();
327  writer.writeEndDocument();
328  writer.flush();
329  } catch (XMLStreamException e) {
330  // TODO Auto-generated catch block
331  e.printStackTrace();
332  }
333  return strwriter.toString();
334  }

References StyleObject.hatch, StyleObject.lineStringImage, StyleObject.lineStringImageStyle, StyleObject.lineStringStyle, StyleObject.pointImage, StyleObject.pointStyle, StyleObject.polygonImage, StyleObject.polygonStyle, StyleObject.popupStyle, and StyleObject.styleName.

Member Data Documentation

◆ conditions

◆ hatch

◆ lineStringImage

String lineStringImage

◆ lineStringImageStyle

String lineStringImageStyle

A style definition of an image which is enclosed in a LineString.

Referenced by GeoModelWriter.handleStyle(), StyleObject.toHTML(), StyleObject.toJSON(), StyleObject.toRDF(), and StyleObject.toXML().

◆ lineStringStyle

◆ pointImage

◆ pointStyle

◆ polygonImage

String polygonImage

◆ polygonStyle

◆ popupStyle

◆ propertyNamespace

String propertyNamespace =""
private

◆ qmlString

String qmlString =""

Referenced by StyleObject.toRDF().

◆ rasterColorMap

Map<String,String> rasterColorMap =new TreeMap<String,String>()

Referenced by StyleObject.toString().

◆ rasterStyle

String rasterStyle

A style definition of an image which is applied to a raster.

◆ sldString

String sldString =""

Referenced by StyleObject.toRDF().

◆ styleDescription

String styleDescription

A description of a given style.

Referenced by StyleObject.toHTML().

◆ styleId

◆ styleName

◆ textStyle

String textStyle

A style definition for the map popup.