Class SvgSource

java.lang.Object
eu.bandm.music.top.SvgSource
Direct Known Subclasses:
GraphartScharen, MaWiCM, MaWiRic, MovingForms

public abstract class SvgSource extends Object
Common base class for several tscore instantiations creating SVG output. 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/

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    protected class 
    Visits all events of a given iterator pairwise and writes out the Svg/Smil commands.
    (package private) class 
    Visits all events of a given iterator pairwise and prepares time and interpolation values.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    (package private) final SortedMap<Duration_calendaric,TpTop>
    Inverse of the Map tp2caldur.
    protected final Modifiers
    The modifiers for the parameter parsing process, including that of the time points.
    protected Tp
    The very first time point, as specified in the input score data.
    protected int
    The rightmost user coordinate.
    protected int
    The numerically highest vertical user coordinate.
    protected Tp
    The very last time point, as specified in the input score data.
    protected int
    The leftmost user coordinate.
    protected int
    The numerically lowest vertical user coordinate.
    protected MessageReceiver<SimpleMessage<eu.bandm.tools.util.xml.XMLDocumentIdentifier>>
    Target of all local messages, maybe including a counter, etc.
    protected final MessageReceiver<SimpleMessage<eu.bandm.tools.util.xml.XMLDocumentIdentifier>>
    External message receiver, to which all messages are finally sent.
    protected final Part
    The tscore data to be processed.
    protected int
    The numeric highest value of svg x coordinates.
    protected int
    The numeric highest value of svg y coordinates.
    protected String
    The string naming the unit of svg distance encoding.
    protected PrintWriter
    The drain of all print commands which generate the source text.
    protected final Multimap<Rational,Tp>
    Inverse of the Map tp2rat.
    protected double
    A possible additional stretch factor for the time coordinates, supplied explicitly by the user.
    (package private) final Map<TpTop,Duration_calendaric>
    Maps the score top-level time points to calendaric ("physical") duration values.
    (package private) final Map<Tp,Rational>
    Maps all time points to rational values.
    protected double
    The stretch factor for the translation of the horizontal coordinates.
    protected double
    The stretch factor for the translation of the vertical coordinates.
  • Constructor Summary

    Constructors
    Constructor
    Description
    SvgSource(Part part, MessageReceiver<SimpleMessage<eu.bandm.tools.util.xml.XMLDocumentIdentifier>> msgr)
    Only constructor, sets the tscore score data and the drain of all messages.
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    alpha2string(int user)
    Returns in a target text string the encoding of the given opacity.
    protected String
    animateString(String attname, double t1, double duration, String v1, String v2)
    Generate a target text string which executes an animation.
    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
    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
    Returns in a target text string the encoding of the given color.
    protected abstract void
    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
    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
    Returns in a target text string a given tscore time point encoded in svg/smil time point values.
    void
    First main entry point, called by the subclasses which realize the specializations, and executes parsing of time points, and further sort operations.
    protected double
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • msg

      protected MessageReceiver<SimpleMessage<eu.bandm.tools.util.xml.XMLDocumentIdentifier>> msg
      Target of all local messages, maybe including a counter, etc.
    • msgr

      protected final MessageReceiver<SimpleMessage<eu.bandm.tools.util.xml.XMLDocumentIdentifier>> msgr
      External message receiver, to which all messages are finally sent.
    • part

      protected final Part part
      The tscore data to be processed.
    • defaultModifiers

      protected final Modifiers defaultModifiers
      The modifiers for the parameter parsing process, including that of the time points.
    • tp2caldur

      final Map<TpTop,Duration_calendaric> tp2caldur
      Maps the score top-level time points to calendaric ("physical") duration values. Currently only full seconds as text value in tp top FIXME support »1'04.322«
    • caldur2tp

      Inverse of the Map tp2caldur.
    • tp2rat

      final Map<Tp,Rational> tp2rat
      Maps all time points to rational values. FIXME WARUM ???
    • rat2tp

      protected final Multimap<Rational,Tp> rat2tp
      Inverse of the Map tp2rat.
    • firstTp

      protected Tp firstTp
      The very first time point, as specified in the input score data.
    • lastTp

      protected Tp lastTp
      The very last time point, as specified in the input score data.
    • pw

      protected PrintWriter pw
      The drain of all print commands which generate the source text.
    • lowX

      protected int lowX
      The leftmost user coordinate. Is translated into svg x coordinate 0
    • lowY

      protected int lowY
      The numerically lowest vertical user coordinate. Is translated into svg y coordinate 0. In the initial (=untransformed) coordinate system of Svg, the y coordinate expands downward, like "line numbers" in a Western text. See https://www.w3.org/TR/SVG11/coords.html#InitialCoordinateSystem This direction is taken over for the user coordinates. So the translation from user (=tscore socure text) coordinates to svg (=generated target text) coordinates works like...
         tscore coord   -->  svg coords
          x  20  70         0   800
          y  20  70         0   800
        
    • hiX

      protected int hiX
      The rightmost user coordinate. Is translated into svg x coordinate physHiX.
    • hiY

      protected int hiY
      The numerically highest vertical user coordinate. Is translated into y coordinate physHiY, see the comment for lowY.
    • punit

      protected String punit
      The string naming the unit of svg distance encoding. (Can be "mm" or "pt", etc.)
    • physHiX

      protected int physHiX
      The numeric highest value of svg x coordinates.
    • physHiY

      protected int physHiY
      The numeric highest value of svg y coordinates.
    • xFact

      protected double xFact
      The stretch factor for the translation of the horizontal coordinates.
    • yFact

      protected double yFact
      The stretch factor for the translation of the vertical coordinates.
    • timeFactor

      protected double timeFactor
      A possible additional stretch factor for the time coordinates, supplied explicitly by the user. Defaults to 1.0.
  • Constructor Details

    • SvgSource

      public SvgSource(Part part, MessageReceiver<SimpleMessage<eu.bandm.tools.util.xml.XMLDocumentIdentifier>> msgr)
      Only constructor, sets the tscore score data and the drain of all messages.
  • Method Details

    • update

      public void update()
      First main entry point, called by the subclasses which realize the specializations, and executes parsing of time points, and further sort operations. Fills global registers tp2caldur, tp2rat, rat2tp, firstTp, etc.
    • width2device

      protected String width2device(float userX)
      Returns in a target text string a given difference in user x-coordinates (x-width) encoded in svg coordinates.
    • width2device

      protected String width2device(int userX)
      Returns in a target text string a given difference in user x-coordinates (x-width) encoded in svg coordinates.
    • x2device

      protected String x2device(int userX)
      Returns in a target text string a given position in user x-coordinates (x-pos) encoded in svg coordinates.
    • height2device

      protected String height2device(float userY)
      Returns in a target text string a given difference in user y-coordinates (y-height) encoded in svg coordinates.
    • height2device

      protected String height2device(int userY)
      Returns in a target text string a given difference in user y-coordinates (y-height) encoded in svg coordinates.
    • y2device

      protected String y2device(int userY)
      Returns in a target text string a given position in user y-coordinates (y-pos) encoded in svg coordinates.
    • tp2device

      protected double tp2device(Tp tp)
      Returns in a target text string a given tscore time point encoded in svg/smil time point values.
    • when2device

      protected double when2device(Event e)
      Returns in a target text string the onset of the given event encoded in svg/smil time point values.
    • color2string

      public static String color2string(Color_rgb_8 user)
      Returns in a target text string the encoding of the given color. cf http://www.w3.org/TR/SVG11/types.html#DataTypeColor but see also css 2.0 definition at http://www.w3.org/TR/2008/REC-CSS2-20080411/syndata.html#value-def-color DISLOC to Color_rgb_16.getSvgString() !?!? FIXME
    • printColor

      protected void printColor(Color_rgb_8 user)
      Print the given color to the generated output text as value of a "fill=" XML attribute.
    • alpha2string

      public static String alpha2string(int user)
      Returns in a target text string the encoding of the given opacity. Cf http://www.w3.org/TR/SVG11/masking.html#OpacityProperty
    • printAlpha

      protected void printAlpha(int user)
      Print the given vakue to the generated output text as an "opacity=" XML attribute.
    • check_init_def

      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.
      Parameters:
      firstEv - the event to check
      v - the voice, for error message only
      map - the parameter values, by events.
      pname - the name of the parameter, for error message only.
    • animateTransformString

      protected String animateTransformString(String attname, double t1, double t2, String v1, String v2)
      Generate a target text string which executes an animation. In Svg/Smil there are two different classes of animations "animate" and "animateTransform".
      Parameters:
      attname - the name of the attribute to animate
      t1 - the starting time point of the changing process
      t2 - the final time point of the changing process
      v1 - the start value of the changing process
      v2 - the final value of the changing process
    • animateString

      protected String animateString(String attname, double t1, double duration, String v1, String v2)
      Generate a target text string which executes an animation. In Svg/Smil there are two different classes of animations "animate" and "animateTransform".
      Parameters:
      attname - the name of the attribute to animate
      t1 - the starting time point of the changing process
      duration - the duration of the changing process
      v1 - the start value of the changing process
      v2 - the final value of the changing process
    • animateString_tp

      protected String animateString_tp(String attname, double t1, double t2, String v1, String v2)
      Generate a target text string which executes an animation. In Svg/Smil there are two different classes of animations "animate" and "animateTransform".
      Parameters:
      attname - the name of the attribute to animate
      t1 - the starting time point of the changing process
      v1 - the start value of the changing process
      t2 - the final time point of the changing process
      v2 - the final value of the changing process
    • setString

      protected String setString(String attname, double t1, String v1)
      Generate a target text string which sets the value of an attribute.
      Parameters:
      attname - the name of the attribute to animate
      t1 - the time point of the change
      v1 - the value to which to change
    • convertData

      protected abstract void convertData()
      Must be overridden by the sub-class which realizes the specific conversion. This may use all parameters in local registers and the auxiliary write-out methods.
    • convertToSvg

      public 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(). Creates SVG file constant header and footer. Copies parameters into local registers and then calls the (specific) convertData().