Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Scout » SVG Field in Swing and in SWT(Same code but different result between Swing and SWT)
icon3.gif  SVG Field in Swing and in SWT [message #1041558] Mon, 15 April 2013 08:48 Go to next message
marco giudici is currently offline marco giudiciFriend
Messages: 204
Registered: February 2013
Location: Italy
Senior Member
Hi all,
I'm here again to mark a strange thing happens to me using a field SVG.
I use a SVG field to represent a set of points that indicate my form; I pass the following XML string to the SVG field:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1"><circle cx="114.488188975" cy="76.692913385" r="1" stroke="red" stroke-width="1" /><circle cx="211.6352088927718" cy="59.563272678074185" r="1" stroke="black" stroke-width="1" /><circle cx="209.3157529735557" cy="42.17850270155239" r="1" stroke="black" stroke-width="1" /><circle cx="191.0802939762989" cy="32.472440944700004" r="1" stroke="black" stroke-width="1" /><circle cx="174.4206109176706" cy="26.403640237343986" r="1" stroke="black" stroke-width="1" /><circle cx="159.6756518033286" cy="22.840592219122065" r="1" stroke="black" stroke-width="1" /><circle cx="147.18110236035" cy="20.067126354125172" r="1" stroke="black" stroke-width="1" /><circle cx="135.68805171689291" cy="18.446769206111867" r="1" stroke="black" stroke-width="1" /><circle cx="124.98911814399666" cy="17.13918469977591" r="1" stroke="black" stroke-width="1" /><circle cx="114.488188975" cy="17.354330708700004" r="1" stroke="black" stroke-width="1" /><circle cx="103.98725980600334" cy="17.13918469977591" r="1" stroke="black" stroke-width="1" /><circle cx="93.02979132162059" cy="17.736450374662" r="1" stroke="black" stroke-width="1" /><circle cx="81.03937007785001" cy="18.757859601966217" r="1" stroke="black" stroke-width="1" /><circle cx="67.843066055435" cy="21.103420568609884" r="1" stroke="black" stroke-width="1" /><circle cx="52.23953816497982" cy="24.460093449028754" r="1" stroke="black" stroke-width="1" /><circle cx="34.95023378134344" cy="30.771653543150002" r="1" stroke="black" stroke-width="1" /><circle cx="20.015784392169238" cy="42.30777015729562" r="1" stroke="black" stroke-width="1" /><circle cx="17.71337986151086" cy="59.62890348538038" r="1" stroke="black" stroke-width="1" /><circle cx="18.48818897640001" cy="76.69291338499998" r="1" stroke="black" stroke-width="1" /><circle cx="21.063277100054705" cy="93.16624601886353" r="1" stroke="black" stroke-width="1" /><circle cx="25.34317562804314" cy="109.13904477655561" r="1" stroke="black" stroke-width="1" /><circle cx="36.58681722154216" cy="121.6692913371" r="1" stroke="black" stroke-width="1" /><circle cx="53.976709815492" cy="127.46807322973481" r="1" stroke="black" stroke-width="1" /><circle cx="68.8148394495926" cy="131.1242917677153" r="1" stroke="black" stroke-width="1" /><circle cx="81.79527558964998" cy="133.31870041587482" r="1" stroke="black" stroke-width="1" /><circle cx="93.28832623310704" cy="134.93905756388813" r="1" stroke="black" stroke-width="1" /><circle cx="104.05289061330957" cy="135.87443126594144" r="1" stroke="black" stroke-width="1" /><circle cx="114.48818897499999" cy="136.4094488172" r="1" stroke="black" stroke-width="1" /><circle cx="124.98911814399665" cy="136.24664207022408" r="1" stroke="black" stroke-width="1" /><circle cx="135.68805171689291" cy="134.93905756388813" r="1" stroke="black" stroke-width="1" /><circle cx="146.9921259824" cy="132.99138372783509" r="1" stroke="black" stroke-width="1" /><circle cx="159.18976510624978" cy="129.96617733404054" r="1" stroke="black" stroke-width="1" /><circle cx="172.6834392671584" cy="125.52452644141964" r="1" stroke="black" stroke-width="1" /><circle cx="184.20664352746437" cy="116.94488188835004" r="1" stroke="black" stroke-width="1" /><circle cx="192.97841985020898" cy="105.26102110425819" r="1" stroke="black" stroke-width="1" /><circle cx="200.09667396000964" cy="91.7879990654327" r="1" stroke="black" stroke-width="1" /><circle cx="205.9527559028" cy="76.69291338500003" r="1" stroke="black" stroke-width="1" /><circle cx="371.496062987" cy="76.692913385" r="1" stroke="red" stroke-width="1" /><circle cx="468.27087210048916" cy="59.62890348538042" r="1" stroke="black" stroke-width="1" /><circle cx="465.96846756983075" cy="42.30777015729563" r="1" stroke="black" stroke-width="1" /><circle cx="451.0340181806566" cy="30.771653543150002" r="1" stroke="black" stroke-width="1" /><circle cx="433.7447137970202" cy="24.46009344902877" r="1" stroke="black" stroke-width="1" /><circle cx="418.141185906565" cy="21.103420568609884" r="1" stroke="black" stroke-width="1" /><circle cx="404.94488188415005" cy="18.757859601966224" r="1" stroke="black" stroke-width="1" /><circle cx="392.95446064037947" cy="17.736450374662" r="1" stroke="black" stroke-width="1" /><circle cx="381.9969921559967" cy="17.13918469977591" r="1" stroke="black" stroke-width="1" /><circle cx="371.496062987" cy="17.354330708700004" r="1" stroke="black" stroke-width="1" /><circle cx="360.99513381800335" cy="17.13918469977591" r="1" stroke="black" stroke-width="1" /><circle cx="350.2962002451071" cy="18.44676920611186" r="1" stroke="black" stroke-width="1" /><circle cx="338.80314960165003" cy="20.067126354125165" r="1" stroke="black" stroke-width="1" /><circle cx="326.3086001586714" cy="22.840592219122065" r="1" stroke="black" stroke-width="1" /><circle cx="311.5636410443294" cy="26.403640237343964" r="1" stroke="black" stroke-width="1" /><circle cx="294.90395798570114" cy="32.472440944700004" r="1" stroke="black" stroke-width="1" /><circle cx="276.6684989884443" cy="42.178502701552375" r="1" stroke="black" stroke-width="1" /><circle cx="274.34904306922823" cy="59.56327267807415" r="1" stroke="black" stroke-width="1" /><circle cx="280.03149605920004" cy="76.69291338499998" r="1" stroke="black" stroke-width="1" /><circle cx="285.8875780019904" cy="91.78799906543271" r="1" stroke="black" stroke-width="1" /><circle cx="293.005832111791" cy="105.26102110425813" r="1" stroke="black" stroke-width="1" /><circle cx="301.77760843453564" cy="116.94488188835001" r="1" stroke="black" stroke-width="1" /><circle cx="313.3008126948416" cy="125.52452644141961" r="1" stroke="black" stroke-width="1" /><circle cx="326.7944868557502" cy="129.9661773340405" r="1" stroke="black" stroke-width="1" /><circle cx="338.9921259796" cy="132.99138372783506" r="1" stroke="black" stroke-width="1" /><circle cx="350.29620024510706" cy="134.93905756388813" r="1" stroke="black" stroke-width="1" /><circle cx="360.99513381800335" cy="136.24664207022408" r="1" stroke="black" stroke-width="1" /><circle cx="371.496062987" cy="136.4094488172" r="1" stroke="black" stroke-width="1" /><circle cx="381.9313613486904" cy="135.87443126594144" r="1" stroke="black" stroke-width="1" /><circle cx="392.6959257288929" cy="134.93905756388813" r="1" stroke="black" stroke-width="1" /><circle cx="404.18897637235" cy="133.31870041587482" r="1" stroke="black" stroke-width="1" /><circle cx="417.1694125124074" cy="131.12429176771533" r="1" stroke="black" stroke-width="1" /><circle cx="432.007542146508" cy="127.46807322973484" r="1" stroke="black" stroke-width="1" /><circle cx="449.3974347404578" cy="121.66929133710003" r="1" stroke="black" stroke-width="1" /><circle cx="460.64107633395685" cy="109.13904477655569" r="1" stroke="black" stroke-width="1" /><circle cx="464.9209748619453" cy="93.16624601886352" r="1" stroke="black" stroke-width="1" /><circle cx="467.4960629856" cy="76.69291338500003" r="1" stroke="black" stroke-width="1" /></svg>


the code that use is as follows:

        String xmlSVG = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n" +
            "<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\">" + xmlSVGR.trim() + xmlSVGL.trim() + "</svg>";

        try {
          SVGDocument doc = SVGUtility.readSVGDocument(new ByteArrayInputStream(xmlSVG.getBytes()));
          getShapeRField().setSvgDocument(doc);
        }
        catch (ProcessingException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }


the result that I obtain in Swing is:
index.php/fa/14372/0/
the result that I obtain in SWT is:
index.php/fa/14373/0/

Can anyone help me to understand where is the problem or my mistake?

Thanks in advance for your help
  • Attachment: img_Swing.png
    (Size: 4.66KB, Downloaded 735 times)
  • Attachment: img_SWT.png
    (Size: 1.81KB, Downloaded 760 times)
Re: SVG Field in Swing and in SWT [message #1052912 is a reply to message #1041558] Wed, 01 May 2013 09:59 Go to previous messageGo to next message
Matthias Zimmermann is currently offline Matthias ZimmermannFriend
Messages: 208
Registered: June 2015
Senior Member
hi marco

i tried to look at your problem with the svg field. however, using the svg document provided in your post and displaying it as described in the svg field tutorial [1], i was unable to reproduce this issue.

two questions:
1) do you have the same issue when you follow the svg field tutorial [1] with your svg document
2) exactely when and where do you set the content of the svg field, ie. please provide more context around the code snipped in your post

thanks
matthias

[1] http://wiki.eclipse.org/Scout/Tutorial/SVG_Field
Re: SVG Field in Swing and in SWT [message #1053048 is a reply to message #1052912] Thu, 02 May 2013 08:09 Go to previous messageGo to next message
marco giudici is currently offline marco giudiciFriend
Messages: 204
Registered: February 2013
Location: Italy
Senior Member
Hi Matthias,
I followed the guidelines in this tutorial to develop my code. I use it in a private method where I obtained the data from an xml file.

The problem that I would draw attention is, against the same code, the user interface Swing and SWT have different results as I reported in my first post.
Re: SVG Field in Swing and in SWT [message #1053065 is a reply to message #1053048] Thu, 02 May 2013 10:13 Go to previous messageGo to next message
Jeremie Bresson is currently offline Jeremie BressonFriend
Messages: 1252
Registered: October 2011
Senior Member
It is difficult to reproduce the case...

From the current screenshot I cannot tell if your SVG Field is cut in SWT (Layout problem) or if the content is not displayed correctly.

Can you try to set a background color on the field?
getShapeRField().setBackgroundColor("FF0000");


... and make screenshots (from Swing and SWT).

[Updated on: Thu, 02 May 2013 10:13]

Report message to a moderator

Re: SVG Field in Swing and in SWT [message #1053075 is a reply to message #1053065] Thu, 02 May 2013 10:41 Go to previous messageGo to next message
marco giudici is currently offline marco giudiciFriend
Messages: 204
Registered: February 2013
Location: Italy
Senior Member
Hi Jeremie,
I make a test with your suggestion and this is the result:

        String xmlSVG = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n" +
            "<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\">" + xmlSVGR.trim() + xmlSVGL.trim() + "</svg>";

        try {
          SVGDocument doc = SVGUtility.readSVGDocument(new ByteArrayInputStream(xmlSVG.getBytes()));
          [b]getShapeRField().setBackgroundColor("FF0000");[/b]
          getShapeRField().setSvgDocument(doc);
          getShapeRField().setVisible(true);
          getNoShapeField().setVisible(false);
        }
        catch (ProcessingException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
          getShapeRField().setVisible(false);
          getNoShapeField().setVisible(true);
        }


here I report to you the properties of this field:
index.php/fa/14615/0/

this is the result in Swing user interface:
index.php/fa/14613/0/
this is the result in SWT user interface:
index.php/fa/14614/0/

Re: SVG Field in Swing and in SWT [message #1053081 is a reply to message #1053075] Thu, 02 May 2013 11:14 Go to previous messageGo to next message
Jeremie Bresson is currently offline Jeremie BressonFriend
Messages: 1252
Registered: October 2011
Senior Member
It seems to me that the SWT Field does not react as we are expecting...

1. Bug:
SVG Field in SWT do not take into account the background color.


2. Problem: SWT Field Layout

I have seen you use
- Grid Use Ui Height => true
- Grid Use Ui Width => true

I am not sure what the effect is/should be... because a SVG Field do not have a child fields...

I have tried to use instead:
- Height In Pixel
- Width In Pixel
but without any luck in SWT.

I think that using:
- Grid H == 10
- Grid W == <number of column in the parent group box>
produces the best results.
Re: SVG Field in Swing and in SWT [message #1053090 is a reply to message #1053081] Thu, 02 May 2013 11:45 Go to previous messageGo to next message
marco giudici is currently offline marco giudiciFriend
Messages: 204
Registered: February 2013
Location: Italy
Senior Member
Hi Jeremie,
I try with
- Grid H == 10
- Grid W == <number of column in the parent group box>

but the result is always the same.
Re: SVG Field in Swing and in SWT [message #1053135 is a reply to message #1053090] Thu, 02 May 2013 15:35 Go to previous messageGo to next message
Urs Beeli is currently offline Urs BeeliFriend
Messages: 573
Registered: October 2012
Location: Bern, Switzerland
Senior Member
I have no trouble whatsoever getting identical results with SVG under both SWT and Swing.

Looking at marco's code I see that his definition for the <xml> element are rather minimalistic:
<svg xmlns="http://www.w3.org/2000/svg" version="1.1">


In my SVG drawings I use the following attributes for my <xml> element:
<svg width="400" height="400" viewBox="0 0 400 400" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" contentScriptType="text/ecmascript" zoomAndPan="magnify" contentStyleType="text/css" version="1.1" xml:space="preserve" preserveAspectRatio="xMidYMid meet">


Marco, can you try to see if things look better if you use the longer version? You might need to adjust the width, height and viewBox parameters to fit your drawing.
Re: SVG Field in Swing and in SWT [message #1053238 is a reply to message #1053135] Fri, 03 May 2013 10:19 Go to previous messageGo to next message
marco giudici is currently offline marco giudiciFriend
Messages: 204
Registered: February 2013
Location: Italy
Senior Member
Hi Urs,
I followed your suggestion and after changing the values ​​according to my needs, I got more or less the same result on Swing and SWT user interface.
However, the result is improved, at least the design is seen complete in both cases.

Thank you for your help
Re: SVG Field in Swing and in SWT [message #1053471 is a reply to message #1053238] Mon, 06 May 2013 07:44 Go to previous message
Urs Beeli is currently offline Urs BeeliFriend
Messages: 573
Registered: October 2012
Location: Bern, Switzerland
Senior Member
I'm glad you've got it working.
Previous Topic:howto add a new button to toolbar
Next Topic:SWT: Switching between SearchForm/TableForm-Pairs does not work
Goto Forum:
  


Current Time: Fri Mar 29 14:22:38 GMT 2024

Powered by FUDForum. Page generated in 0.03860 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top