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

📄 mprinttableformat.java

📁 大家共享愉快, 共享愉快, 共享愉快, 共享愉快,共享愉快
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
			pageHeader_Font = new Font (standard_Font.getName(), Font.BOLD, standard_Font.getSize());
		return pageHeader_Font;
	}	//	getPageHeader_Font

	/**
	 * 	Get Page Header FG_Color
	 *	@return color or blue black
	 */
	public Color getPageHeaderFG_Color()
	{
		if (pageHeaderFG_Color == null)
			pageHeaderFG_Color = MPrintColor.blackBlue;
		return pageHeaderFG_Color;
	}	//	getPageHeaderFG_Color
	
	/**
	 * 	Get Page Header BG_Color
	 *	@return color or white
	 */
	public Color getPageHeaderBG_Color()
	{
		if (pageHeaderBG_Color == null)
			pageHeaderBG_Color = Color.white;
		return pageHeaderBG_Color;
	}	//	getPageHeaderBG_Color

	/**
	 * 	Get Page Footer Font
	 *	@return 2pt smaller standard font
	 */
	public Font getPageFooter_Font()
	{
		if (pageFooter_Font == null)
			pageFooter_Font = new Font (standard_Font.getName(), Font.PLAIN, standard_Font.getSize()-2);
		return pageFooter_Font;
	}	//	getPageFooter_Font
	
	/**
	 * 	Get PageFooter FG_Color
	 *	@return blue black
	 */
	public Color getPageFooterFG_Color()
	{
		if (pageFooterFG_Color == null)
			pageFooterFG_Color = MPrintColor.blackBlue;
		return pageFooterFG_Color;
	}	//	getPageFooterFG_Color
	
	/**
	 * 	Get Page Footer BG_Color
	 *	@return white
	 */
	public Color getPageFooterBG_Color()
	{
		if (pageFooterBG_Color == null)
			pageFooterBG_Color = Color.white;
		return pageFooterBG_Color;
	}	//	getPageFooterBG_Color


	/**************************************************************************
	 *  Get Horizontal Line Color.
	 * 	(one db attribute for line color)
	 *  @return color or gray light
	 */
	public Color getHLine_Color()
	{
		if (lineH_Color != null)
			return lineH_Color;
		int i = getLine_PrintColor_ID();
		if (i != 0)
			lineH_Color = MPrintColor.get(getCtx(), i).getColor();
		if (lineH_Color == null)
			lineH_Color = Color.lightGray;
		return lineH_Color;
	}	//	getHLine_Color
	
	/**
	 *  Get Verical Line Color.
	 * 	(one db attribute for line color)
	 *  @return color or gray light
	 */
	public Color getVLine_Color()
	{
		if (lineV_Color != null)
			return lineV_Color;
		int i = getLine_PrintColor_ID();
		if (i != 0)
			lineV_Color = MPrintColor.get(getCtx(), i).getColor();
		if (lineV_Color == null)
			lineV_Color = Color.lightGray;
		return lineV_Color;
	}	//	getVLine_Color


	/**
	 * 	Get Horizontal Line Stroke -
	 * 	(same DB line column)
	 *	@return solid line baded on line width (default solid 1p)
	 */
	public Stroke getHLine_Stroke()
	{
		if (lineH_Stroke == null)
		{
			float width = getLineStroke().floatValue() / 2;
			if (getHdrStrokeType() == null || LINESTROKETYPE_DottedLine.equals(getLineStrokeType()))
				lineH_Stroke = new BasicStroke(width, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 
					1.0f, getPatternDotted(width), 0.0f);			//	. . .
			//		
			else if (LINESTROKETYPE_SolidLine.equals(getLineStrokeType()))
				lineH_Stroke = new BasicStroke(width);				//	-
			else if (LINESTROKETYPE_DashedLine.equals(getLineStrokeType()))
				lineH_Stroke = new BasicStroke(width, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 
					1.0f, getPatternDashed(width), 0.0f);			//	- -
			else if (LINESTROKETYPE_Dash_DottedLine.equals(getLineStrokeType()))
				lineH_Stroke = new BasicStroke(width, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 
					1.0f, getPatternDash_Dotted(width), 0.0f);		//	- . -
			//	default / fallback
			if (lineH_Stroke == null)
				lineH_Stroke = new BasicStroke(width, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 
					1.0f, getPatternDotted(width), 0.0f);			//	. . .
		}
		return lineH_Stroke;
	}	//	getHLine_Stroke
	
	/**
	 * 	Get Vertical Line Stroke |
	 * 	(same DB line column)
	 *	@return line based on line (1/2 of) width and stroke (default dotted 1/2p 
	 */
	public Stroke getVLine_Stroke()
	{
		if (lineV_Stroke == null)
		{
			float width = getLineStroke().floatValue() / 2;
			if (getHdrStrokeType() == null || LINESTROKETYPE_DottedLine.equals(getLineStrokeType()))
				lineV_Stroke = new BasicStroke(width, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 
					1.0f, getPatternDotted(width), 0.0f);			//	. . .
			//		
			else if (LINESTROKETYPE_SolidLine.equals(getLineStrokeType()))
				lineV_Stroke = new BasicStroke(width);				//	-
			else if (LINESTROKETYPE_DashedLine.equals(getLineStrokeType()))
				lineV_Stroke = new BasicStroke(width, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 
					1.0f, getPatternDashed(width), 0.0f);			//	- -
			else if (LINESTROKETYPE_Dash_DottedLine.equals(getLineStrokeType()))
				lineV_Stroke = new BasicStroke(width, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 
					1.0f, getPatternDash_Dotted(width), 0.0f);		//	- . -
			//	default / fallback
			if (lineV_Stroke == null)
				lineV_Stroke = new BasicStroke(width, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 
					1.0f, getPatternDotted(width), 0.0f);			//	. . .
		}
		return lineV_Stroke;
	}	//	getVLine_Stroke

	/**
	 * 	Get Horizontal Stroke for Lines -
	 *	@return stroke in pt (default 1)
	 */
	public BigDecimal getLineStroke()
	{
		BigDecimal retValue = super.getLineStroke();
		if (retValue == null || Env.ZERO.compareTo(retValue) <= 0)
			retValue = new BigDecimal (1.0);
		return retValue;
	}	//	getLineStroke

	/**
	 * 	Get Vertical Stroke for Lines |
	 *	@return stroke in pt (default 1)
	 */
	public BigDecimal getVLineStroke()
	{
		BigDecimal retValue = super.getLineStroke();
		if (retValue == null || Env.ZERO.compareTo(retValue) <= 0)
			retValue = new BigDecimal (1.0);
		return retValue;
	}	//	getVLineStroke
	
	/**
	 * 	Get Pattern Dotted . . . .
	 *	@param width width of line
	 *	@return pattern
	 */
	private float[] getPatternDotted (float width)
	{
		return new float[] {2*width, 2*width};
	}	//	getPatternDotted

	/**
	 * 	Get Pattern Dashed - - - -
	 *	@param width width of line
	 *	@return pattern
	 */
	private float[] getPatternDashed (float width)
	{
		return new float[] {10*width, 4*width};
	}	//	getPatternDashed
	
	/**
	 * 	Get Pattern Dash Dotted - . - .
	 *	@param width width of line
	 *	@return pattern
	 */
	private float[] getPatternDash_Dotted (float width)
	{
		return new float[] {10*width, 2*width, 2*width, 2*width};
	}	//	getPatternDash_Dotted
	
	
	/*************************************************************************/

	private static CCache<Integer,MPrintTableFormat>	s_cache
		= new CCache<Integer,MPrintTableFormat>("AD_PrintTableFormat", 3);
	/** Static Logger					*/
	private static CLogger 	s_log = CLogger.getCLogger(MPrintTableFormat.class);

	/**
	 * 	Get Table Format.
	 * 	@param ctx context
	 * 	@param AD_PrintTableFormat_ID table format
	 *  @param standard_font standard font
	 * 	@return Table Format
	 */
	static public MPrintTableFormat get (Properties ctx, int AD_PrintTableFormat_ID, Font standard_font)
	{
		Integer ii = new Integer (AD_PrintTableFormat_ID);
		MPrintTableFormat tf = (MPrintTableFormat)s_cache.get(ii);
		if (tf == null)
		{
			if (AD_PrintTableFormat_ID == 0)
				tf = getDefault (ctx);
			else
				tf = new MPrintTableFormat (ctx, AD_PrintTableFormat_ID, null);
			s_cache.put(ii, tf);
		}
		tf.setStandard_Font(standard_font);
		return tf;
	}	//	get

	/**
	 * 	Get Table Format
	 * 	@param ctx context
	 * 	@param AD_PrintTableFormat_ID table format
	 *  @param AD_PrintFont_ID standard font
	 * 	@return Table Format
	 */
	static public MPrintTableFormat get (Properties ctx, int AD_PrintTableFormat_ID, int AD_PrintFont_ID)
	{
		return get (ctx, AD_PrintTableFormat_ID, MPrintFont.get (AD_PrintFont_ID).getFont());
	}	//	get

	/**
	 * 	Get Default Table Format.
	 * 	@param ctx context
	 * 	@return Default Table Format (need to set standard font) 
	 */
	static public MPrintTableFormat getDefault (Properties ctx)
	{
		MPrintTableFormat tf = null;
		String sql = "SELECT * FROM AD_PrintTableFormat "
			+ "WHERE AD_Client_ID IN (0,?) AND IsActive='Y' "
			+ "ORDER BY IsDefault DESC, AD_Client_ID DESC";
		int AD_Client_ID = Env.getAD_Client_ID(ctx);
		PreparedStatement pstmt = null;
		try
		{
			pstmt = DB.prepareStatement(sql, null);
			pstmt.setInt(1, AD_Client_ID);
			ResultSet rs = pstmt.executeQuery();
			if (rs.next())
				tf = new MPrintTableFormat (ctx, rs, null);
			rs.close();
			pstmt.close();
			pstmt = null;
		}
		catch (Exception e)
		{
			s_log.log(Level.SEVERE, sql, e);
		}
		try
		{
			if (pstmt != null)
				pstmt.close();
			pstmt = null;
		}
		catch (Exception e)
		{
			pstmt = null;
		}
		return tf;
	}	//	get


}	//	MPrintTableFormat

⌨️ 快捷键说明

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