Hi Michael
I finally opened the bug ticket. Hopefully we have time to solve it.
I added the new methods to export import OJ styles to/from file. All those
methods are located into the class
org.openjump.core.apitools.IOTools. They mostly use the power Java2XML to
turn objects into XML documents (and viceversa).
<See also com\vividsolutions\jump\util\java2xml\package.html>.

*Export to XML file.  method saveSimbology_Jump(File output_file, Layer
input_layer)*
Instead to create a new object for the styles, I uses the method  new
Java2XML().write(Layer.class, "layer", Writer.class).
Some extra actions are done by complementary methods
a) Since the output XML document contains more info than <styles> ones
[<data-souce>, <feature.schema-operation>, <description> and <SRIDStyle>,
an accessory method (method *removeElements(Node parent)*) removes all
unecessary elements
b) if <styles> are related to external vertex images (bitmap or svg), A
folder with the same name of the output file is created where all these
images are copied (method *copyFileToFolder(File inputFile, String
outputDir) *)
c) a list of the paths of those images is also saved as text file. Note
that these paths are generally saved into the XML file under the child
element "imageURL".

*Import XML file as style. method loadSimbology_Jump (File input_file,
Layer input_layer)*
Even in this case the method used to read style is the following:
a) first create a new object <in this case a Layer.class> from the XML,
copy the styles from this new Layer.class, apply them to the target Layer
 final Layer sourceLayer = (Layer) new XML2Java(workbenchFrame
                    .getContext().getWorkbench().getPlugInManager()
                    .getClassLoader()).read(reader, Layer.class);
 final Collection<Style> styleColection = sourceLayer.getStyles();
*......*
 targetlayer.setStyles(names);
Even this method uses complementary methods to load images
b) first the method *imageURLExist(file)* scan the input_file to check if
there are elements with value  "imageURL
*" *
c) if so, the folder contained image files is found and the XML "imageURL"
values are recopiled according to the path of this folder

I tested all these methods and thy seem to work fine. Eventually I will
rewrite the code using info from
com\vividsolutions\jump\util\java2xml\package.html
I hope these info can be useful for ViewManager plugin

Best regards

Peppe





Il giorno gio 29 nov 2018 alle ore 22:34 Michaël Michaud <
m.michael.mich...@orange.fr> ha scritto:

> Hi Peppe,
>
> I don't know this area very well, but I feel always divided between sld
> which is the only standard I know but quite complex and maybe not well
> suited for all situations, and non portable solutions.
>
> The only work I did in this area is for the ViewManager plugin, because I
> also needed a simple way to serialize Styles and SLD did not appeared well
> suited to me (or maybe too complex). I created a new way to serialize
> styles with jaxb. Not all styles can be serialize yet though.
> I'm not sure I made the right decisions (using jaxb vs java2xml, using a
> format different from sld and different from openjump jmp files, etc.).
> Just want to make you know that I tried to address a problem which is not
> very far from yours with this extension.
>
> If you have some ideas to make all these works converge toward one format
> (sld ?) or 2 formats (sld + oj) with some reusable components, you're
> welcome.  If you have already some working code adding new capabilities
> that SLD and ViewManager plugins have not, you're also welcome ;-).
>
> Michaël
>
>
> Le 29/11/2018 à 12:01, Giuseppe Aruta a écrit :
>
> Hi Michaël
> thanks for the answer.
> Images for color theming: Maybe it is connected to XBasicStyle changes: as
> I can understand Import SLD recognize all these images as separate Basic
> Styles.
> I found also the even exporting a "Basic" color theming on polygons (only
> plain colors by attribute. No pattern, no images), even if loading style is
> applied correctly, the style displayed by the polygons is not correct,
> darker, as the BasicStyle is drawn on the top of the different
> XBasicStyles. Luckely it is possible to solve it reusing the Theming plugin
> to restore the real colors
>
> Indeed my scope is to find a good way to share layer styles between users
> who work on the same project but with differents areas (in my case, it is a
> common situation between a teem of field geologists).
> I possible find a solution to my scope. I realized tha Java2XML is quite
> flexible. Using this class I made some methods to export/import jump style
> (in the standard Jump XML format) which bypass some issues on sld.
> A Jump XML is not an universal "language" but, at least, it reaches my
> scope (if all field geologist uses OJ) -  Anyhow,  other GIS: Kosmo, GvSIG
> and QGIS, it seems to me that a full compatibility is still (or was still)
> missing between different softwares on SLD
>
> This new JUMP export/import style will be completely portable: also the
> images files, used by styles, will be saved in a folder together with the
> style XML file. Adnd these imags will be searched and read when an user try
> lo load a style file on another computer. A step ahead considering that all
> SLD exporter don't have this option as they are used for local (local
> computer) or computer to web (*) action
> I will add these capabilities on this weekend as two new plugins (import
> Style/Export Style).
> To be moore precise:
> A) The export plugin will open a JFileChooser where the user can choose to
> export style  either to SLD or to this new Jump XML style format.
> B)  the import plugin will be able to import either to SLD or to this new
> Jump style format.
> C) All  those methods will be set on org.openjump.core.apitools.IOTools
> class, in order to resume even from other plugins or to be
> controlled/modified in the future
> D) SLD code will not be changed, right now, except I will duplicate the
> export process (as method) to bypass the JFileChooser.
> E) those new plugins (import Style/Export Style) will substitute Import
> Style as SLD/Export style as SLD plugins
>
> Best regards
> Peppe
>
> (*) (
> http://www.ricercasit.it/public/documenti/Dottorato/Formazione%20interna%20dottorandi/GIS%20Open%20Source%20e%20Web%20-%20Claudio%20Schifani/Servizi_Web_OGC.pdf)
>
>
>
> Il giorno dom 25 nov 2018 alle ore 19:23 Michaël Michaud <
> m.michael.mich...@orange.fr> ha scritto:
>
>> Hi Peppe,
>>
>> Did you fill a ticket to track these bugs ?
>>
>> Some hints :
>> A few years ago, I created XBasicStyle which extends BasicStyle and wraps
>> VertexStyle
>> in order to make Vertex Style available in ThemingStyle. Maybe some bugs
>> are related to this
>> change which has not been ported to SLDPlugIn.
>>
>> If the path of images are not saved with a correct URL, the problem may
>> come from XSLUtility which
>> has a few methods used by layerstyle2sld.xsl to read/write URL.
>> ImageFillPattern seems to use geIconURL which itself uses a URL method. I
>> don't know why some
>> methods of this utility class use URL.toString() and others
>> URL.toExternalForm for example...
>>
>> Michaël
>>
>>
>>
>>
>> Le 25/11/2018 à 10:27, Giuseppe Aruta a écrit :
>>
>> I can be more accurate on { ColorThemingStyle for polygons with some fill
>> patterns seems not working}
>> Polygon fill pattern are samples are saved as temp image files like
>> "ojp5731593574799380314pti.png"
>> On saving to SLD file the relative path of the file is saved as tag (in
>> windows)
>> <OnlineResource xlink:type="simple" 
>> xlink:href="file:/C:/Users/<Urer>/AppData/Local/Temp/
>> jp5731593574799380314pti.png "/>
>> When I try to load, the SLD import cannot recognize it and throws an
>> error message in the log file (An ogc:filter could not be found while
>> trying to parse a color theming style).
>> Peppe
>>
>> Il giorno ven 23 nov 2018 alle ore 16:24 Giuseppe Aruta <
>> giuseppe.ar...@gmail.com> ha scritto:
>>
>>> Hi
>>> it seems that sld import/export has some faults. According to an user's
>>> mail (I recived) it was not possible to load text symbology on a layer.
>>> While waiting a more complete info (and opening a bug ticket), I did
>>> some (partial) tests. This is what I found:
>>> - Save: vertex symbology from external image file is not saved into the
>>> xml file. The tag <sld:ExternalGraphic> is not recorded even if it is
>>> present into the layerstyle2sld.xsl file template
>>> - Load: vertex symbologies applied as ColorThemingStyle are decoded as
>>> multiple BasicStyle. Thus is not easy to apply a styling according to an
>>> attribute classification
>>> - Load: strangelly Labeling works fine. labels are located anyhow at the
>>> center of the geometry.
>>> - Load. ColorThemingStyle for polygon works only if user uses base fill
>>> colors.
>>> ColorThemingStyle for polygons with some fill patterns seems not working
>>> - Load both line color and line pattern seem to work.
>>> I remember years ago everyting seemed to work fine (
>>> http://ojwiki.soldin.de/index.php?title=Import-Export_Layer_Style). I
>>> wonder if this is connecte external libraries.
>>>
>>> Good news: the method  new Java2XML().write(layer, "layer",
>>> stringWriter) controls the way to export style (both on project file and
>>> partially on sld file).
>>> I thing I will implement an alternative way to export/import style to
>>> file using this method.
>>>
>>> Best regards
>>> Peppe
>>>
>>
>>
>>
>>
>> _______________________________________________
>> Jump-pilot-devel mailing 
>> listJump-pilot-devel@lists.sourceforge.nethttps://lists.sourceforge.net/lists/listinfo/jump-pilot-devel
>>
>>
>> _______________________________________________
>> Jump-pilot-devel mailing list
>> Jump-pilot-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel
>>
>
>
> _______________________________________________
> Jump-pilot-devel mailing 
> listJump-pilot-devel@lists.sourceforge.nethttps://lists.sourceforge.net/lists/listinfo/jump-pilot-devel
>
> _______________________________________________
> Jump-pilot-devel mailing list
> Jump-pilot-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel
>
_______________________________________________
Jump-pilot-devel mailing list
Jump-pilot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel

Reply via email to