List Info

Thread: how to draw markers




how to draw markers
country flaguser name
United States
2007-05-26 03:24:31
does anyone have an example for drawing markers in batik? or
can anyone guide
me through it? thanks
-- 
View this message in context: http://www.nabble.com/how-to-draw-markers-tf38
19799.html#a10814414
Sent from the Batik - Users mailing list archive at
Nabble.com.


------------------------------------------------------------
---------
To unsubscribe, e-mail: batik-users-unsubscribexmlgraphics.apache.org
For additional commands, e-mail: batik-users-helpxmlgraphics.apache.org


Re: how to draw markers
country flaguser name
Germany
2007-05-26 07:54:02
Hello hardc0d3r,

you asked for help with drawing markers.
When recently I introduced markers into my app, I found
http:/
/www.w3.org/TR/SVG/painting.html#Markers quite helpful.
If you need anything beyond that, please ask for details.

Regards
-Urs

------------------------------------------------------------
---------
To unsubscribe, e-mail: batik-users-unsubscribexmlgraphics.apache.org
For additional commands, e-mail: batik-users-helpxmlgraphics.apache.org


Re: how to draw markers
country flaguser name
United States
2007-05-26 09:33:17
sir, how do i do this in batik? how do i add the path do the
marker element?
-- 
View this message in context: http://www.nabble.com/how-to-draw-markers-tf38
19799.html#a10816891
Sent from the Batik - Users mailing list archive at
Nabble.com.


------------------------------------------------------------
---------
To unsubscribe, e-mail: batik-users-unsubscribexmlgraphics.apache.org
For additional commands, e-mail: batik-users-helpxmlgraphics.apache.org


Re: how to draw markers
country flaguser name
Germany
2007-05-26 09:55:46
hardc0d3r wrote:
> sir, how do i do this in batik? how do i add the path
do the marker element?

after loading the svg containing the marker e.g. into an
SVGCanvas named
svgCanvas fetch the document:

org.w3c.dom.Document document = svgCanvas.getSVGDocument();

best do this in a listener callback as loading svg in batik
is not
synchronous, like

treeRendererAdapter = new GVTTreeRendererAdapter() {
  public void gvtRenderingCompleted(GVTTreeRendererEvent e)
{
    // initialise document root
    document = svgCanvas.getSVGDocument();
  }
};
svgCanvas.addGVTTreeRendererListener(treeRendererAdapter);

The rest can be done via the documents DOM interface:

find your marker element -lets name it markEl- by name, id
or path
(svgCanvas.getElementById, svgCanvas.getElementsByName or
using sth.
like javax.xml.xpath.XPath)

Then create and attach the attribute:
  org.w3c.dom.Attr att =
document.createAttribute("path");
  att.setValue("M0,0 v100");
  markEl.setAttributeNode(att);

Cheers,

     Robert

------------------------------------------------------------
---------
To unsubscribe, e-mail: batik-users-unsubscribexmlgraphics.apache.org
For additional commands, e-mail: batik-users-helpxmlgraphics.apache.org


Re: how to draw markers
country flaguser name
United States
2007-05-26 10:00:33
do i need a svg element to load inorder for the marker to
work? or can i make
one when creating a new svg?
-- 
View this message in context: http://www.nabble.com/how-to-draw-markers-tf38
19799.html#a10817119
Sent from the Batik - Users mailing list archive at
Nabble.com.


------------------------------------------------------------
---------
To unsubscribe, e-mail: batik-users-unsubscribexmlgraphics.apache.org
For additional commands, e-mail: batik-users-helpxmlgraphics.apache.org


Re: how to draw markers
country flaguser name
United States
2007-05-26 10:03:54
sorry i get it now.. thanks for the replies
-- 
View this message in context: http://www.nabble.com/how-to-draw-markers-tf38
19799.html#a10817163
Sent from the Batik - Users mailing list archive at
Nabble.com.


------------------------------------------------------------
---------
To unsubscribe, e-mail: batik-users-unsubscribexmlgraphics.apache.org
For additional commands, e-mail: batik-users-helpxmlgraphics.apache.org


Re: how to draw markers
country flaguser name
United States
2007-05-26 10:28:22
i tried what you said but failed.. here is the code..

            Element defs = doc.createElementNS(svgNS,
"defs");
            Element startArrow = doc.createElementNS(svgNS,
"marker");
            startArrow.setAttributeNS(null, "id",
"startArrow");
            startArrow.setAttributeNS(null,
"viewBox", "0 0 10 10");
            startArrow.setAttributeNS(null,
"refX", "0");
            startArrow.setAttributeNS(null,
"refY", "6");
            startArrow.setAttributeNS(null,
"markerUnits", "strokewidth");
            startArrow.setAttributeNS(null,
"orient", "auto");
            startArrow.setAttributeNS(null,
"markerWidth", "5");
            startArrow.setAttributeNS(null,
"markerHeight", "4");
            Attr att =
doc.createAttribute("path");
            att.setValue("M0,0 L10,0 L0,5 L10,10 L10,5
z");
            startArrow.setAttributeNode(att); 
            defs.appendChild(startArrow);

and here is how i call the marker:
            
            shape.setAttributeNS(null,
"marker-start", "url(#startArrow)");

help..
-- 
View this message in context: http://www.nabble.com/how-to-draw-markers-tf38
19799.html#a10817347
Sent from the Batik - Users mailing list archive at
Nabble.com.


------------------------------------------------------------
---------
To unsubscribe, e-mail: batik-users-unsubscribexmlgraphics.apache.org
For additional commands, e-mail: batik-users-helpxmlgraphics.apache.org


Re: how to draw markers
country flaguser name
United States
2007-05-26 22:14:03
ok.. solved it! i just have to append the path element to
the marker..

somethig like these:
            Element defs = doc.createElementNS(svgNS,
"defs");
            Element startArrow = doc.createElementNS(svgNS,
"marker");
            startArrow.setAttributeNS(null, "id",
"startArrow");
            startArrow.setAttributeNS(null,
"viewBox", "0 0 10 10");
            startArrow.setAttributeNS(null,
"refX", "0");
            startArrow.setAttributeNS(null,
"refY", "6");
            startArrow.setAttributeNS(null,
"markerUnits", "strokeWidth");
            startArrow.setAttributeNS(null,
"orient", "auto");
            startArrow.setAttributeNS(null,
"markerWidth", "5");
            startArrow.setAttributeNS(null,
"markerHeight", "4");
            defs.appendChild(startArrow);
            
            Element path = doc.createElementNS(svgNS,
"path");
            path.setAttribute("d", "M0,1 L5,1
L5,0 L10,1.5 L5,3 L5,2 L0,2
L0,1 Z");
            startArrow.appendChild(path);
-- 
View this message in context: http://www.nabble.com/how-to-draw-markers-tf38
19799.html#a10821960
Sent from the Batik - Users mailing list archive at
Nabble.com.


------------------------------------------------------------
---------
To unsubscribe, e-mail: batik-users-unsubscribexmlgraphics.apache.org
For additional commands, e-mail: batik-users-helpxmlgraphics.apache.org


[1-8]

about | contact  Other archives ( Real Estate discussion Medical topics )