XML Elves

XML Elves

<community>of XML and SVG Developers</community>


Grouping SVG element and groups using JavaScript

This is a discussion on Grouping SVG element and groups using JavaScript within the SVG Questions forums, part of the SVG Forums category; Hello guys! Could you pls answer the question concerning the groups+JavaScript? I have some objects on canvas (for example circle, ...


Go Back   XML Elves > SVG Forums > SVG Questions

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Notices


Click here to register

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 09-15-2003, 04:03 AM
Junior Member
 
Join Date: Sep 2003
Posts: 17
Default Grouping SVG element and groups using JavaScript

Hello guys!
Could you pls answer the question concerning the groups+JavaScript?
I have some objects on canvas (for example circle, rect, path,line).
And I want to group them all or some of them (maybe only circle and line) by simple clicking on the corresponding subjects. But I have lack of JavaScript code concerning how better to produse this.
Is there anybody know how to produse this properly?
I need just to create <g>...</g> tags and insert selected elements between them.
Using JavaScript of cource
__________________
rbeit gibt die Freilesung!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 09-16-2003, 02:36 AM
Anonymous
Guest
 
Posts: n/a
Default Grouping SVG element and groups using JavaScript

Hi
You have to
1- create group with group = document.createElementNS(null,"g")
give id to this group group.setAttributeNS(null,"id","MyGroup")
append group to main svg document.rootElement.appendChild(group)
2- clone node to put in group with new_node=evt.target.cloneNode(true)
3- append new node to group document.getElementById("MyGroup").appendChild(new _node)
4- delete moved node with evt.target.parentNode.removeChild(evt.target)

You can adapt script with where put group in DOM tree.

Michel
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 09-16-2003, 05:00 AM
Junior Member
 
Join Date: Sep 2003
Posts: 17
Default SVG+DATABASE


Thank you guest!
That was nice for you to help me.
Now SVG seems much easier for me.
Could you pls answer: How to extract DATA from nodes(elements, group)?
I mean very necessary DATA, which contain x,y - coordinates, styles,id and other
properties...
Is it possible way to save this parameters into DATABASE?
I do the following. Data->JavaScript variables->PHP variables->MySQL DATABASE.
May be somebody know more easier way to store DATA?
Best regards...
_________________
Arbeit gibt die Freilesung!
__________________
rbeit gibt die Freilesung!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 09-16-2003, 05:08 AM
Junior Member
 
Join Date: Sep 2003
Posts: 17
Default Grouping with JavaScript by clicking elements

Could you pls answer me the question:
There some objects on canvas.
How to write function on JavaScript which will connect these objects into group? :roll:
__________________
rbeit gibt die Freilesung!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 09-16-2003, 10:03 AM
Anonymous
Guest
 
Posts: n/a
Default Grouping SVG element and groups using JavaScript

To get DATA from objects you can use

Your_Node.attributes give list of attributes, with length you get number of attributes and with item(i) you get attribute and then name and value ....

with
Code:
<rect x="10" y="20" width="200" ...... />
node.attributes.item(0).name will be x and node.attributes.item(0).value will be 10 ...
but some viewer parsing string change order of attributes ....

To retrieve specific attribute you can use Your_Node.getAttributeNS(null,"x") to get value of x coordinate ....

For text content is firstChild.data for text node

Michel,
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 09-16-2003, 10:08 AM
Anonymous
Guest
 
Posts: n/a
Default Grouping SVG element and groups using JavaScript

I forget end of your question

You can save in database or text file data with postURL or send to php file as variables

For connecting objects in group, what will you make?

Connect objects on graphic with lines?
Group is only structure in DOM tree, you can give common attribute in group for objects (visible by example or color for filling ...) but group give not particular drawing

Michel
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 09-18-2003, 05:25 AM
Junior Member
 
Join Date: Sep 2003
Posts: 17
Default SVG group+JavaScript

Quote:
Originally Posted by Anonymous
I forget end of your question

You can save in database or text file data with postURL or send to php file as variables

For connecting objects in group, what will you make?

Connect objects on graphic with lines?
Group is only structure in DOM tree, you can give common attribute in group for objects (visible by example or color for filling ...) but group give not particular drawing

Michel
I send SVG-attributes(width, height,style) to
Code:
PHP-variables($width, $height,$style)
and then save them into My-SQL database.
I wan to group elements into one LOGICAL group, which I can easyly drag on Canvas by simple mouse event. But while draging this group, it will be seem that all element included into group are draging in the same direction!

I only want to add some interactivity on my pictures...
__________________
rbeit gibt die Freilesung!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 09-19-2003, 03:20 AM
Anonymous
Guest
 
Posts: n/a
Default Grouping SVG element and groups using JavaScript

You can add translation to your group
<g transform="translate(0,0)">
....
</g>
And with script change vector of translation function of position your pointer

Michel
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 02-01-2004, 09:38 PM
shwathi
Guest
 
Posts: n/a
Default Is Retrieving SVG code from a database possible?

Is Retieving SVG code from a MySQL database and executing the code in html through PHP possible? Someone please help me giving an idea.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 02-02-2004, 11:33 AM
Anonymous
Guest
 
Posts: n/a
Default Re: Is Retrieving SVG code from a database possible?

Quote:
Originally Posted by shwathi
Is Retieving SVG code from a MySQL database and executing the code in html through PHP possible? Someone please help me giving an idea.
You can create svg file from your database and open it in explorer.
(Don't forget to send mime-type ... )
If you need html, you can use svg embedded in html.

Michel
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Tags
element, grouping, groups, javascript, svg


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT -6. The time now is 02:26 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0

Compatible Ink Cartridges
For remanufactured and compatible ink cartridges, click here.

canon cartridge
Buy your Canon cartridge online at Internet Ink. We offer discounted prices on a wide variety of canon cartridges.

Hard disk drive data recovery yorkshire
Need hard disk drive data recovery in Yorkshire? We collect all over the UK and never exceed our quotation.

ink cartridges Free UK Delivery on ink cartridges such as Canon, Dell, Epson, hp & Lexmark.

1 2 3 4 5 6 7 8 9 10