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

📄 fontformat.java

📁 用Java开发的、实现类似Visio功能的应用程序源码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/**
 *    $Id:FontFormat.java $
 *
 *    Copyright 2004 ~ 2005  JingFei International Cooperation LTD. All rights reserved. *
 */
package com.jfimagine.jfgraph.shape.decorate;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;

import java.awt.Color;
import java.awt.Font;

import com.jfimagine.jfdom.Document;
import com.jfimagine.jfdom.Element;

import com.jfimagine.utils.commonutil.CommonUtil;

import com.jfimagine.jfgraph.shape.base.AbstractObject;
import com.jfimagine.jfgraph.shape.base.ShapeConst;
import com.jfimagine.jfgraph.shape.base.JFVersion;
 
 /**
 * Font format class. All fonts or curves or circlles should use this class for their fonts format.
 *
 * @author     CookieMaker    
 *
 * @version $Revision: 1.00 $
 */  
 public class FontFormat extends AbstractObject{
  
   //*****************************************************************
   //         XML Tags
   //*****************************************************************

   /**
    *   A XML string tag represents a font format.
    */
   public  static final String	 XML_FONTFORMAT		="FontFormat";

   /**
    *   A XML string tag represents the font style
    */
   public  static final String   XML_FONTSTYLE		="fontStyle";

   /**
    *   A XML string tag represents the font size
    */
   public  static final String   XML_FONTSIZE		="fontSize";

   /**
    *   A XML string tag represents a font's name
    */
   public  static final String   XML_FONTNAME		="fontName";
   /**
    *   A XML string tag represents a font's color
    */
   public  static final String   XML_FONTCOLOR		="fontColor";
   /**
    *   A XML string tag represents font transparency
    */
   public  static final String   XML_FONTTRANSPARENCY	="fontTransparency";

   /**
    *   A XML string tag represents if use stroke and fill drawing format
    */
   public  static final String   XML_USESTROKEANDFILL	="useStrokeAndFill";


   /**
    *   A default font name
    */
   public  static final String  FONTNAME_DEFAULT	=com.jfimagine.jfdraw.gui.resource.CADResource.getString("sys.font");


   /**
    *   A default font size
    */
   public  static final int  FONTSIZE_DEFAULT		=12;


   private static FontFormat m_defaultFontFormat	=new FontFormat();
   /**
    *   set global default font format
    *   @param fontFormat A new font format
    */
   public static void setDefaultFontFormat(FontFormat fontFormat){
   	m_defaultFontFormat.setValue(fontFormat);
   }
   /**
    *   get global default font format
    *   @return The global default font format
    */
   public static FontFormat getDefaultFontFormat(){
   	return m_defaultFontFormat;
   }
   
   /**
    *   Font style variable.
    *   we can use font style value as PLAIN,BOLD,ITALIC,CENTER_BASELINE,HANGLINE_BASELINE,ROMAN_BASELINE,
    *   all of these defined in java.awt.Font.
    */
   private	int	m_fontStyle=Font.PLAIN;

   /**
    *   Font size variable.
    */
   private	int	m_fontSize=FONTSIZE_DEFAULT;

   /**
    *   Font name variable
    */
   private	String	m_fontName=FONTNAME_DEFAULT;

   /**
    *   Font object variable
    */
   private	Font	m_font=null;

   /**
    *   Font color variable,default to black.
    */
   private	Color	m_fontColor=Color.black;

   /**
    *   Transparency of this shape. 0% ~ 100%
    */
   private int m_transparency		=0;


   /**
    *   If use stroke and fill font drawing format
    */
   private	boolean m_useStrokeAndFill	=false;

   /**
    *   Line format for stroke and fill
    */
   private	LineFormat m_lineFormat		=new LineFormat();

   /**
    *   Fill format for stroke and fill
    */
   private	FillFormat m_fillFormat		=new FillFormat();

	
   /**
    *   Constructor for FontFormat
    */
   public FontFormat(){
   	setObjectType(ShapeConst.DECORATETYPE_FONTFORMAT);
   	setXMLTag(XML_FONTFORMAT);

   	if (m_defaultFontFormat!=null){ 
   		setValue(m_defaultFontFormat);
   	}
   }	

   /**
    *  clear format, then set to default values
    */
   public void clearFormat(){
   	m_fontStyle	=Font.PLAIN;
   	m_fontSize	=FONTSIZE_DEFAULT;
   	m_fontName	=FONTNAME_DEFAULT;
   	m_fontColor	=Color.black;   
 	
 	m_transparency	=0;  	
   	m_useStrokeAndFill	=false;
   	m_lineFormat		=new LineFormat();
   	m_fillFormat		=new FillFormat();
   }



   /**
    *   Get current font style.
    *
    *   @return  The font style.
    *
    */ 	
   public int getFontStyle(){
   	return m_fontStyle;
   }

   /**
    *   Set current font style.
    *
    *   @param fontStyle  A new font style.
    *
    */ 	
   public void setFontStyle(int fontStyle){
   	m_fontStyle	=fontStyle;
   }

   /**
    *   Get current font size.
    *
    *   @return  The font size.
    *
    */ 	
   public int getFontSize(){
   	return m_fontSize;
   }


   /**
    *   Set current font size.
    *
    *   @param fontSize  A new font size.
    *
    */ 	
   public void setFontSize(int fontSize){
   	m_fontSize	=fontSize;
   }

   /**
    *   Get current font name.
    *
    *   @return  The font name.
    *
    */ 	
   public String getFontName(){
   	return m_fontName;
   }

   /**
    *   Set current font name.
    *
    *   @param fontName  A new font name.
    *
    */ 	
   public void setFontName(String fontName){
   	if (fontName==null)
   		fontName	=FONTNAME_DEFAULT;
   	m_fontName	=fontName;
   }

   /**
    *   Get current font color.
    *
    *   @return  The font color.
    *
    */ 	
   public Color getFontColor(){
   	return m_fontColor;
   }

   /**
    *   Set current font color.
    *
    *   @param fontColor  A new font color.
    *
    */ 	
   public void setFontColor(Color fontColor){
   	if (fontColor==null)
   		m_fontColor	=new Color(Color.black.getRGB());
   	else
   		m_fontColor	=new Color(fontColor.getRGB());
   }

   /**
    *   get transparency of this shape.
    */
   public int getTransparency(){
   	return m_transparency;
   }

   /**
    *   set transparency of this shape.
    */
   public void  setTransparency(int transparency){  
   	if (transparency<0)
   		transparency	=0;
   	if (transparency>100)
   		transparency	=100;
   		
   	m_transparency	=transparency;
   }


   /**
    *   if is use stroke and fill drawing format
    *
    *   @return  True if use stroke and fill, false otherwise.
    *
    */ 	
   public boolean isUseStrokeAndFill(){
   	return m_useStrokeAndFill;
   }

   /**
    *   Set current font color.
    *
    *   @param useStrokeAndFill  A new font color.
    *
    */ 	
   public void setUseStrokeAndFill(boolean useStrokeAndFill){
   	m_useStrokeAndFill	=useStrokeAndFill;
   }

   /**
    *   Get line format for stroke and fill drawing.
    *
    *   @return  The line format.
    *
    */ 	
   public LineFormat getLineFormat(){
   	return m_lineFormat;
   }

   /**
    *   Get fill format for stroke and fill drawing.
    *
    *   @return  The fill format.
    *
    */ 	
   public FillFormat getFillFormat(){
   	return m_fillFormat;
   }



   /**
    *   Get current font object.
    *
    *   @return  The font object.
    *
    */ 	
   public Font getFont(){
   	initFont();
   	return m_font;
   }

⌨️ 快捷键说明

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