/* Ultimate Scalebar /* Written by Chris Eykamp, 1997 /* Updated July, 2000 -- added .scalebar$mapscale parameter /* Full documentation and most recent code available at http://www.eykamp.com/scalebar /* Report bugs or contact author at chris@eykamp.com /* Although utmost care has been taken to ensure the correctness of the /* software, the software is provided "as is" without any warranty of any /* kind. In no event shall the author be liable for any damages, including but /* not limited to special, consequential, or other damages. The author /* specifically disclaims all other warranties, expressed or implied, /* including but not limited to the determination of suitability of this /* product for a specific purpose, use, or application. /************************************* /* Directs execution of this aml to the proper sub-routine... &args args:rest &s args [unquote %args%] &s oldabbrev [show &abbrev] &abbrev &off &goto init &return /************************************* &routine init &label init &s xpos [extract 1 %args%] &s ypos [extract 2 %args%] &s width [extract 3 %args%] &s height [extract 4 %args%] &if [show program] ne 'ARCPLOT' &then &do &ty Sorry, but the Ultimate Scalebar can only be run from Arcplot. &ty &return &end /* TO DO: Add more sophisticated command line checking... &if [null %height%] &then &do &ty Usage: scalebar {getsize} &ty &ty The following variables can be used to control the Ultimate Scalebar's behavior: &ty &ty .scalebar$justification: Set the scalebar justification &ty .scalebar$textsize: Set the textsize for the scale units and numbers &ty .scalebar$font: Font used to label the scalebar &ty .scalebar$intervals: Number of intervals to be drawn on scalebar &ty .scalebar$validintervals: Allowed values for largest number on scalebar &ty .scalebar$units: Units in which scalebar will be drawn &ty .scalebar$barstyle: Bar style for scalebar &ty .scalebar$numstyle: Style for scalebar unit label &ty .scalebar$unitstyle: Style for scalebar unit label &ty .scalebar$scalestyle: Style for "Scale:" text &ty .scalebar$scaleradix: Radix for scale text &ty .scalebar$scaleround: Rounding factor for scale text &ty .scalebar$mapscale: Override current mapscale &ty &ty For more information about command line parameters and a description &ty of how these variables are used, please refer to the Ultimate Scalebar &ty documentation at http://eykamp.com/scalebar . &ty &return &end /* Set font for scalebar text &if not [variable .scalebar$font] &then &s font 93726 &else &s font %.scalebar$font% &if not [variable .scalebar$noconvert] &then &s noconvert .FALSE. &else &s noconvert %.scalebar$noconvert% &if [quote %noconvert%] ne '.TRUE.' and [quote %noconvert%] ne '.FALSE.' &then &do &ty Variable .scalebar$noconvert improperly specified. Reverting to default of .FALSE. &ty &ty For more information about enabling or disabling "unit sliding", &ty please refer to the Ultimate Scalebar documentation at http://eykamp.com/scalebar . &ty &s noconvert .FALSE. &end &if not [variable .scalebar$mapscale] &then &s mymapscale [show mapscale] &else &s mymapscale %.scalebar$mapscale% &if not [variable .scalebar$intervals] &then &s intervals 5 &else &s intervals %.scalebar$intervals% &if [type %intervals%] ne -1 &then &do &ty %intervals% intervals is not valid. Integer values only. &ty Reverting to default value 5. &ty &ty For more information about how to specify the number of intervals, &ty please refer to the Ultimate Scalebar documentation at http://eykamp.com/scalebar . &ty &s intervals 5 &end &if %intervals% < 1 &then &do &ty The number of intervals must be greater than 0. Reverting to default value 5. &ty &ty For more information about how to set the number of intervals, &ty please refer to the Ultimate Scalebar documentation at http://eykamp.com/scalebar . &ty &s intervals 5 &end &if not [variable .scalebar$validintervals] &then &s validintervals 1 2.5 5 7.5 &else &s validintervals %.scalebar$validintervals% &if not [variable .scalebar$scaleround] &then &s round 1 &else &s round %.scalebar$scaleround% &if not [variable .scalebar$scaleradix] &then &s radix &else &s radix %.scalebar$scaleradix% &if not [variable .scalebar$textsize] &then &s textheight %height% &else &s textheight %.scalebar$textsize% &if not [variable .scalebar$justification] &then &s just l &else &s just [substr [quote [locase %.scalebar$justification%]] 1 1] &if 'lrc' nc %just% &then &do &ty Justification %just% is invalid. Reverting to default value left. &ty &ty For more information about specifying the justification, &ty please refer to the Ultimate Scalebar documentation at http://eykamp.com/scalebar . &ty &s just l &end &if not [variable .scalebar$barstyle] &then &s barstyle 1 &else &s barstyle %.scalebar$barstyle% &if not [variable .scalebar$numstyle] &then &s numstyle 1 &else &s numstyle %.scalebar$numstyle% &if not [variable .scalebar$unitstyle] &then &s unitstyle 1 &else &s unitstyle %.scalebar$unitstyle% &if not [variable .scalebar$scalestyle] &then &s scalestyle 0 &else &s scalestyle %.scalebar$scalestyle% &s barstyles 10 &s item bar &s minstyle 1 &call checkstyle &s numstyles 4 &s item num &call checkstyle &s unitstyles 6 &s item unit &call checkstyle &s scalestyles 2 &s item scale &s minstyle 0 &call checkstyle &if [quote [show mapunits]] = 'CM' or [quote [show mapunits]] = 'METERS' &then &s defunits km &else &s defunits mi &if not [variable .scalebar$units] &then &do &s units %defunits% &end &else &s units %.scalebar$units% &if 'm km ft mi M' nc [quote %units%] &then &do &ty %.scalebar$units% is an invalid unit. Please specify one of: m, km, mi, ft, or M. &ty Reverting to default value of %defunits%. &ty &ty For more information about specifying units, please refer to the Ultimate Scalebar &ty documentation at http://eykamp.com/scalebar . &ty &s units %defunits% &end /* Barstyle 1: XXXXX XXXXX XXXXX XXXXX XXXXX /* XXXXX XXXXX XXXXX XXXXX /* Barstyle 2: XXXXX XXXXX XXXXXXXXXXXXXXXXXXXX /* XXXXX XXXXX /* Barstyle 3: XXXXX XXXXX XXXXX XXXXX XXXXX /* XXXXX XXXXX XXXXX XXXXX XXXXX /* Barstyle 4: XXXXX XXXXX XXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXX /* XXXXX XXXXX XXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXX /* Barstyle 5: |-----|-----|-----|-----|-----|-----|-----| /* Barstyle 6: |--+--|--+--|--+--|--+--|--+--|--+--|--+--| /* Barstyle 7: |_____|_____|_____|_____|_____|_____|_____| /* Barstyle 8: |__,__|__,__|__,__|__,__|__,__|__,__|__,__| /* _________________________________________ /* Barstyle 9: | | | | | | | | /* _________________________________________ /* Barstyle 10: | ' | ' | ' | ' | ' | ' | ' | /* Numstyle 1: All numbers above the bar /* Numstyle 2: All numbers below the bar /* Numstyle 3: Numbers alternating, starting above the bar /* Numstyle 4: Numbers alternating, starting below the bar /* Unitstyle 1: Units placed after final number on the scale, abbreviated /* Unitstyle 2: Units placed after final number on the scale, spelled out /* Unitstyle 3: Units placed below scalebar, abbreviated /* Unitstyle 4: Units placed below scalebar, spelled out /* Unitstyle 5: Units placed above scalebar, abbreviated /* Unitstyle 6: Units placed above scalebar, spelled out /* Scalestyle 0: No text scale (default) /* Scalestyle 1: Text scale placed above the scalebar /* Scalestyle 2: Text scale placed below the scalebar /* 1 pageunit equals %maplength% %units% on the map &select [show pageunits] &when INCHES &do &select %units% &when m &s maplength .0254 &when km &s maplength .0000254 &when M &s maplength 1 / 72913.39 &when mi &s maplength 1 / 63360 &when ft &s maplength 1 / 12 &end &end &when CM &do &select %units% &when m &s maplength .01 &when km &s maplength .00001 &when M &s maplength 1 / 185200 &when mi &s maplength 1 / 160934.4 &when ft &s maplength 1 / 30.48 &end &end &otherwise &do &select %units% &when m &s maplength .0254 / [show pageunits] &when km &s maplength .0000254 / [show pageunits] &when M &s maplength 1 / ( 72913.39 * [show pageunits] ) &when mi &s maplength 1 / ( 63360 * [show pageunits] ) &when ft &s maplength 1 / ( 12 * [show pageunits] ) &end &end &end &if %mymapscale% <= 0 &then &do /* Yes, this does happen occasionally... &ty Sorry, I do not understand your mapscale. ArcPlot reports it as %mymapscale%. &ty Please set a more conventional mapscale and try again. &ty &ty Aborting... &return &end &s maplength %maplength% * %mymapscale% &if [locase [quote [extract 5 %args%]]] = 'getsize' &then &do &call calcbarwidth &call calctruesize &call calccenter &abbrev %oldabbrev% &return &end &call draw &abbrev %oldabbrev% &return /************************************* /* Run a quick check on the specified style parameter &routine checkstyle &label checkstyle &s bad .FALSE. &if not [okdistance [value %item%style]] &then &s bad .TRUE. &else &if [value %item%style] < %minstyle% or [value %item%style] > [value %item%styles] &then &s bad .TRUE. &if %bad% &then &do &ty [value .scalebar$%item%style] is an invalid %item% style. &ty Please specify a number between %minstyle% and [value %item%styles]. &ty Reverting to default value %minstyle%. &ty &ty For more information about %item% styles, please refer to the Ultimate Scalebar &ty documentation at http://eykamp.com/scalebar . &ty &s %item%style %minstyle% &end &return /************************************* /* Set up the proper spelled out version of the units &routine longunits &label longunits &if %units% = 'm' &then &do &if %maxnumber% = 1 and %unitstyle% = 2 &then &s longunits meter &else &s longunits meters &end &else &if %units% = 'km' &then &do &if %maxnumber% = 1 and %unitstyle% = 2 &then &s longunits kilometer &else &s longunits kilometers &end &else &if %units% = 'ft' &then &do &if %maxnumber% = 1 and %unitstyle% = 2 &then &s longunits foot &else &s longunits feet &end &else &if %units% = 'mi' &then &do &if %maxnumber% = 1 and %unitstyle% = 2 &then &s longunits mile &else &s longunits miles &end &else &if %units% = 'M' &then &do &if %maxnumber% = 1 and %unitstyle% = 2 &then &s longunits nautical mile &else &s longunits nautical miles &end &return /************************************* /* Calculate the true width of the scalebar &routine calcbarwidth &label calcbarwidth &s done .FALSE. /*/* TEST /*&s multiplier %width% * %maplength% /*&tty /* END TEST &s multiplier .00000001 &do &while not %done% &s multiplier %multiplier% * 10 &do interval &list %validintervals% &if [calc %multiplier% * %interval% / %maplength%] > %width% &then &s done .TRUE. &else &s maxnumber %multiplier% * %interval% &end &end /*&tty &s barwidth %maxnumber% / %maplength% &return /************************************* /* Calculate the true width and height of the scalebar complex, including the numbers and units and scale text &routine calctruesize &label calctruesize &s oldtextscale [show textscale] &s oldtextset [show textset] &s oldtextsize [show textsize] &s oldtextquality [show textquality] &s oldfont [show textfont] &s oldtextoffset [show textoffset] textscale 1 textfont %font% textquality proportional textsize %textheight% textoffset 0,0 /* First height -- this is easy: Just the size of the numbers + the height of the bar specified + units + scale &if %numstyle% in { 1 2 } &then &s hfact 1 &else &s hfact 2 /* This unit style will increase the height of the scalebar &if %unitstyle% in { 3 4 5 6 } &then &s hfact %hfact% + 1 /* Also, a text scale will make things bigger &if %scalestyle% = 1 &then &s hfact %hfact% + 1.2 &else &if %scalestyle% = 2 &then &s hfact %hfact% + 1.2 &s actualheight %textheight% * %hfact% + %height% &s zerowidth [extract 1 [show textextent '0']] /* Used here as well as later /* Next width -- a little more tricky &call slideunits &s actualwidth %barwidth% &s actualwidth %actualwidth% + .5 * ( %zerowidth% + [extract 1 [show textextent [quote %maxnumber%]]] ) &call longunits &if %unitstyle% = 1 &then &s actualwidth %actualwidth% + [extract 1 [show textextent [quote %units%]]] &else &if %unitstyle% = 2 &then &s actualwidth %actualwidth% + [extract 1 [show textextent [quote [unquote ' ']%longunits%]]] &call createscaletext &s scalewidth [extract 1 [show textextent [quote %scaletext%]]] /* Check for a very unususal case... &if %barwidth% < %scalewidth% &then &s actualwidth %actualwidth% - .5 * %barwidth% + .5 * %scalewidth% textscale %oldtextscale% textset %oldtextset% textsize %oldtextsize% textquality %oldtextquality% textfont %oldfont% textoffset %oldtextoffset% /* Set up global variables here &s .scalebar$actualbarwidth %barwidth% &s .scalebar$actualsize %actualwidth% %actualheight% &return /************************************* /* Calculate the center point of the entire scalebar complex &routine calccenter &label calccenter /* First find the upper left corner... &s ulx %xpos% - .5 * %zerowidth% &s uly %ypos% &if %numstyle% in { 1 3 4 } &then &s uly %uly% + %textheight% &if %unitstyle% in { 5 6 } &then &s uly %uly% + %textheight% &if %scalestyle% = 1 &then &s uly %uly% + 1.2 * %textheight% /* Check for a very unususal case... &if %barwidth% < %scalewidth% &then &s ulx %ulx% + .5 * %barwidth% - ( .5 * %scalewidth% ) &s cenx %ulx% + .5 * %actualwidth% &s ceny %uly% - .5 * %actualheight% &s .scalebar$actualposition %cenx% %ceny% &return /************************************* /* Draw basic scalebar &routine draw &label draw &if not [null [show map]] &then mbegin /* If map composition... /* First, find out how wide the actual scale bar will be when we draw it &call calcbarwidth /* Adjust coordinates so that justification will be correct... &if %just% = 'c' &then &s xpos %xpos% - .5 * %barwidth% &else &if %just% = 'r' &then &s xpos %xpos% - %barwidth% /* Now we can draw everything left-justified &s oldunits [show units] &s oldtextscale [show textscale] &s oldtextset [show textset] &s oldtextsize [show textsize] &s oldtextquality [show textquality] &s oldfont [show textfont] &s oldshadesymbol [show shadesymbol] &s oldtextoffset [show textoffset] &s oldtextcolor [show textcolor] &s oldshadeset [show shadeset] &s oldlinecolor [show linecolor current 1] &s oldlinesize [show linesize current 1] &s oldlinesymbol [show linesymbol current] &s oldlineset [show lineset] units page textscale 1 textcolor black shadeset color shadesymbol 2 lineset color linesymbol 1 &if %barstyle% in { 1 2 3 4 } &then &do shadecolor cmyk 0 0 0 0 patch %xpos% %ypos% [calc %xpos% + %barwidth%] [calc %ypos% - %height%] &end shadecolor cmyk -1 -1 -1 100 /* Draw the basic scale bar first. Numbers and units will be added later &call drawbarstyle%barstyle% /* Do any unit sliding that may be necessary &call slideunits /* Set up text all nice 'n' pretty textfont %font% textquality proportional textsize [calc %textheight%] textoffset 0,0 /* Add numbers to the scalebar &call drawnumstyle%numstyle% /* Add units to the scalebar &call drawunitstyle%unitstyle% /* Finally, add scale text, if there is any &if %scalestyle% > 0 &then &call drawscalestyle%scalestyle% /* Restore the state of text settings units %oldunits% textset %oldtextset% textscale %oldtextscale% textsize %oldtextsize% textquality %oldtextquality% textfont %oldfont% textoffset %oldtextoffset% textcolor [unquote %oldtextcolor%] shadeset %oldshadeset% shadesymbol [unquote %oldshadesymbol%] linesymbol %oldlinesymbol% lineset %oldlineset% linecolor [unquote %oldlinecolor%] linesize %oldlinesize% &if not [null [show map]] &then mend 'Ultimate Scalebar' &return /************************************* /* Convert units between m and km if appropriate &routine slideunits &label slideunits &if not %noconvert% &then &do /* Kick down to meters from km if numbers get too small &if %units% = 'km' and %maxnumber% <= 1 &then &do &s units m &s maxnumber %maxnumber% * 1000 &end /* Kick up from meters to km if numbers get too big &if %units% = 'm' and %maxnumber% > 10000 &then &do &s units km &s maxnumber %maxnumber% / 1000 &end &end &return /************************************* /* Draw abbreviated units after final number &routine drawunitstyle1 &label drawunitstyle1 text [quote %units%] ll &return /************************************* /* Draw un-abbreviated units after final number &routine drawunitstyle2 &label drawunitstyle2 &call longunits text [quote [unquote ' ']%longunits%] ll &return /************************************* /* Draw abbreviated units under the scalebar &routine drawunitstyle3 &label drawunitstyle3 /* Move the units down to make room for the numbers if they are drawn below the scalebar... &if %numstyle% in { 2 3 4 } &then &s textfact %textheight% &else &s textfact 0 move [calc %xpos% + .5 * %barwidth% ] [calc %ypos% - %height% - %textfact%] text [quote %units%] uc &return /************************************* /* Draw un-abbreviated units under the scalebar &routine drawunitstyle4 &label drawunitstyle4 &call longunits /* Move the units down to make room for the numbers if they are drawn below the scalebar... &if %numstyle% in { 2 3 4 } &then &s textfact %textheight% &else &s textfact 0 move [calc %xpos% + .5 * %barwidth% ] [calc %ypos% - %height% - %textfact%] text [quote %longunits%] uc &return /************************************* /* Draw abbreviated units above the scalebar &routine drawunitstyle5 &label drawunitstyle5 /* Move the units up to make room for the numbers if they are drawn above the scalebar... &if %numstyle% in { 1 3 4 } &then &s textfact %textheight% &else &s textfact 0 move [calc %xpos% + .5 * %barwidth% ] [calc %ypos% + .25 * %textheight% + %textfact%] text [quote %units%] lc &return /************************************* /* Draw un-abbreviated units above the scalebar &routine drawunitstyle6 &label drawunitstyle6 &call longunits /* Move the units up to make room for the numbers if they are drawn above the scalebar... &if %numstyle% in { 1 3 4 } &then &s textfact %textheight% &else &s textfact 0 move [calc %xpos% + .5 * %barwidth% ] [calc %ypos% + .25 * %textheight% + %textfact%] text [quote %longunits%] lc &return /************************************* /* Draw scale above the scalebar &routine drawscalestyle1 &label drawscalestyle1 &call createscaletext /* Move the scale up to make room for the numbers and scale if they are drawn above the scalebar... &if %numstyle% in { 1 3 4 } &then &s textfact %textheight% &else &s textfact .25 * %textheight% &if %unitstyle% in { 5 6 } &then &s textfact %textfact% + %textheight% move [calc %xpos% + .5 * %barwidth% ] [calc %ypos% + %textfact% + .4 * %textheight%] text [quote %scaletext%] lc &return /************************************* /* Draw scale below the scalebar &routine drawscalestyle2 &label drawscalestyle2 &call createscaletext /* Move the scale up to make room for the numbers and scale if they are drawn below the scalebar... &if %numstyle% in { 2 3 4 } &then &s textfact %textheight% &else &s textfact 0 &if %unitstyle% in { 3 4 } &then &s textfact %textfact% + %textheight% move [calc %xpos% + .5 * %barwidth% ] [calc %ypos% - %height% - %textfact% - .2 * %textheight%] text [quote %scaletext%] uc &return /************************************* /* Create the full scale text, using radix and rounding specified &routine createscaletext &label createscaletext &s num %mymapscale% /* Round properly &if %num% <= .5 * %round% &then &s round 1 &if %round% > 0 &then &s num %round% * [round [calc %num% / %round%]] /* Insert radix /* First check if there is a decimal in the number... &s newnum &if [index %num% '.'] > 0 &then &do &s newnum [substr %num% [index %num% '.']] &s num [before %num% '.'] &end &do i = [length [quote %num%]] &to 1 &by -1 &s newnum [substr %num% %i% 1][unquote %newnum%] &if [mod [calc [length %num%] - %i% + 1] 3] = 0 and %i% > 1 &then &s newnum [quote [unquote %radix%][unquote %newnum%]] &end &s scaletext Scale 1:[unquote %newnum%] &return /************************************* /* Draw all numbers above the scalebar &routine drawnumstyle1 &label drawnumstyle1 move %xpos% [calc %ypos% + .25 * %textheight%] text '0' lc &do i = 1 &to [calc %intervals% - 1] &s x %xpos% + %i% * %patchwidth% move %x% [calc %ypos% + .25 * %textheight%] text [quote [calc %i% * %maxnumber% / ( %intervals% * %intervalfact% ) ]] lc &end &if %intervalfact% = 2 &then &do /* Add an extra number on the scale &s x %xpos% + %intervals% * %patchwidth% move %x% [calc %ypos% + .25 * %textheight%] text [quote [calc %maxnumber% / %intervalfact%]] lc &end move [calc %xpos% + %barwidth%] [calc %ypos% + .25 * %textheight%] text [quote %maxnumber%] lc &return /************************************* /* Draw all numbers below the scalebar &routine drawnumstyle2 &label drawnumstyle2 move %xpos% [calc %ypos% - %height%] text '0' uc &do i = 1 &to [calc %intervals% - 1] &s x %xpos% + %i% * %patchwidth% move %x% [calc %ypos% - %height%] text [quote [calc %i% * %maxnumber% / ( %intervals% * %intervalfact% ) ]] uc &end &if %intervalfact% = 2 &then &do /* Add an extra number on the scale &s x %xpos% + %intervals% * %patchwidth% move %x% [calc %ypos% - %height%] text [quote [calc %maxnumber% / %intervalfact%]] uc &end move [calc %xpos% + %barwidth%] [calc %ypos% - %height%] text [quote %maxnumber%] uc &return /************************************* /* Alternate numbers above and below, starting with one above &routine drawnumstyle3 &label drawnumstyle3 move %xpos% [calc %ypos% + .25 * %textheight%] text '0' lc &do i = 1 &to [calc %intervals% - 1] &s x %xpos% + %i% * %patchwidth% &if [mod %i% 2] = 0 &then &do move %x% [calc %ypos% + .25 * %textheight%] text [quote [calc %i% * %maxnumber% / ( %intervals% * %intervalfact% ) ]] lc &end &else &do move %x% [calc %ypos% - %height%] text [quote [calc %i% * %maxnumber% / ( %intervals% * %intervalfact% ) ]] uc &end &end &if %intervalfact% = 2 &then &do /* Add an extra number on the scale &s x %xpos% + %intervals% * %patchwidth% &if [mod %i% 2] = 1 &then &do move [calc %xpos% + %barwidth% * .5] [calc %ypos% - %height%] text [quote [calc %i% * %maxnumber% / ( %intervals% * %intervalfact% ) ]] uc move [calc %xpos% + %barwidth%] [calc %ypos% + .25 * %textheight%] text [quote %maxnumber%] lc &end &else &do move [calc %xpos% + %barwidth% * .5] [calc %ypos% + .25 * %textheight%] text [quote [calc %i% * %maxnumber% / ( %intervals% * %intervalfact% ) ]] lc move [calc %xpos% + %barwidth%] [calc %ypos% - %height%] text [quote %maxnumber%] uc &end &end &else &do &if [mod %i% 2] = 0 &then &do move [calc %xpos% + %barwidth%] [calc %ypos% + .25 * %textheight%] text [quote %maxnumber%] lc &end &else &do move [calc %xpos% + %barwidth%] [calc %ypos% - %height%] text [quote %maxnumber%] uc &end &end &return /************************************* /* Alternate numbers above and below, starting with one below &routine drawnumstyle4 &label drawnumstyle4 move %xpos% [calc %ypos% - %height%] text '0' uc &do i = 1 &to [calc %intervals% - 1] &s x %xpos% + %i% * %patchwidth% &if [mod %i% 2] = 1 &then &do move %x% [calc %ypos% + .25 * %textheight%] text [quote [calc %i% * %maxnumber% / ( %intervals% * %intervalfact% ) ]] lc &end &else &do move %x% [calc %ypos% - %height%] text [quote [calc %i% * %maxnumber% / ( %intervals% * %intervalfact% ) ]] uc &end &end &if %intervalfact% = 2 &then &do /* Add an extra number on the scale &s x %xpos% + %intervals% * %patchwidth% &if [mod %i% 2] = 0 &then &do move [calc %xpos% + %barwidth% * .5] [calc %ypos% - %height%] text [quote [calc %i% * %maxnumber% / ( %intervals% * %intervalfact% ) ]] uc move [calc %xpos% + %barwidth%] [calc %ypos% + .25 * %textheight%] text [quote %maxnumber%] lc &end &else &do move [calc %xpos% + %barwidth% * .5] [calc %ypos% + .25 * %textheight%] text [quote [calc %i% * %maxnumber% / ( %intervals% * %intervalfact% ) ]] lc move [calc %xpos% + %barwidth%] [calc %ypos% - %height%] text [quote %maxnumber%] uc &end &end &else &do &if [mod %i% 2] = 1 &then &do move [calc %xpos% + %barwidth%] [calc %ypos% + .25 * %textheight%] text [quote %maxnumber%] lc &end &else &do move [calc %xpos% + %barwidth%] [calc %ypos% - %height%] text [quote %maxnumber%] uc &end &end &return /************************************* &routine drawbarstyle1 &label drawbarstyle1 &s patchwidth %barwidth% / %intervals% &do i = 1 &to %intervals% &s x %xpos% + ( %i% - 1 ) * %patchwidth% &s y %ypos% + .5 * [mod %i% 2] * %height% - .5 * %height% patch %x% %y% [calc %x% + %patchwidth%] [calc %y% - .5 * %height%] &end box %xpos% %ypos% [calc %xpos% + %barwidth%] [calc %ypos% - %height%] &s intervalfact 1 &return /************************************* &routine drawbarstyle2 &label drawbarstyle2 &s patchwidth .5 * %barwidth% / %intervals% &do i = 1 &to %intervals% &s x %xpos% + ( %i% - 1 ) * %patchwidth% &s y %ypos% + .5 * [mod %i% 2] * %height% - .5 * %height% patch %x% %y% [calc %x% + %patchwidth%] [calc %y% - .5 * %height%] &end &s x %xpos% + ( %i% - 1 ) * %patchwidth% &s y %ypos% + .5 * [mod %i% 2] * %height% - .5 * %height% patch %x% %y% [calc %x% + .5 * %barwidth%] [calc %y% - .5 * %height%] box %xpos% %ypos% [calc %xpos% + %barwidth%] [calc %ypos% - %height%] &s intervalfact 2 &return /************************************* &routine drawbarstyle3 &label drawbarstyle3 &s patchwidth %barwidth% / %intervals% &do i = 1 &to %intervals% &by 2 &s x %xpos% + ( %i% - 1 ) * %patchwidth% patch %x% %ypos% [calc %x% + %patchwidth%] [calc %ypos% - %height%] &end box %xpos% %ypos% [calc %xpos% + %barwidth%] [calc %ypos% - %height%] &s intervalfact 1 &return /************************************* &routine drawbarstyle4 &label drawbarstyle4 &s patchwidth .5 * %barwidth% / %intervals% &do i = 1 &to %intervals% &by 2 &s x %xpos% + ( %i% - 1 ) * %patchwidth% patch %x% %ypos% [calc %x% + %patchwidth%] [calc %ypos% - %height%] &end &if [mod %intervals% 2] = 0 &then &do &s x %xpos% + %intervals% * %patchwidth% patch %x% %ypos% [calc %x% + %patchwidth% * %intervals%] [calc %ypos% - %height%] &end box %xpos% %ypos% [calc %xpos% + %barwidth%] [calc %ypos% - %height%] &s intervalfact 2 &return /************************************* &routine drawbarstyle5 &label drawbarstyle5 &s patchwidth %barwidth% / %intervals% /* Draw central spine of scalebar line %xpos% [calc %ypos% - .5 * %height%] [calc %xpos% + %barwidth%] [calc %ypos% - .5 * %height%] &do i = 1 &to %intervals% &s x %xpos% + ( %i% - 1 ) * %patchwidth% line %x% %ypos% %x% [calc %ypos% - %height%] &end &s x %xpos% + ( %i% - 1 ) * %patchwidth% &s y %ypos% + .5 * [mod %i% 2] * %height% - .5 * %height% /* End bit line [calc %xpos% + %barwidth%] %ypos% [calc %xpos% + %barwidth%] [calc %ypos% - %height%] &s intervalfact 1 &return /************************************* &routine drawbarstyle7 &label drawbarstyle7 &s patchwidth %barwidth% / %intervals% /* Draw central spine of scalebar line %xpos% [calc %ypos% - %height%] [calc %xpos% + %barwidth%] [calc %ypos% - %height%] &do i = 1 &to %intervals% &s x %xpos% + ( %i% - 1 ) * %patchwidth% line %x% %ypos% %x% [calc %ypos% - %height%] &end &s x %xpos% + ( %i% - 1 ) * %patchwidth% &s y %ypos% + .5 * [mod %i% 2] * %height% - .5 * %height% /* End bit line [calc %xpos% + %barwidth%] %ypos% [calc %xpos% + %barwidth%] [calc %ypos% - %height%] &s intervalfact 1 &return /************************************* &routine drawbarstyle6 &label drawbarstyle6 &call drawbarstyle5 /* Add minor tic marks &do i = 1 &to %intervals% &s x %xpos% + ( %i% - .5 ) * %patchwidth% line %x% [calc %ypos% - .15 * %height%] %x% [calc %ypos% - .85 * %height%] &end &return /************************************* &routine drawbarstyle8 &label drawbarstyle8 &call drawbarstyle7 /* Add minor tic marks &do i = 1 &to %intervals% &s x %xpos% + ( %i% - .5 ) * %patchwidth% line %x% [calc %ypos% - .3 * %height%] %x% [calc %ypos% - %height%] &end &return /************************************* &routine drawbarstyle9 &label drawbarstyle9 &s patchwidth %barwidth% / %intervals% /* Draw central spine of scalebar line %xpos% %ypos% [calc %xpos% + %barwidth%] %ypos% &do i = 1 &to %intervals% &s x %xpos% + ( %i% - 1 ) * %patchwidth% line %x% %ypos% %x% [calc %ypos% - %height%] &end &s x %xpos% + ( %i% - 1 ) * %patchwidth% &s y %ypos% + .5 * [mod %i% 2] * %height% - .5 * %height% /* End bit line [calc %xpos% + %barwidth%] %ypos% [calc %xpos% + %barwidth%] [calc %ypos% - %height%] &s intervalfact 1 &return /************************************* &routine drawbarstyle10 &label drawbarstyle10 &call drawbarstyle9 /* Add minor tic marks &do i = 1 &to %intervals% &s x %xpos% + ( %i% - .5 ) * %patchwidth% line %x% [calc %ypos% - .7 * %height%] %x% %ypos% &end &return