⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 twoway_yxview_parse.class

📁 是一个经济学管理应用软件 很难找的 但是经济学学生又必须用到
💻 CLASS
📖 第 1 页 / 共 2 页
字号:
/*                                 twoway_yxview_parse

   A parser for yxviews.  Works with twoway.ado.

   Typical usage:

   	tempname parse_obj
	.`parse_obj' = .twoway_yxview_parse.new parse_syntax
		... process .`parse_obj'.options ...
	.ss = .`parse_obj'.log_create_serset	/* or create your own serset */
	.view = .`parse_obj'.log_create_view , view(#) serset(ssname) 	///
		plotregion(prname) seriesid(#) ...
	.`parse_obj'.log_edits .view #_view

*/
*! version 1.0.12  03mar2005

version 8

class {
    instance:
    	double n			// number of views

					// attributes expected by twoway
	string varlist
	string if
	string in
	string wtype
	string wtexp
	string sort
	string omitmethod
	string options				// other options

	array  labvars

	must_create_serset = 0		// designates whether serset_cmd MUST
					// be used to create serset for view 

	string viewtype			// attributes specific to the view

	array plotstyles		// array of .editstyle strings
	array plotsettings		// array of plot settings

	viewclass = "yxview"		// class of the created views
					// may be replaced if inherited 

	x_pushed = 0			// internal tracking

	varcheck	= 1		// side signal from children
	allow_anything	= 0		// side signal from children
	anything	= ""

	wtvarnum  = 0			// weight variable id
	posnm     = ""			// position variable name

	drop_base = 1			// for areas, whether droping do base

	overall_drop_to = ""		// for bar and rbar
	barwidth	= -1		// for rbar

} , inherit(parser_g)



/* -------------------------------------------------------------------------*/
/*
	Parse the yxview and fill-in the parsing information.

	Leaves any unparsed options in .options.

	Parsers that derive from this class often use -_parse expand- to
	expand their own options, then call here to parse the varlist and
	to compbine and record the pair options.

	Assumes that weights are allowed, so issue a message if .wttype is
	filled in and your derived view does not support weights.
*/

program parse

	syntax [anything(id="varlist" equalok)] [aw fw pw ] [if] [in]	///
		[ , SERSET(passthru) * ]

	if `"`serset'"' == `""' {
					// let children signal what  is allowed
		if `.allow_anything' {
			local varspec [ anything(equalok) ]
		}
		else {
		    if 0`.varcheck' {
			local varspec varlist(min=2 numeric ts default=none)
		    }
		    else {
			local varspec [varlist(numeric ts default=none)]
		    }
		}
	}
	else {					// if serset allow names
		if `.allow_anything' {
			local varspec [ anything(equalok) ]
		}
		else {
		    if 0`.varcheck' {
			local varspec namelist(min=2 default=none)
		    }
		    else {
			local varspec [namelist(min=1 default=none)]
		    }
		}
	}

	_parse combop 0 : 0 , option(MLabels)   rightmost
	_parse combop 0 : 0 , option(TYPE)      rightmost
	_parse combop 0 : 0 , option(RECASTas)  rightmost
	_parse combop 0 : 0 , option(SORT1)     rightmost
	_parse combop 0 : 0 , option(SERSET)    rightmost

	syntax `varspec' [aw fw pw] [if] [in] [ ,			///
		MLabels(string) TYPE(string) RECASTas(string)		///
		SORT SORT1(namelist) MLABVposition(name) 		///
		OMITANYMiss OMITALLMiss OMITDUPmiss OMITNothing		///
		SERSET(passthru) noDROPBase * ]

	local varlist `varlist' `namelist'

	if `:word count `omitanymiss' `omitallmiss' `omitdupmiss'	///
	   `omitnothing'' > 1 {
		di as error "may only specify one from omitanymiss " 	///
			"omitallmiss omitdupmiss omitnothing"
		exit 198
	}

	if `"`recastas'"' != `""' {
		local type `"`recastas'"'			// synonym
	}

	if `.n' >= . {					// else set by caller
		.n = max(`=`:word count `varlist'' - 1', 0)
	}

	local labclean : subinstr local mlabels "." " " , all
	if `"`labclean'"' != `""' & ! `.allow_anything' {
		unab labclean : `labclean'
	}
	local labclean : list uniq labclean
	.varlist	= "`:list varlist | labclean'"
	.anything	= `"`anything'"'
	.if		= `"`if'"'
	.in		= `"`in'"'
	.wtype		= `"`weight'"'
	.wtexp		= `"`exp'"'
	.omitmethod	= "`omitanymiss'`omitallmiss'`omitdupmiss'`omitnothing'"
	if `"`sort'"'  != `""' {
		.sort	= "`:word `=`.n'+1' of `.varlist''"
	}
	if `"`sort1'"' != `""' {
		.sort	= "`sort1'"
	}
	if `"`.wtexp'"' != `""' {
		.must_create_serset = 1
	}

	if "`dropbase'" != "" {
		.drop_base = 0
	}

	if "`mlabels'" != "" {				// record label vars
		local i 0
		foreach var of local mlabels {
			if "`var'" == "." {
				local ++i
			}
			else {
				if ! `.allow_anything' {
					unab var : `var'
				}
				.labvars[`++i'] = "`var'"		
			}
		}
	}

	if "`mlabvposition'" != "" {			// label positions
		if ! `.allow_anything' {
			unab mlabvposition : `mlabvposition'
		}

		local varlist `.varlist'
		.varlist = "`:list varlist | mlabvposition'"

		.posnm = "`mlabvposition'"
	}

	if "`type'" != "" {
		.viewtype	= "`type'"		// assumes a valid view
	}

	if `.BarOrBarDerived' {
		local 0 `", `options'"'
		syntax [ , HORizontal VERTical * ]

		if `:word count `horizontal' `vertical'' > 1 {
		   di as error "may not combine options horizontal and vertical"
		   exit 198
		}

		if "`vertical'"   != "" {
			.overall_drop_to = "x"
		}
		if "`horizontal'" != "" {
			.overall_drop_to = "y"
		}
	}

	.parse_opts , `options'
end


/* -------------------------------------------------------------------------*/
/*
	Parse the options for the yxview and fill-in the parsing information.

	Leaves any unparsed options in .options.

	Note, again that parsers deriving from this parser often merely 
	-_parse expand- their options and call through to here.
*/

program parse_opts

	local popts P1(string asis)  P2(string asis)  P3(string asis)	///
		    P4(string asis)  P5(string asis)  P6(string asis)	///
		    P7(string asis)  P8(string asis)  P9(string asis)	///
		    P10(string asis) P11(string asis) P12(string asis)	///
		    P13(string asis) P14(string asis) P15(string asis)	///
		    P16(string asis) P17(string asis) P18(string asis)	///
		    P19(string asis) P20(string asis) 

	local n = cond(`.n' < . , `.n' , 19) + 1	// ignore p# # > .n
							// allow +1 for x
							// masquerading as y

							// style settings
	local 0 `"`.factor `0''"'
	_parse factordot  0 : 0 , n(`.n')
	_parse combine    0 : 0

	syntax [ , `popts' * ]

	forvalues i = 1/`n' {
		if `"`p`i''"' != `""' {
			.plotstyles[`i'] = `"`p`i''"'
		}
	}

							// plot settings
	local 0 `"`.FactorPlot , `options''"'
	_parse factordot  0 : 0 , n(`.n')
	_parse combine    0 : 0

	syntax [ , `popts' * ]
	forvalues i = 1/`n' {
		if `"`p`i''"' != `""' {
			.plotsettings[`i'] = `"`p`i''"'
		}
	}

	.options	= `"`options'"'

end

program factor
						// factor overall series style

	_parse combop 0 : 0 , option(PSTYle)    rightmost
	_parse factor 0 : 0 , option(PSTYle)	to(style(X))	

						// All colors
	_parse combop 0 : 0 , option(COLor)	rightmost
	_parse factor 0 : 0 , option(COLor) to(line(color(X)) qxav(X))
	_parse factor 0 : 0, option(QXAV) to(area(shadestyle(color(X))) qxav(X))
	_parse factor 0 : 0 , option(QXAV) to(area(linestyle(color(X))) qxav(X))
	_parse factor 0 : 0 , option(QXAV)				///
				to(marker(fillcolor(X) linestyle(color(X))))


						// connecting & area line style

	_parse combop 0 : 0 , option(LStyle)	rightmost
	_parse factor 0 : 0 , option(LStyle)	to(line(X) area(linestyle(X)))
	_parse combop 0 : 0 , option(LColor)	rightmost
	_parse factor 0 : 0 , option(LColor)				///
				to(line(color(X)) area(linestyle(color(X)))) 
	_parse combop 0 : 0 , option(LWidth)	rightmost
	_parse factor 0 : 0 , option(LWidth)				///
				to(line(width(X)) area(linestyle(width(X))))   
	_parse combop 0 : 0 , option(LPattern)	rightmost
	_parse factor 0 : 0 , option(LPattern)				///
			to(line(pattern(X)) area(linestyle(pattern(X))))   


						// connecting line style

	_parse combop 0 : 0 , option(CLStyle)   rightmost
	_parse factor 0 : 0 , option(CLStyle)	to(line(X))	
	_parse combop 0 : 0 , option(CLColor)   rightmost
	_parse factor 0 : 0 , option(CLColor)	to(line(color(X))) 
	_parse combop 0 : 0 , option(CLWidth)   rightmost
	_parse factor 0 : 0 , option(CLWidth)	to(line(width(X))) 
	_parse combop 0 : 0 , option(CLPattern) rightmost
	_parse factor 0 : 0 , option(CLPattern)	to(line(pattern(X))) 

						// marker style options

	_parse combop 0 : 0 , option(MSTyle)    rightmost
	_parse factor 0 : 0 , option(MSTyle)	to(marker(X))		
	_parse combop 0 : 0 , option(Msymbol)   rightmost
	_parse factor 0 : 0 , option(Msymbol)	to(marker(symbol(X)))	
	_parse combop 0 : 0 , option(Symbol)    rightmost
	_parse factor 0 : 0 , option(Symbol)	to(marker(symbol(X)))	
	_parse combop 0 : 0 , option(MColor)    rightmost
	_parse factor 0 : 0 , option(MColor)				///
			      to(marker(fillcolor(X) linestyle(color(X))))	
	_parse combop 0 : 0 , option(MFColor)   rightmost
	_parse factor 0 : 0 , option(MFColor) to(marker(fillcolor(X)))	
	_parse combop 0 : 0 , option(MSIze)   rightmost
	_parse factor 0 : 0 , option(MSIze)   to(marker(size(X)))	
	_parse combop 0 : 0 , option(MLstyle) rightmost
	_parse factor 0 : 0 , option(MLstyle) to(marker(linestyle(X))) 
	_parse combop 0 : 0 , option(MLColor) rightmost
	_parse factor 0 : 0 , option(MLColor) to(marker(linestyle(color(X)))) 
	_parse combop 0 : 0 , option(MLPattern) rightmost
	_parse factor 0 : 0 , option(MLPattern)  			///
			      to(marker(linestyle(pattern(X))))   
	_parse combop 0 : 0 , option(MLWidth) rightmost
	_parse factor 0 : 0 , option(MLWidth) to(marker(linestyle(width(X))))   
	_parse combop 0 : 0 , option(MANGle)   rightmost
	_parse factor 0 : 0 , option(MANGle)	to(marker(angle(X)))	
	_parse combop 0 : 0 , option(BARBSize)   rightmost
	_parse factor 0 : 0 , option(BARBSize)	to(marker(backsize(X)))	
	_parse combop 0 : 0 , option(BMSymbol) rightmost
	_parse factor 0 : 0 , option(BMSymbol) to(marker(backsymbol(X)))
	_parse combop 0 : 0 , option(BSymbol) rightmost
	_parse factor 0 : 0 , option(BSymbol) to(marker(backsymbol(X)))	
	_parse combop 0 : 0 , option(BMColor) rightmost
	_parse factor 0 : 0 , option(BMColor) to(marker(backcolor(X))) 
	_parse combop 0 : 0 , option(BMSIze)  rightmost
	_parse factor 0 : 0 , option(BMSIze)  to(marker(backsize(X)))
	_parse combop 0 : 0 , option(BMLinestyle)  rightmost
	_parse factor 0 : 0 , option(BMLinestyle)  to(marker(backline(X)))
	_parse combop 0 : 0 , option(BMLColor) rightmost
	_parse factor 0 : 0 , option(BMLColor) to(marker(backline(color(X))))
	_parse combop 0 : 0 , option(BMLPattern) rightmost
	_parse factor 0 : 0 , option(BMLPattern)			///
			      to(marker(backline(pattern(X))))   
	_parse combop 0 : 0 , option(BMLWidth) rightmost
	_parse factor 0 : 0 , option(BMLWidth) to(marker(backline(width(X))))   

						// label style options
	_parse combop 0 : 0 , option(MLABSTyle) rightmost
	_parse factor 0 : 0 , option(MLABSTyle) to(label(X))		
	_parse combop 0 : 0 , option(MLABPosition) rightmost
	_parse factor 0 : 0 , option(MLABPosition) to(label(position(X)))	
	_parse combop 0 : 0 , option(MLABGap) rightmost
	_parse factor 0 : 0 , option(MLABGap) to(label(textgap(X)))
	_parse combop 0 : 0 , option(MLABTextstyle) rightmost
	_parse factor 0 : 0 , option(MLABTextstyle) to(label(textstyle(X))) 
	_parse combop 0 : 0 , option(MLABSize) rightmost
	_parse factor 0 : 0 , option(MLABSize) to(label(textstyle(size(X)))) 
	_parse combop 0 : 0 , option(MLABColor) rightmost
	_parse factor 0 : 0 , option(MLABColor) to(label(textstyle(color(X)))) 
	_parse combop 0 : 0 , option(MLABFontface) rightmost
	_parse factor 0 : 0 , option(MLABFontface)			///
			      to(label(textstyle(fontface(X)))) 
	_parse combop 0 : 0 , option(MLABANGle) rightmost
	_parse factor 0 : 0 , option(MLABANGle) to(label(textstyle(angle(X)))) 
	_parse combop 0 : 0 , option(MLABJUSTification) rightmost
	_parse factor 0 : 0 , option(MLABJUSTification) to(label(horizontal(X)))
	_parse combop 0 : 0 , option(MLABALIGNment) rightmost
	_parse factor 0 : 0 , option(MLABALIGNment) to(label(vertical(X)))

						// area style options

	_parse combop 0 : 0 , option(ASTyle)    rightmost
	_parse factor 0 : 0 , option(ASTyle)	to(area(X))		
	_parse combop 0 : 0 , option(AColor)    rightmost
	_parse factor 0 : 0 , option(AColor)				///
			      to(area(shadestyle(color(X)) linestyle(color(X))))
	_parse combop 0 : 0 , option(AFColor)   rightmost
	_parse factor 0 : 0 , option(AFColor) to(area(shadestyle(color(X))))
	_parse combop 0 : 0 , option(AFIntensity) rightmost
	_parse factor 0 : 0 , option(AFIntensity)			///
			      to(area(shadestyle(intensity(X))))
	_parse combop 0 : 0 , option(ALstyle) rightmost
	_parse factor 0 : 0 , option(ALstyle) to(area(linestyle(X))) 
	_parse combop 0 : 0 , option(ALColor) rightmost
	_parse factor 0 : 0 , option(ALColor) to(area(linestyle(color(X)))) 
	_parse combop 0 : 0 , option(ALPattern) rightmost
	_parse factor 0 : 0 , option(ALPattern)  			///
			      to(area(linestyle(pattern(X))))   
	_parse combop 0 : 0 , option(ALWidth) rightmost
	_parse factor 0 : 0 , option(ALWidth) to(area(linestyle(width(X))))   

						// bar (b) a synonym for area

	_parse combop 0 : 0 , option(BSTyle)    rightmost
	_parse factor 0 : 0 , option(BSTyle)	to(area(X))		
	_parse combop 0 : 0 , option(BColor)    rightmost
	_parse factor 0 : 0 , option(BColor)				///
			      to(area(shadestyle(color(X)) linestyle(color(X))))
	_parse combop 0 : 0 , option(BFColor)   rightmost
	_parse factor 0 : 0 , option(BFColor) to(area(shadestyle(color(X))))
	_parse combop 0 : 0 , option(BFIntensity) rightmost
	_parse factor 0 : 0 , option(BFIntensity)			///
			      to(area(shadestyle(intensity(X))))
	_parse combop 0 : 0 , option(BLstyle) rightmost
	_parse factor 0 : 0 , option(BLstyle) to(area(linestyle(X))) 
	_parse combop 0 : 0 , option(BLColor) rightmost
	_parse factor 0 : 0 , option(BLColor) to(area(linestyle(color(X)))) 
	_parse combop 0 : 0 , option(BLPattern) rightmost
	_parse factor 0 : 0 , option(BLPattern)  			///

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -