;+ ; ;thm_ui_draw_object method: addDateString ; ;adds the dateString annotation to the axis ; ;Inputs: ; view(object reference): The IDLgrView to which the string will be added. ; axisSettings(object reference): the thm_ui_axis_settings where the associated settings are stored ; range(2-element double): The start and stop range for the panel ; scaling(long): Indicates the scaling used 0(linear),1(log10),2(logN) ; xplotsize: The length of the x-axis of the panel in normalized coordinates ; yplotsize: The length of the y-axis of the panel in normalized coordinates ; labelMargin: The distance between the variable labels and the y-axis. This ; parameter is also used to position the dateString, in lieu of a more specific parameter ; ;$LastChangedBy: pcruce $ ;$LastChangedDate: 2010-08-25 18:05:01 -0700 (Wed, 25 Aug 2010) $ ;$LastChangedRevision: 7774 $ ;$URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/thmsoc/tags/tdas_8_00/idl/themis/thm_ui_new/display/draw_object/thm_ui_draw_object__adddatestring.pro $ ;- pro thm_ui_draw_object::addDateString,view,axisSettings,range,scaling,xplotsize,yplotsize,labelmargin compile_opt idl2 axisSettings->getProperty,$ showDate=showDate,$ datestring1=datestring1,$ datestring2=datestring2,$ placeannotation=placeannotation,$ ; scaling=scaling,$ annotateTextObject=annotateTextObject,$ tickStyle=tickStyle,$ bottomPlacement=bottomPlacement,$ topPlacement=topPlacement,$ majorLength=majorLength,$ minorLength=minorLength,$ isTimeAxis=isTimeAxis ; view->getProperty,viewPlane_rect=viewPlane_rect if ~showDate then begin return endif if ~isTimeAxis then begin return endif ;format the date strings, according to the splash-based format codes string1 = formatdate(range[0],datestring1,scaling) string2 = formatdate(range[0],datestring2,scaling) ;Copy the text objects so we can mutate them string1Obj = annotateTextObject->copy() string2Obj = annotateTextObject->copy() string1Obj->getProperty,size=size ;Turn this measure into a panel normal size textSizeNorm = self->pt2norm(size,1)/yplotsize posoffset = textSizeNorm ;account for tick position when calculating offset for date string if tickStyle eq 1 || tickStyle eq 2 then begin if (~placeAnnotation && bottomPlacement) || $ (placeAnnotation && topPlacement) then begin posoffset += (self->pt2norm(majorLength > minorLength,1)/yplotsize) endif endif xposoffset = -self->pt2norm(labelmargin,0)/xplotsize string1Obj->setProperty,value=string1 string2Obj->setProperty,value=string2 ;determine if string goes on top or bottom if placeAnnotation then begin ; location = [viewPlane_rect[0]/2.,1. + (viewPlane_rect[3]-1+viewPlane_rect[1])/4.,.1] location = [xposoffset,1.+posoffset,.1] endif else begin ;location = [viewPlane_rect[0]/2.,viewPlane_rect[1]/4.,.1] location = [xposoffset,0.-posoffset,.1] endelse ;generate text models and add them model1 = self->getTextModel(string1Obj,location,1.,0.,justify=1) model2 = self->getTextModel(string2Obj,location,-1.,0.,justify=1) view->add,model1 view->add,model2 end