Hi Lewis,
Lewis Keen <[EMAIL PROTECTED]> wrote on 02/12/2006 09:37:17 PM:
> 1) I currently have a button class that does all of the adding of the
> xml to the document etc. and was wondering if there was an easier way
> of doing this? Most of the examples I've seen suggest that I simply
> use the Document/Element to build my document up, and that is what I
> am doing atm, I was just wondering if there was a more elegant way of
> doing it.
Well some people will clone an 'example' piece of XML. Some things
you can use the 'use' element.
> 2) Updating of the SVG once its been modified. Yes I know this has
> been a problem with a few people :) I've implemented it in the way I
> think is right, but from some reason its not working :/ I have a
> status indicator in the bottom right that changes to yellow when
> connecting and green when connected. However, the change from red to
> yellow and yellow to green is about 2-3 seconds each.
The problem is the massive filter effect on the whole canvas:
> 3) More examples - are there any? I've always been someone who's found
> it easier to learn from example rather than trawling through pages of
> javadoc. Looking at the site there are a few examples but not that
> many and was wondering if I had missed anything.
The samples directory has lots of example SVG. The solitaire
examples are just one, there is also a minesweeper game and a
few other 'interactive' documents that at least give examples of
how other people think SVG should be manipulated.
> such as sending the client the svg of each of the cards that they can
> see on the board.
Why would you send them SVG? I would send them something like:
'2H' or 'KS' (two of harts, king of spades). Is there any reason
they wouldn't have all the 'card' stuff themselves?
> I can see how to do it using Document/Element but
> again its a case of is there a more elegant way?
Well the solitaire examples use the 'use' element with
a base 'deck' SVG file and the card names (as above) are
the 'id' of the individual cards.
> 4) Any general tips about my code (see below). Its kinda messy atm and
> I'm not sure if I've got everything I need in there to make things
> work correctly. I'm not asking for someone to write the code for me,
> just point me in the right direction :)
> Element svgRoot = document.getDocumentElement();
> NodeList rootElements=
svgRoot.getElementsByTagName("circle");
> Element status=(Element)rootElements.item(0);
> status.setAttributeNS(null,"fill",color);
'getElementById' is much faster (now at least) and doesn't depend on
there
being only one circle in the document.
> <rect x="0" y="0" width="720" height="520" rx="40"
fill="olivedrab"
> stroke="saddlebrown" stroke-width="10" filter="url(#MyFilter)" />
This filter is the basic problem, filters can be very slow.
Unfortunately
until the 'static' property becomes commonly implemented it is really not
possible to use filter effects to provide a 'complex' background. You are
unfortunately currently much better off using a raster, or just
simplifying
the content (by removing the filter).
> <filter id="MyFilter" filterUnits="userSpaceOnUse" x="0" y="0">
> <feGaussianBlur in="SourceAlpha" stdDeviation="4"
result="blur"/>
> <feOffset in="blur" dx="4" dy="4" result="offsetBlur"/>
> <feSpecularLighting in="blur" surfaceScale="5"
> specularConstant=".75" specularExponent="20" lighting-color="#bbbbbb"
> result="specOut">
> <fePointLight x="-5000" y="-10000" z="20000"/>
> </feSpecularLighting>
> <feComposite in="specOut" in2="SourceAlpha" operator="in"
result="specOut"/>
> <feComposite in="SourceGraphic" in2="specOut"
operator="arithmetic"
> k1="0" k2="1" k3="1" k4="0" result="litPaint"/>
> <feMerge>
> <feMergeNode in="offsetBlur"/>
> <feMergeNode in="litPaint"/>
> </feMerge>
> </filter>
> </defs>
> </svg>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]