Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
moex
Transmorpher
Commits
6c766fdf
Commit
6c766fdf
authored
Apr 10, 2003
by
Fabien Triolet
Browse files
transcoder parameter is used for coosing the type of Transcoder to use.
Available values for this parameter are TIFF, JPEG or PNG.
parent
e2a19066
Changes
1
Hide whitespace changes
Inline
Side-by-side
transmorpher/src/fr/fluxmedia/tmcontrib/serializer/SVGSerializer.java
View file @
6c766fdf
/*
* $Id: SVGSerializer.java,v 1.
1
2003-04-0
9
1
3
:5
1
:4
1
triolet Exp $
* $Id: SVGSerializer.java,v 1.
2
2003-04-
1
0 1
4
:5
2
:4
6
triolet Exp $
*
* Transmorpher
*
...
...
@@ -41,6 +41,8 @@ import org.apache.batik.dom.svg.SAXSVGDocumentFactory;
import
org.apache.batik.dom.svg.SVGDOMImplementation
;
import
org.apache.batik.transcoder.image.*
;
import
org.apache.batik.transcoder.Transcoder
;
import
org.apache.batik.transcoder.TranscoderInput
;
import
org.apache.batik.transcoder.TranscoderOutput
;
...
...
@@ -54,48 +56,47 @@ import javax.xml.transform.dom.DOMResult;
*/
public
final
class
SVGSerializer
extends
TSerializer
{
/**
* The handler that receives SAX events
*/
protected
SVGHandler
handler
=
null
;
protected
SAXTransformerFactory
tfactory
=
null
;
public
SVGSerializer
(
String
[]
pIn
,
Parameters
pParam
,
StringParameters
pStaticAttributes
)
throws
TMRuntimeException
{
super
(
pIn
,
pParam
,
pStaticAttributes
);
handler
=
new
SVGHandler
(
this
);
}
public
void
setOutputStream
()
throws
TMRuntimeException
,
TMException
,
SAXException
{
super
.
setOutputStream
();
}
public
SVGSerializer
(
String
[]
pIn
,
Parameters
pParam
,
StringParameters
pStaticAttributes
)
throws
TMRuntimeException
{
super
(
pIn
,
pParam
,
pStaticAttributes
);
handler
=
new
SVGHandler
(
this
);
}
public
void
setOutputStream
()
throws
TMRuntimeException
,
TMException
,
SAXException
{
super
.
setOutputStream
();
}
public
void
notify
(
Document
doc
)
throws
SAXException
{
try
{
JPEGTranscoder
t
=
new
JPEGTranscoder
();
t
.
addTranscodingHint
(
JPEGTranscoder
.
KEY_QUALITY
,
new
Float
(.
8
));
/* t.addTranscodingHint(JPEGTranscoder.KEY_WIDTH,
new Float(10)); */
trans
.
addTranscodingHint
(
ImageTranscoder
.
KEY_MEDIA
,
"print"
);
public
void
notify
(
Document
doc
)
throws
SAXException
{
try
{
String
transcoderFormat
=(
String
)
getParameters
().
getParameter
(
"transcoder"
);
if
(
transcoderFormat
==
null
)
transcoderFormat
=
"JPEG"
;
String
transcoderName
=
"org.apache.batik.transcoder.image."
+
transcoderFormat
+
"Transcoder"
;
Class
transcoderClass
=
Class
.
forName
(
transcoderName
);
java
.
lang
.
reflect
.
Constructor
[]
transcoderConstructors
=
transcoderClass
.
getConstructors
();
Transcoder
t
=
(
Transcoder
)
transcoderConstructors
[
0
].
newInstance
(
null
);
t
.
addTranscodingHint
(
ImageTranscoder
.
KEY_MEDIA
,
"print"
);
TranscoderInput
input
=
new
TranscoderInput
(
doc
);
TranscoderOutput
output
=
new
TranscoderOutput
(
getOutputStream
());
t
.
transcode
(
input
,
output
);
}
catch
(
Exception
ex
)
{
throw
new
SAXException
(
"Exception writing image "
,
ex
);
}
}
protected
SAXTransformerFactory
getTransformerFactory
()
{
if
(
tfactory
==
null
)
{
tfactory
=
(
SAXTransformerFactory
)
TransformerFactory
.
newInstance
();
TranscoderInput
input
=
new
TranscoderInput
(
doc
);
TranscoderOutput
output
=
new
TranscoderOutput
(
getOutputStream
());
t
.
transcode
(
input
,
output
);
}
return
tfactory
;
catch
(
Exception
ex
)
{
throw
new
SAXException
(
"Exception writing image "
,
ex
);
}
}
public
ContentHandler
getContentHandler
()
{
return
(
ContentHandler
)
handler
;
}
public
ContentHandler
getContentHandler
()
{
return
(
ContentHandler
)
handler
;
}
}
class
SVGHandler
extends
SAXSVGDocumentFactory
{
...
...
@@ -130,9 +131,6 @@ class SVGHandler extends SAXSVGDocumentFactory{
try
{
super
.
endDocument
();
// FIXME: Hack.
((
org
.
apache
.
batik
.
dom
.
svg
.
SVGOMDocument
)
this
.
document
).
setURLObject
(
new
java
.
net
.
URL
(
"http://xml.apache.org"
));
owner
.
notify
(
this
.
document
);
}
catch
(
Exception
ex
){
ex
.
printStackTrace
();
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment