Class Print_Plan_3d

java.lang.Object
eu.bandm.music.top.Print_Plan_3d

public class Print_Plan_3d extends Object
Prints a list of segments in a three-dimensional (3d) block diagram style, mostly for visualizing temporal distribution of themes/counterpoints in a multi-voice work of music.

The graphics are organized as a vertical stack of horizontal lines, top down. Each segment of such a line can show either a 3d-block (for symbolizing main themes) or different kinds of 2d-lines (for counterpoints and subordinated material). The data must be collected in advance, in one instance of this class, which can be used either for 2d or for 3d printing, so that normally two instances cooperate to make one diagram. The data must be entered as lists of numeric x-positions, for 3d as pairs (from, to), for 2d as triples (from, to, kind). This is done by calling addSegment(int,int) or addSegment(int,int,int). The call to nextRow() starts a new row. Afterwards either show_Block_3d(Graphics2D,float,boolean) or show_Line_2d(Graphics2D,float,int) are called which execute the graphic rendering. For ease of layout, a top-most empty line is provided on construction.

  • Field Details

    • stack

      protected Stack<List<Print_Plan_3d.Triple>> stack
      The list of lists, each standing for a horizontal line in the graphics.
    • default_color_line

      public static final Color default_color_line
      The color of all 2d lines (representing counterpoints/subordinated material).
    • default_linewidth

      public static final int default_linewidth
      The default line width for the 2d lines.
      See Also:
    • default_color_front

      public static final Color default_color_front
      The color of the front of the 3d blocks
    • default_color_side

      public static final Color default_color_side
      The color of the visible right side (visible end) of the 3d blocks
    • default_color_down

      public static final Color default_color_down
      The color of the visible bottom of the 3d blocks
    • image_minus

      public static final BufferedImage image_minus
      Container into which we draw and which will paint the 0th line type.
    • image_slash

      public static final BufferedImage image_slash
      Container into which we draw and which will paint the 1st line type.
    • image_cross

      public static final BufferedImage image_cross
      Container into which we draw and which will paint the 2ndh line type.
    • image_wave

      public static final BufferedImage image_wave
      Container into which we draw and which will paint the 3rd line type.
    • image_hori

      public static final BufferedImage image_hori
      Container into which we draw and which will paint the 4th line type.
    • paint_minus

      public static TexturePaint paint_minus
      Paint object to draw the lines of type 0
    • paint_wave

      public static TexturePaint paint_wave
      Paint object to draw the lines of type 1
    • paint_cross

      public static TexturePaint paint_cross
      Paint object to draw the lines of type 2
    • paint_slash

      public static TexturePaint paint_slash
      Paint object to draw the lines of type 3
    • paint_hori

      public static TexturePaint paint_hori
      Paint object to draw the lines of type 4
    • default_patterns

      protected static final List<Paint> default_patterns
      List of the java awt default Paint objects for 2d lines, indexed by the "kind" data.
  • Constructor Details

    • Print_Plan_3d

      public Print_Plan_3d()
      Only constructor. Add one empty line to the stack of horizontal lines, and open the next.
  • Method Details

    • addSegment

      public void addSegment(int from, int to, int kind)
      Add a segment with x and y coordinate and a kind index (currently 1 to 5)

      ATTENTION: no further consistency checks are done with the coordinates.

    • addSegment

      public void addSegment(int from, int to)
      Add a segment with x and y coordinate, the kind index ==0. This means a 3d-block symbolizing main theme material.

      ATTENTION: no further consistency checks are done with the coordinates. The caller is responsible for non-overlapping and increasing order.

    • nextRow

      public void nextRow()
      Declare the growing row to be finished and a new (=next lower) row to start.
    • show_Block_3d

      public void show_Block_3d(Graphics2D graphics, float xfactor, boolean suppressLimitLine)
      Show all 3d-blocks defined in the accumulated data in stack. Sets the next three parameters to 20, 4, 10, the last parameters to their default values defined in the corresponding constants, and calls show_Block_3d(Graphics2D,float,boolean,int,int,int,Color,int,Color,Color,Color)
    • show_Block_3d

      public void show_Block_3d(Graphics2D graphics, float xfactor, boolean suppressLimitLine, int yheight, int perspective_x, int perspective_y)
      Show all 3d-blocks defined in the accumulated data in stack. Sets the last parameters to their default values defined in the corresponding constants, and calls show_Block_3d(Graphics2D,float,boolean,int,int,int,Color,int,Color,Color,Color)
    • show_Block_3d

      public void show_Block_3d(Graphics2D graphics, float xfactor, boolean suppressLimitLine, int yheight, int perspective_x, int perspective_y, Color color_line, int linewidth, Color color_front, Color color_side, Color color_down)
      Show all 3d-blocks defined in the accumulated data in stack. The blocks have the form
          +------------+            
          |            |\
          +------------+ |           
           \------------\|
        
      The are drawn completely, without any clipping. The seqenctial order is relevant: first the lines top down, in each line from left to right: So each later block will overprint the earliers, if necessary:
                  +------------+            
                  |            |\
                  +---+-----------------+
                  \---|                 |\
                      +-----------------+ |
                       \-----------------\|
        
      This sequnential order must be adhered to by the user when defining the data by addSegment(int,int) and is currently not tested.
      Parameters:
      graphics - the target of all draw commands
      xfactor - scaling from input data to Graphic's coordinates.
      suppressLimitLine - no line between two parallel, adjacent segments
      yheight - scaling from segment list (=line) number in input data to graphic's coordinates.
      perspective_x - width of perspective side wall, in Graphic's coordinates.
      perspective_y - height of perspective bottom wall, in Graphic's coordinates.
      color_line - color of all separation lines
      linewidth - width of all separation lines, the Graphics pixel coordinates.
      color_front - of the front of the 3d blocks
      color_side - of the visible right side (visible end) of the 3d blocks
      color_down - of the visible bottom of the 3d blocks
    • show_Line_2d

      public void show_Line_2d(Graphics2D graphics, float xfactor, int yheight)
      Show all 2d-blocks defined in the accumulated data in stack. Set yoffset to 1/2 yheight and use the list of default_patterns to call show_Line_2d(Graphics2D,float,int,int,List)
    • show_Line_2d

      public void show_Line_2d(Graphics2D graphics, float xfactor, int yheight, int yoffset, List<Paint> patterns)
      Show all 2d-lines defined in the accumulated data in stack. Currently there are five line types adressable by index/kind 0 to 4.
      Parameters:
      graphics - the target of all draw commands
      xfactor - scaling from input data to Graphic's coordinates.
      yheight - scaling from segment list (=line) number in input data to y coordinates
      yoffset - shift of the lines from the box bottom lines
      patterns - list of Paint objects to draw the lines.
    • get_default_patterns

      public static List<Paint> get_default_patterns()
      Return the list of java awt default Paint objects for 2d lines,
    • main

      public static void main(String[] args)
      TEST, DISLOC to "example" or to "interactiveTests" FIXME