#pragma TextEncoding = "UTF-8" #pragma rtGlobals=3 // Use modern global access method and strict wave access. //FUNCTIONs: //Change_TB_Colors //Change_TB_Font_Size //Changes the text color of a text box to match the color of the trace in the text box //User needs to have already added text color tags, and the script will only handle one //color per line. The script only operates on legends, but that can be changed. //This will work // \K(3,52428,1)\s(Flux_CH3OH) Flux_CH3OH // \K(65535,43690,0)\s(Flux_C2H4) Flux_C2H4 // \K(65535,0,52428)\s(Flux_C2H6) Flux_C2H6 //This legend text won't change // \s(Flux_CH3OH) Flux_CH3OH // \s(Flux_C2H4) Flux_C2H4 //This legend text will all be set to the color of the first trace // \K(3,52428,1)\s(Flux_CH3OH) Flux_CH3OH // \s(Flux_C2H4) Flux_C2H4 //Only the first color tag will get updated here. // \K(3,52428,1)\s(Flux_CH3OH) Flux_CH3OH \K(65535,43690,0)\s(Flux_C2H4) Flux_C2H4 FUNCTION Change_TB_Colors() String strAnnotation_List=AnnotationList("") WAVE/T twAnnotation_List=ListToTextWave(strAnnotation_List, ";") //IMO text waves are easier to debug than string lists, especially long string lists. Variable iTB_Dex FOR(iTB_Dex=0;iTB_Dex=0 && vRGB_Start>=0) //Make sure there is a trace tag and a text color tag Variable vTrace_Stop=strsearch(strLine, ")", vTrace_Start, 2) String strTrace_Name=strLine[vTrace_Start+3, vTrace_Stop-1] Variable vRGB_Stop=strsearch(strLine, ")", vRGB_Start, 0) String strTrace_RGB=StringByKey("rgb(x)", TraceInfo("", strTrace_Name, 0), "=") //This will have parentheses around it String strNew_Line=strLine[0,vRGB_Start+1]+strTrace_RGB+strLine[vRGB_Stop+1,strlen(strLine)-1] strNew_Text+=(strNew_Line+"\r") ELSE strNew_Text+=(strLine+"\r") ENDIF //End making sure there is a trace name and color name ENDFOR //End looping over the lines the text box Legend/C/N=$strTB_Name RemoveEnding(strNew_Text, "\r") ENDIF //End checking the type of the annotation ENDFOR //End looping over the text boxes END /////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //Only works on Legends and Textboxes FUNCTION Change_TB_Font_Size(vNew_Font_Size) Variable vNew_Font_Size String strNew_Font_Size sprintf strNew_Font_Size, "%02d", vNew_Font_Size String strAnnotation_List=AnnotationList("") WAVE/T twAnnotation_List=ListToTextWave(strAnnotation_List, ";") //IMO text waves are easier to deal with than string lists Variable iTB_Dex FOR(iTB_Dex=0;iTB_Dex=0) strNew_Text+=(strLine[0,vFont_Size_Start+1]+strNew_Font_Size+strline[vFont_Size_Start+4,inf]+"\r") ELSE strNew_Text+=(strLine+"\r") ENDIF ENDFOR //End looping over the lines the text box IF(cmpstr(strAnnotation_Type, "Legend")==0) Legend/C/N=$strTB_Name RemoveEnding(strNew_Text, "\r") ELSEIF(cmpstr(strAnnotation_Type, "TextBox")==0) TextBox/C/N=$strTB_Name RemoveEnding(strNew_Text, "\r") ENDIF ENDFOR //End looping over the text boxes END