def plot_text(file, alignment, x0, y0, text, font, color, depth): # Alignments can be different if alignment == "Left": file.write("4 0 %3d %3d -1 " % (code_color(color), depth)) elif alignment == "Center": file.write("4 1 %3d %3d -1 " % (code_color(color), depth)) elif alignment == "Right": file.write("4 2 %3d %3d -1 " % (code_color(color), depth)) file.write("%5d" % code_font(font)) # font code file.write("%3d" % (Const.FONT_SIZE * 36)) # font size file.write(" 0.0000 4 ") text_width = 3 # could be any value text_height = 3 # could be any value file.write("%9d" % (text_height * Const.XFIG_SCALE)) # text height xfig units file.write("%9d" % (text_width * Const.XFIG_SCALE)) # text width xfig units file.write("%9d %9d" % ((x0) * Const.XFIG_SCALE, (y0) * Const.XFIG_SCALE)) if alignment == "Center": file.write("%s\\001\n" % text) else: file.write("%s%s\\001\n" % (" ", text))
def plot_type_frame(file, box_width, object): if object.Type() == "Module": color = Const.COLOR_HEADER_MODULE if object.Type() == "Subroutine": color = Const.COLOR_HEADER_SUBROUTINE if object.Type() == "Function": color = Const.COLOR_HEADER_FUNCTION if object.Type() == "Program": color = Const.COLOR_HEADER_PROGRAM x0 = object.x0 * Const.XFIG_SCALE x1 = (object.x0 + box_width) * Const.XFIG_SCALE y0 = (object.y0 + ( 1 ) * Const.UNIT_BOX_HEIGHT ) * Const.XFIG_SCALE y1 = y0 + object.N_Types() * Const.UNIT_BOX_HEIGHT * Const.XFIG_SCALE file.write("2 2 0 ") file.write("%3d " % Const.THICKNESS) file.write("0") file.write("%3d " % code_color(color)) file.write("11 -1 30 0.000 0 0 -1 0 0 5\n") # 30*5 = 150% intensity file.write("%9d %9d" % ( x0, y0) ) file.write("%9d %9d" % ( x1, y0) ) file.write("%9d %9d" % ( x1, y1) ) file.write("%9d %9d" % ( x0, y1) ) file.write("%9d %9d\n"% ( x0, y0) )
def plot_line(file, x0, y0, x1, y1, color, depth): file.write("2 1 0 1 %3d 7 %3d -1 -1 0.000 0 0 -1 0 0 2" \ % (code_color(color), depth)) file.write("\n%9d %9d" % ( (x0) * Const.XFIG_SCALE, \ (y0) * Const.XFIG_SCALE)) file.write("%9d %9d" % ( (x1) * Const.XFIG_SCALE, \ (y1) * Const.XFIG_SCALE)) file.write("\n")
def plot_title_frame(file, object, box_width, box_height): file.write("2 2 0 ") file.write("%3d " % Const.THICKNESS) file.write("0") if object.Type() == "Subroutine": file.write("%3d " % code_color(Const.COLOR_HEADER_SUBROUTINE)) elif object.Type() == "Program": file.write("%3d " % code_color(Const.COLOR_HEADER_PROGRAM)) elif object.Type() == "Module": file.write("%3d " % code_color(Const.COLOR_HEADER_MODULE)) elif object.Type() == "Function": file.write("%3d " % code_color(Const.COLOR_HEADER_FUNCTION)) file.write("15 -1 20 0.000 0 0 -1 0 0 5\n") file.write("%9d %9d" % ( object.x0 *Const.XFIG_SCALE, \ object.y0 *Const.XFIG_SCALE)) file.write("%9d %9d" % ((object.x0+box_width) *Const.XFIG_SCALE, \ object.y0 *Const.XFIG_SCALE)) file.write("%9d %9d" % ((object.x0+box_width) *Const.XFIG_SCALE, \ (object.y0+box_height)*Const.XFIG_SCALE)) file.write("%9d %9d" % ( object.x0 *Const.XFIG_SCALE, \ (object.y0+box_height)*Const.XFIG_SCALE)) file.write("%9d %9d\n"% ( object.x0 *Const.XFIG_SCALE, \ object.y0 *Const.XFIG_SCALE))
def plot_use_frame(file, box_width, object): x0 = object.x0 * Const.XFIG_SCALE x1 = (object.x0 + box_width) * Const.XFIG_SCALE y0 = (object.y0 + ( 1 \ + object.N_Types()) * Const.UNIT_BOX_HEIGHT ) * Const.XFIG_SCALE y1 = y0 + object.N_Uses() * Const.UNIT_BOX_HEIGHT * Const.XFIG_SCALE file.write("2 2 0 ") file.write("%3d " % Const.THICKNESS) file.write("0") file.write("%3d " % code_color(Const.COLOR_BOX)) file.write("12 -1 20 0.000 0 0 -1 0 0 5\n") file.write("%9d %9d" % (x0, y0)) file.write("%9d %9d" % (x1, y0)) file.write("%9d %9d" % (x1, y1)) file.write("%9d %9d" % (x0, y1)) file.write("%9d %9d\n" % (x0, y0))