mkstyles.sh 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #! /bin/ksh
  2. #
  3. # usage: mkstyles.sh <style>
  4. #
  5. # where style has the form [nce]_<styleattr>.fmt
  6. # where .fmt gives the desired output format.
  7. if (( $# == 0 ))
  8. then
  9. echo "mkstyles: missing style name argument"
  10. exit 1
  11. fi
  12. TGT=$1 # x_style.fmt
  13. STYLE=${1%.*} # x_style
  14. FMT=${1#$STYLE.} # fmt
  15. F=$STYLE.gv # x_style.gv
  16. OBJ=${STYLE%_*} # x
  17. STYLE=${STYLE#${OBJ}_} # style
  18. exec 3> $F
  19. echo "digraph G { rankdir=LR" >&3
  20. case "$OBJ" in
  21. c )
  22. echo " fillcolor=greenyellow" >&3
  23. echo " node[style=filled label=\"\"]" >&3
  24. if [[ $STYLE == striped ]]
  25. then
  26. echo " fillcolor=\"greenyellow:yellow:lightblue\"" >&3
  27. fi
  28. echo " subgraph cluster { style=$STYLE 0}" >&3
  29. ;;
  30. e )
  31. echo " node[ style=filled label=\"\"]" >&3
  32. echo " a -> b [ style=$STYLE ]" >&3
  33. ;;
  34. n )
  35. case "$STYLE" in
  36. rounded | diagonals )
  37. echo " node[ shape=box]" >&3
  38. ;;
  39. striped )
  40. echo " node[ shape=box fillcolor=\"greenyellow:yellow:lightblue\"]" >&3
  41. ;;
  42. wedged )
  43. echo " node[ fillcolor=\"greenyellow:yellow:lightblue\"]" >&3
  44. ;;
  45. esac
  46. echo " 0 [style=$STYLE label=\"\"]" >&3
  47. ;;
  48. esac
  49. echo "}" >&3
  50. exec 3>&-
  51. dot -T$FMT $F > $TGT
  52. rm -f $F