You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by ra...@blueyonder.co.uk on 2006/04/13 17:57:23 UTC
removing elements
Hi All,
Can someone plz advice me how to remove elements from a group, to make
myself clear, ...I have added a 'CircleGroup', to my svgDocument, now I
want to remove some of the circles from this group????
Thanx
yasmin
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
RE: removing elements
Posted by th...@kodak.com.
Hi all,
If you have the 'id' of the element(s) to remove you can do this easily
(and quickly) with:
Element e = document.getElementById(<element to removes id>);
e.getParentNode().removeChild(e);
So wrap this in your accidents2Remove for loop and just those elements
will be removed.
rafiqy@blueyonder.co.uk wrote on 04/13/2006 03:24:39 PM:
> All the cirlce id's I want to remove are stored in an array ...
> when I try to execute my code, it runs but does not get processed, I
think it's the
> way I'v looped it ...
You don't advance child, you need to add:
child = child.getNextSibling();
at the end of the while(child!=null) loop...
can you please have a look at my code, and see if you
> can spot what Im doing wrong:
>
> SVGDocument svgDocument = canvas.getSVGDocument();
> String SVGNS = SVGDOMImplementation.SVG_NAMESPACE_URI;
> Element g = svgDocument.getElementById("circleGroup");
>
> Element child = (Element) g.getFirstChild();
>
> while (child != null)
> {
>
> for (int i=0; i<accident2Remove.size(); i++)
> {
> AccidentRecord accidentR = (AccidentRecord)
accident2Remove.get(i);
> Point2D point2D = accidentR.getPoint2D();
>
>
> if (child.getAttribute("id") == point2D.toString())
> {
> g.removeChild(child);
> }
> }
> }
>
> Many thanx
>
> yasmin
>
>
>
>
> > Yasmin,
> > If you have some id information associated with the circles then you
could
> > remove it like this:
> >
> > Element circleGroup
> >
> > Element child = (Element) circleGroup.getFirstChild()
> > while (child != null) {
> > if child.getAttributeNS(SVG_NS, "id" ) == "your id"
> > circleGroup.removeChild(child);
> > }
> >
> > I think this would work but I haven't tested it.
> >
> > Javid
> >
> > -----Original Message-----
> > From: rafiqy@blueyonder.co.uk [mailto:rafiqy@blueyonder.co.uk]
> > Sent: Thursday, April 13, 2006 10:57 AM
> > To: batik-users@xmlgraphics.apache.org
> > Subject: removing elements
> >
> >
> > Hi All,
> >
> > Can someone plz advice me how to remove elements from a group, to make
> > myself clear, ...I have added a 'CircleGroup', to my svgDocument, now
I
> > want to remove some of the circles from this group????
> >
> > Thanx
> >
> > yasmin
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> > For additional commands, e-mail:
batik-users-help@xmlgraphics.apache.org
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> > For additional commands, e-mail:
batik-users-help@xmlgraphics.apache.org
> >
> >
> >
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
RE: removing elements
Posted by ra...@blueyonder.co.uk.
Hi Javid,
All the cirlce id's I want to remove are stored in an array ...when I try
to execute my code, it runs but does not get processed, I think it's the
way I'v looped it ...can you please have a look at my code, and see if you
can spot what Im doing wrong:
SVGDocument svgDocument = canvas.getSVGDocument();
String SVGNS = SVGDOMImplementation.SVG_NAMESPACE_URI;
Element g = svgDocument.getElementById("circleGroup");
Element child = (Element) g.getFirstChild();
while (child != null)
{
for (int i=0; i<accident2Remove.size(); i++)
{
AccidentRecord accidentR = (AccidentRecord) accident2Remove.get(i);
Point2D point2D = accidentR.getPoint2D();
if (child.getAttribute("id") == point2D.toString())
{
g.removeChild(child);
}
}
}
Many thanx
yasmin
> Yasmin,
> If you have some id information associated with the circles then you could
> remove it like this:
>
> Element circleGroup
>
> Element child = (Element) circleGroup.getFirstChild()
> while (child != null) {
> if child.getAttributeNS(SVG_NS, "id" ) == "your id"
> circleGroup.removeChild(child);
> }
>
> I think this would work but I haven't tested it.
>
> Javid
>
> -----Original Message-----
> From: rafiqy@blueyonder.co.uk [mailto:rafiqy@blueyonder.co.uk]
> Sent: Thursday, April 13, 2006 10:57 AM
> To: batik-users@xmlgraphics.apache.org
> Subject: removing elements
>
>
> Hi All,
>
> Can someone plz advice me how to remove elements from a group, to make
> myself clear, ...I have added a 'CircleGroup', to my svgDocument, now I
> want to remove some of the circles from this group????
>
> Thanx
>
> yasmin
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
RE: removing elements
Posted by th...@kodak.com.
Hi Javid,
Your code below will work, but in most cases it would be simpler (and
faster) to
simply remove the group, and create a new one...
"Javid Alimohideen" <ja...@gmail.com> wrote on 04/13/2006 03:55:43 PM:
> Yasmin,
> It will work, but the question is how you would like to do. In my
> application, I remove all the elements from the circleGroup and add the
new
> set of circles. You could use the method below to remove all the child
> elements
>
> void removeAllChild(Element elt)
> {
> while (elt.getFirstChild() != null)
> {
> elt.removeChild(elt.getFirstchild());
> }
> }
>
> Say, if you call your circle group to be circleSet, the you would call
the
> above method passing the circleSet as an argument.
>
> Hope, it helps,
>
> Javid
>
> -----Original Message-----
> From: rafiqy@blueyonder.co.uk [mailto:rafiqy@blueyonder.co.uk]
> Sent: Thursday, April 13, 2006 2:36 PM
> To: batik-users@xmlgraphics.apache.org
> Subject: RE: removing elements
>
>
> Avid,
>
> ...would it be better if I removed all the 'circle Group' and then add
it
> again with only the circles I want to display...?
>
> yasmin
>
>
> > Yasmin,
> > If you have some id information associated with the circles then you
could
> > remove it like this:
> >
> > Element circleGroup
> >
> > Element child = (Element) circleGroup.getFirstChild()
> > while (child != null) {
> > if child.getAttributeNS(SVG_NS, "id" ) == "your id"
> > circleGroup.removeChild(child);
> > }
> >
> > I think this would work but I haven't tested it.
> >
> > Javid
> >
> > -----Original Message-----
> > From: rafiqy@blueyonder.co.uk [mailto:rafiqy@blueyonder.co.uk]
> > Sent: Thursday, April 13, 2006 10:57 AM
> > To: batik-users@xmlgraphics.apache.org
> > Subject: removing elements
> >
> >
> > Hi All,
> >
> > Can someone plz advice me how to remove elements from a group, to make
> > myself clear, ...I have added a 'CircleGroup', to my svgDocument, now
I
> > want to remove some of the circles from this group????
> >
> > Thanx
> >
> > yasmin
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> > For additional commands, e-mail:
batik-users-help@xmlgraphics.apache.org
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> > For additional commands, e-mail:
batik-users-help@xmlgraphics.apache.org
> >
> >
> >
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
RE: removing elements
Posted by Javid Alimohideen <ja...@gmail.com>.
Yasmin,
It will work, but the question is how you would like to do. In my
application, I remove all the elements from the circleGroup and add the new
set of circles. You could use the method below to remove all the child
elements
void removeAllChild(Element elt)
{
while (elt.getFirstChild() != null)
{
elt.removeChild(elt.getFirstchild());
}
}
Say, if you call your circle group to be circleSet, the you would call the
above method passing the circleSet as an argument.
Hope, it helps,
Javid
-----Original Message-----
From: rafiqy@blueyonder.co.uk [mailto:rafiqy@blueyonder.co.uk]
Sent: Thursday, April 13, 2006 2:36 PM
To: batik-users@xmlgraphics.apache.org
Subject: RE: removing elements
Avid,
...would it be better if I removed all the 'circle Group' and then add it
again with only the circles I want to display...?
yasmin
> Yasmin,
> If you have some id information associated with the circles then you could
> remove it like this:
>
> Element circleGroup
>
> Element child = (Element) circleGroup.getFirstChild()
> while (child != null) {
> if child.getAttributeNS(SVG_NS, "id" ) == "your id"
> circleGroup.removeChild(child);
> }
>
> I think this would work but I haven't tested it.
>
> Javid
>
> -----Original Message-----
> From: rafiqy@blueyonder.co.uk [mailto:rafiqy@blueyonder.co.uk]
> Sent: Thursday, April 13, 2006 10:57 AM
> To: batik-users@xmlgraphics.apache.org
> Subject: removing elements
>
>
> Hi All,
>
> Can someone plz advice me how to remove elements from a group, to make
> myself clear, ...I have added a 'CircleGroup', to my svgDocument, now I
> want to remove some of the circles from this group????
>
> Thanx
>
> yasmin
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
RE: removing elements
Posted by ra...@blueyonder.co.uk.
Avid,
...would it be better if I removed all the 'circle Group' and then add it
again with only the circles I want to display...?
yasmin
> Yasmin,
> If you have some id information associated with the circles then you could
> remove it like this:
>
> Element circleGroup
>
> Element child = (Element) circleGroup.getFirstChild()
> while (child != null) {
> if child.getAttributeNS(SVG_NS, "id" ) == "your id"
> circleGroup.removeChild(child);
> }
>
> I think this would work but I haven't tested it.
>
> Javid
>
> -----Original Message-----
> From: rafiqy@blueyonder.co.uk [mailto:rafiqy@blueyonder.co.uk]
> Sent: Thursday, April 13, 2006 10:57 AM
> To: batik-users@xmlgraphics.apache.org
> Subject: removing elements
>
>
> Hi All,
>
> Can someone plz advice me how to remove elements from a group, to make
> myself clear, ...I have added a 'CircleGroup', to my svgDocument, now I
> want to remove some of the circles from this group????
>
> Thanx
>
> yasmin
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
RE: removing elements
Posted by Javid Alimohideen <ja...@gmail.com>.
Yasmin,
If you have some id information associated with the circles then you could
remove it like this:
Element circleGroup
Element child = (Element) circleGroup.getFirstChild()
while (child != null) {
if child.getAttributeNS(SVG_NS, "id" ) == "your id"
circleGroup.removeChild(child);
}
I think this would work but I haven't tested it.
Javid
-----Original Message-----
From: rafiqy@blueyonder.co.uk [mailto:rafiqy@blueyonder.co.uk]
Sent: Thursday, April 13, 2006 10:57 AM
To: batik-users@xmlgraphics.apache.org
Subject: removing elements
Hi All,
Can someone plz advice me how to remove elements from a group, to make
myself clear, ...I have added a 'CircleGroup', to my svgDocument, now I
want to remove some of the circles from this group????
Thanx
yasmin
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org