xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Steiner, Dominik" <Dominik.Stei...@gigatronik.com>
Subject AW: Clipping SVG documents
Date Fri, 09 Jun 2006 07:27:15 GMT
Hi Tilo,

can you explain what you mean by 'painted the wrong way round'?

Another thing that might interest you is that after I create the svg element from the shape
I set the viewbox on the clipped document so that the clipped region gets fully display in
a SVGCanvas.

		Rectangle2D rect = shape.getBounds2D();
		int offx = 10;
		int offy = 10;
		float offsetx = rect.getWidth() / 100 * offx;
		float offsety = rect.getHeight() / 100 * offy;
		String viewBoxAttr = (rect.getX() - (offsetx / 2)) + " " + (rect.getY() - (offsety / 2))
				+ " " + (rect.getWidth() + offsetx) + " " + (rect.getHeight() + offsety);
		doc.getRootElement().setAttributeNS(null,
				SVGConstants.SVG_VIEW_BOX_ATTRIBUTE, viewBoxAttr);

Dominik Steiner
Dipl-Ing. Informationstechnik (BA)
GIGATRONIK
Gesellschaft für Automobil-
elektronikentwicklung mbH
Taunusstr. 21
80807 München
Telefon +49 (0) 89 / 353 96 80-70
Telefax +49 (0) 89 / 353 96 80-99
mailto:dominik.steiner@gigatronik.com
www.gigatronik.com


-----Ursprüngliche Nachricht-----
Von: Tilo Behrmann [mailto:T.behrmann@gmx.net] 
Gesendet: Freitag, 9. Juni 2006 09:19
An: batik-users@xmlgraphics.apache.org
Betreff: AW: Clipping SVG documents

Hi Dominik,

thanks for help, i see it is not only a problem for me.
Some other question on the peace of code that you have send it, Batik
clipped the district that i define on the shape element, but he painted the
wrong way round. Have
you a idea way.

-----Ursprüngliche Nachricht-----
Von: Steiner, Dominik [mailto:Dominik.Steiner@gigatronik.com]
Gesendet: Freitag, 9. Juni 2006 08:55
An: batik-users@xmlgraphics.apache.org; T.behrmann@gmx.net
Betreff: AW: Clipping SVG documents


Hi Tilo,

I have the same problem (big svg map file) and I couldn't come up with any
solution either.

I guess you could probably cut off the non visible parts by hand out of the
document but I haven't any clue if there is a nice solution to that problem.

Perhaps Andreas had a similar issue?


Dominik Steiner
Dipl-Ing. Informationstechnik (BA)
GIGATRONIK
Gesellschaft für Automobil-
elektronikentwicklung mbH
Taunusstr. 21
80807 München
Telefon +49 (0) 89 / 353 96 80-70
Telefax +49 (0) 89 / 353 96 80-99
mailto:dominik.steiner@gigatronik.com
www.gigatronik.com

-----Ursprüngliche Nachricht-----
Von: Tilo Behrmann [mailto:T.behrmann@gmx.net]
Gesendet: Freitag, 9. Juni 2006 08:19
An: batik-users@xmlgraphics.apache.org
Betreff: AW: Clipping SVG documents

Hi Dominik,

i have found my failure. My next Question is it is possible to generate a
SVG Document that only contains the svg code from the clipping path. The
main Problem is i have tree JSVGCanvas in the first i show the hole map in
the second a part of this map (like a district) and in the last i show only
a special point of the map. The problem is when i have a svg File that is
1Mb big the batik needs 600 Mb Memory and the system works very slow. Have
anybody a idea to solve this problem.

-----Ursprüngliche Nachricht-----
Von: Steiner, Dominik [mailto:Dominik.Steiner@gigatronik.com]
Gesendet: Donnerstag, 8. Juni 2006 15:15
An: batik-users@xmlgraphics.apache.org; T.behrmann@gmx.net
Betreff: AW: Clipping SVG documents


Hi Tilo,

perhaps this one can help:

// shape is your clipping shape, so for example a polygon and
// svgDocument the document you want to clip
public void clipMap(SVGDocument svgDocument, java.awt.Shape shape)
{
	// first clone the document
	SVGDocument doc = (SVGDocument) svgDocument.cloneNode(true);

	// create an svg element from the clipping shape with the cloned
document
	SVGGraphics2D svgGenerator = new SVGGraphics2D(doc);
	Element svgShape = svgGenerator.getShapeConverter().toSVG(shape);

	// add the clipping element to the <defs> tag of the document
	NodeList n1 = doc.getRootElement().getElementsByTagName(
SVGConstants.SVG_DEFS_TAG);
	Element defs = (Element) n1.item(0);

	// create the <clip-path> tag
	Element clip = doc.createElementNS(svgNS, SVGConstants.SVG_CLIP_PATH_TAG);
	clip.setAttributeNS(null, SVGConstants.SVG_ID_ATTRIBUTE, "clipmap");

      // append the clip shape to the clip path and the <defs> tag
	clip.appendChild(svgShape);
	defs.appendChild(clip);

	// reference the clipping from the element you want to clip
	Element el = doc.getElementById("myelement");
	el.setAttributeNS(null, SVGConstants.SVG_CLIP_PATH_ATTRIBUTE,
				"url(#clipmap)");
}


Dominik Steiner
Dipl-Ing. Informationstechnik (BA)
GIGATRONIK
Gesellschaft für Automobil-
elektronikentwicklung mbH
Taunusstr. 21
80807 München
Telefon +49 (0) 89 / 353 96 80-70
Telefax +49 (0) 89 / 353 96 80-99
mailto:dominik.steiner@gigatronik.com
www.gigatronik.com

-----Ursprüngliche Nachricht-----
Von: Tilo Behrmann [mailto:T.behrmann@gmx.net]
Gesendet: Donnerstag, 8. Juni 2006 14:54
An: Batik User
Betreff: Clipping SVG documents

Hi all,

I have an SVG document and I want to generate an SVG document that contains
only a smaller part of this document - just cut a rectangle from the
original image. Does anyone have an idea about how to do this using the
Batik toolkit ?

MfG

Tilo


---------------------------------------------------------------------
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



---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org


Mime
View raw message