public abstract class SvgSource extends Object
MfMain
is currently the tool-facade.
The derived classes realize different languages to define moving Svg graphics.
Two methods must be called from this class: first update()
,
which parses the time information into instance registers.
Iff this succeeds, followed by
(PrintWriter, String, int, int, int, int, int, int,String, double)
.
which constructs the general text frame of the generated Svg file and calls in turn
convertData()
, which must be overridden by the sub-class to generate the specific
Svg/Smil commands.
The usage of dynamic svg is rather well explained in
http://www.ibm.com/developerworks/xml/tutorials/x-dynamicsvg/section4.html
(this link is regrettably void, but see instead
https://web.archive.org/web/20110206162341/http://www.ibm.com/developerworks/xml/tutorials/x-dynamicsvg/section4.html
and
https://web.archive.org/web/20120330112222/http://www.ibm.com/developerworks/xml/tutorials/x-dynamicsvg/
It says
"[...] Synchronized Multimedia Integration Language (SMIL).
SMIL is an XML format to describe multi-media presentations, and it includes an
animation module that SVG borrows for its own use."
SMIL / animation in turn is documented in
http://www.w3.org/TR/SMIL/smil-animation.html#animationNS-BasicAnimationElements
The "svg homepage" is at
http://www.w3.org/Graphics/SVG/
The specs are in several files at
http://www.w3.org/TR/SVG11/
(( some hints from 2007 wrt. technical problems :
http://jwatt.org/svg/authoring/ ))
weiteres Tutorial SVG allgemein / incl animation, auf Deutsch:
http://svg.tutorial.aptico.de/start.php
weiteres Tutorial SVG allgemein / incl animation:
http://tutorials.jenkov.com/svg/
Modifier and Type | Class and Description |
---|---|
protected class |
SvgSource.ParamTranslate
Visits all events of a given iterator pairwise and writes out the Svg/Smil commands.
|
(package private) class |
SvgSource.Process
Visits all events of a given iterator pairwise and prepares time and interpolation
values.
|
Modifier and Type | Field and Description |
---|---|
(package private) SortedMap<Duration_calendaric,TpTop> |
caldur2tp
Inverse of the Map
tp2caldur . |
protected Modifiers |
defaultModifiers
The modifiers for the parameter parsing process, including that of the time points.
|
protected Tp |
firstTp
The very first time point, as specified in the input score data.
|
protected int |
hiX
The rightmost user coordinate.
|
protected int |
hiY
The numerically highest vertical user coordinate.
|
protected Tp |
lastTp
The very last time point, as specified in the input score data.
|
protected int |
lowX
The leftmost user coordinate.
|
protected int |
lowY
The numerically lowest vertical user coordinate.
|
protected MessageReceiver<SimpleMessage<XMLDocumentIdentifier>> |
msg
Target of all local messages, maybe including a counter, etc.
|
protected MessageReceiver<SimpleMessage<XMLDocumentIdentifier>> |
msgr
External message receiver, to which all messages are finally sent.
|
protected Part |
part
The tscore data to be processed.
|
protected int |
physHiX
The numeric highest value of svg x coordinates.
|
protected int |
physHiY
The numeric highest value of svg y coordinates.
|
protected String |
punit
The string naming the unit of svg distance encoding.
|
protected PrintWriter |
pw
The drain of all print commands which generate the source text.
|
protected Multimap<Rational,Tp> |
rat2tp
Inverse of the Map
tp2rat . |
protected double |
timeFactor
A possible additional stretch factor for the time coordinates, supplied explicitly
by the user.
|
(package private) Map<TpTop,Duration_calendaric> |
tp2caldur
Maps the score top-level time points to calendaric ("physical") duration values.
|
(package private) Map<Tp,Rational> |
tp2rat
Maps all time points to rational values.
|
protected double |
xFact
The stretch factor for the translation of the horizontal coordinates.
|
protected double |
yFact
The stretch factor for the translation of the vertical coordinates.
|
Constructor and Description |
---|
SvgSource(Part part,
MessageReceiver<SimpleMessage<XMLDocumentIdentifier>> msgr)
Only constructor, sets the tscore score data and the drain of all messages.
|
Modifier and Type | Method and Description |
---|---|
static String |
alpha2string(int user)
Returns in a target text string the encoding of the given opacity.
|
protected String |
animateString_tp(String attname,
double t1,
double t2,
String v1,
String v2)
Generate a target text string which executes an animation.
|
protected String |
animateString(String attname,
double t1,
double duration,
String v1,
String v2)
Generate a target text string which executes an animation.
|
protected String |
animateTransformString(String attname,
double t1,
double t2,
String v1,
String v2)
Generate a target text string which executes an animation.
|
protected <T> boolean |
check_init_def(Event firstEv,
Vox v,
Map<Event,T> map,
String pname)
Checks whether the very first event of a particular voice has a necessary parameter.
|
static String |
color2string(Color_rgb_8 user)
Returns in a target text string the encoding of the given color.
|
protected abstract void |
convertData()
Must be overridden by the sub-class which realizes the specific conversion.
|
void |
convertToSvg(PrintWriter pw,
String title,
int ulox,
int uloy,
int uhix,
int uhiy,
int phix,
int phiy,
MfOptions.physUnit punit,
double timeFactor)
Second main entry point, called after a successful execution of
update() . |
protected String |
height2device(float userY)
Returns in a target text string a given difference in user y-coordinates (y-height)
encoded in svg coordinates.
|
protected String |
height2device(int userY)
Returns in a target text string a given difference in user y-coordinates (y-height)
encoded in svg coordinates.
|
protected void |
printAlpha(int user)
Print the given vakue to the generated output text as an "opacity=" XML attribute.
|
protected void |
printColor(Color_rgb_8 user)
Print the given color to the generated output text as value of a "fill=" XML attribute.
|
protected String |
setString(String attname,
double t1,
String v1)
Generate a target text string which sets the value of an attribute.
|
protected double |
tp2device(Tp tp)
Returns in a target text string a given tscore time point encoded in svg/smil
time point values.
|
void |
update()
First main entry point, called by the subclasses which realize
the specializations,
and executes parsing of time points, and further sort operations.
|
protected double |
when2device(Event e)
Returns in a target text string the onset of the given event
encoded in svg/smil time point values.
|
protected String |
width2device(float userX)
Returns in a target text string a given difference in user x-coordinates (x-width)
encoded in svg coordinates.
|
protected String |
width2device(int userX)
Returns in a target text string a given difference in user x-coordinates (x-width)
encoded in svg coordinates.
|
protected String |
x2device(int userX)
Returns in a target text string a given position in user x-coordinates (x-pos)
encoded in svg coordinates.
|
protected String |
y2device(int userY)
Returns in a target text string a given position in user y-coordinates (y-pos)
encoded in svg coordinates.
|
protected MessageReceiver<SimpleMessage<XMLDocumentIdentifier>> msg
protected final MessageReceiver<SimpleMessage<XMLDocumentIdentifier>> msgr
protected final Part part
protected final Modifiers defaultModifiers
final Map<TpTop,Duration_calendaric> tp2caldur
final SortedMap<Duration_calendaric,TpTop> caldur2tp
tp2caldur
.protected Tp firstTp
protected Tp lastTp
protected PrintWriter pw
protected int lowX
protected int lowY
tscore coord --> svg coords x 20 70 0 800 y 20 70 0 800
protected int hiX
physHiX
.protected int hiY
protected String punit
protected int physHiX
protected int physHiY
protected double xFact
protected double yFact
protected double timeFactor
public SvgSource(Part part, MessageReceiver<SimpleMessage<XMLDocumentIdentifier>> msgr)
public void update()
protected String width2device(float userX)
protected String width2device(int userX)
protected String x2device(int userX)
protected String height2device(float userY)
protected String height2device(int userY)
protected String y2device(int userY)
protected double tp2device(Tp tp)
protected double when2device(Event e)
public static String color2string(Color_rgb_8 user)
protected void printColor(Color_rgb_8 user)
public static String alpha2string(int user)
protected void printAlpha(int user)
protected <T> boolean check_init_def(Event firstEv, Vox v, Map<Event,T> map, String pname)
firstEv
- the event to checkv
- the voice, for error message onlymap
- the parameter values, by events.pname
- the name of the parameter, for error message only.protected String animateTransformString(String attname, double t1, double t2, String v1, String v2)
attname
- the name of the attribute to animatet1
- the starting time point of the changing processt2
- the final time point of the changing processv1
- the start value of the changing processv2
- the final value of the changing processprotected String animateString(String attname, double t1, double duration, String v1, String v2)
attname
- the name of the attribute to animatet1
- the starting time point of the changing processduration
- the duration of the changing processv1
- the start value of the changing processv2
- the final value of the changing processprotected String animateString_tp(String attname, double t1, double t2, String v1, String v2)
attname
- the name of the attribute to animatet1
- the starting time point of the changing processv1
- the start value of the changing processt2
- the final time point of the changing processv2
- the final value of the changing processprotected String setString(String attname, double t1, String v1)
attname
- the name of the attribute to animatet1
- the time point of the changev1
- the value to which to changeprotected abstract void convertData()
public void convertToSvg(PrintWriter pw, String title, int ulox, int uloy, int uhix, int uhiy, int phix, int phiy, MfOptions.physUnit punit, double timeFactor)
update()
.
Creates SVG file constant header and footer.
Copies parameters into local registers and then calls the (specific) convertData()
.