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

📄 globalsettings.java

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


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

import java.io.BufferedReader;
import java.io.FileReader;

import java.io.PrintWriter;
import java.io.FileWriter;


import com.jfimagine.jfgraph.shape.base.ShapeConst;
import com.jfimagine.utils.commonutil.CommonUtil;

import com.jfimagine.jfgraph.shape.decorate.Arrow;
import com.jfimagine.jfgraph.shape.decorate.FillFormat;
import com.jfimagine.jfgraph.shape.decorate.LineFormat;
import com.jfimagine.jfgraph.shape.decorate.FontFormat;
import com.jfimagine.jfgraph.shape.decorate.CanvasFormat;
import com.jfimagine.jfdraw.gui.dialog.RotateSetupDialog;


 /**
 * Global settings class. A class used to place global settings.
 *
 * @author     CookieMaker    
 *
 * @version $Revision: 1.1.1 $
 */  
 public class GlobalSettings{  
        
        /** a text based config file name*/
	private static final String CONFIG_FILE	="jfdraw.config";  
	
	
        /** key for measure type*/
	private static final String CONFIG_KEY_MEASURE	="globalsettings.measure";

        /** key for hidePorts*/
	private static final String CONFIG_KEY_HIDEPORTS="globalsettings.hidePorts";
	
        /** key for disablePortSnapping*/
	private static final String CONFIG_KEY_DISABLEPORTSNAPPING="globalsettings.disablePortSnapping";
	
        /** key for scaleValue*/
	private static final String CONFIG_KEY_SCALEVALUE="globalsettings.scaleValue";
	
        /** key for scaleUnit*/
	private static final String CONFIG_KEY_SCALEUNIT="globalsettings.scaleUnit";

        /** key for screenUnit*/
	private static final String CONFIG_KEY_SCREENUNIT="globalsettings.screenUnit";

        /** key for global path*/
	private static final String CONFIG_KEY_GLOBALPATH="globalsettings.globalPath";
	
        /** export with grid*/
	private static final String CONFIG_KEY_EXPORTWITHGRID="globalsettings.exportWithGrid";

        /** export with ruler*/
	private static final String CONFIG_KEY_EXPORTWITHRULER="globalsettings.exportWithRuler";


        /** start arrow type arrow format*/
	private static final String CONFIG_KEY_ARROWFORMAT_STARTARROWTYPE="globalsettings.arrowtype.startarrowtype";
        /** end arrow type arrow format*/
	private static final String CONFIG_KEY_ARROWFORMAT_ENDARROWTYPE="globalsettings.arrowtype.endarrowtype";


        /** line style of line format*/
	private static final String CONFIG_KEY_LINEFORMAT_LINESTYLE="globalsettings.lineformat.linestyle";
        /** line width of line format*/
	private static final String CONFIG_KEY_LINEFORMAT_LINEWIDTH="globalsettings.lineformat.linewidth";
        /** line color of line format*/
	private static final String CONFIG_KEY_LINEFORMAT_LINECOLOR="globalsettings.lineformat.linecolor";


        /** fill style of fill format*/
	private static final String CONFIG_KEY_FILLFORMAT_FILLSTYLE="globalsettings.fillformat.fillstyle";
        /** fill color of fill format*/
	private static final String CONFIG_KEY_FILLFORMAT_FILLCOLOR="globalsettings.fillformat.fillcolor";
        /** fill color2 of fill format*/
	private static final String CONFIG_KEY_FILLFORMAT_FILLCOLOR2="globalsettings.fillformat.fillcolor2";
        /** fill line style of fill format*/
	private static final String CONFIG_KEY_FILLFORMAT_FILLLINESTYLE="globalsettings.fillformat.filllinestyle";
        /** fill line color of fill format*/
	private static final String CONFIG_KEY_FILLFORMAT_FILLLINECOLOR="globalsettings.fillformat.filllinecolor";


        /** font style of font format*/
	private static final String CONFIG_KEY_FONTFORMAT_FONTSTYLE="globalsettings.fontformat.fontstyle";
        /** font size of font format*/
	private static final String CONFIG_KEY_FONTFORMAT_FONTSIZE="globalsettings.fontformat.fontsize";
        /** font name of font format*/
	private static final String CONFIG_KEY_FONTFORMAT_FONTNAME="globalsettings.fontformat.fontname";
        /** font color of font format*/
	private static final String CONFIG_KEY_FONTFORMAT_FONTCOLOR="globalsettings.fontformat.fontcolor";
        /** font transparency of font format*/
	private static final String CONFIG_KEY_FONTFORMAT_FONTTRANSPARENCY="globalsettings.fontformat.fonttransparency";
        /** use stroke and fill of font format*/
	private static final String CONFIG_KEY_FONTFORMAT_USESTROKEANDFILL="globalsettings.fontformat.usestrokeandfill";

        /** line style of font format(use stroke and fill)*/
	private static final String CONFIG_KEY_FONTFORMAT_LINESTYLE="globalsettings.fontformat.linestyle";
        /** line width of font format(use stroke and fill)*/
	private static final String CONFIG_KEY_FONTFORMAT_LINEWIDTH="globalsettings.fontformat.linewidth";
        /** line color of font format(use stroke and fill)*/
	private static final String CONFIG_KEY_FONTFORMAT_LINECOLOR="globalsettings.fontformat.linecolor";

        /** fill style of fill format(use stroke and fill)*/
	private static final String CONFIG_KEY_FONTFORMAT_FILLSTYLE="globalsettings.fontformat.fillstyle";
        /** fill color of fill format(use stroke and fill)*/
	private static final String CONFIG_KEY_FONTFORMAT_FILLCOLOR="globalsettings.fontformat.fillcolor";
        /** fill color2 of fill format(use stroke and fill)*/
	private static final String CONFIG_KEY_FONTFORMAT_FILLCOLOR2="globalsettings.fontformat.fillcolor2";
        /** fill line style of fill format(use stroke and fill)*/
	private static final String CONFIG_KEY_FONTFORMAT_FILLLINESTYLE="globalsettings.fontformat.filllinestyle";
        /** fill line color of fill format(use stroke and fill)*/
	private static final String CONFIG_KEY_FONTFORMAT_FILLLINECOLOR="globalsettings.fontformat.filllinecolor";


        /** canvas width of canvas format setting*/
	private static final String CONFIG_KEY_CANVASFORMAT_CANVASWIDTH="globalsettings.canvasformat.canvaswidth";
        /** canvas width unit of canvas format setting*/
	private static final String CONFIG_KEY_CANVASFORMAT_CANVASWIDTHUNIT="globalsettings.canvasformat.canvaswidthunit";
        /** canvas height of canvas format setting*/
	private static final String CONFIG_KEY_CANVASFORMAT_CANVASHEIGHT="globalsettings.canvasformat.canvasheight";
        /** canvas height unit of canvas format setting*/
	private static final String CONFIG_KEY_CANVASFORMAT_CANVASHEIGHTUNIT="globalsettings.canvasformat.canvasheightunit";


        /** rotate type*/
	private static final String CONFIG_KEY_ROTATE_TYPE	="globalsettings.rotate.type";
        /** rotate angle*/
	private static final String CONFIG_KEY_ROTATE_ANGLE	="globalsettings.rotate.angle";
		
 	/** english or metric measurement*/
    	private int m_measure			=ShapeConst.MEASURE_ENGLISH;

   	/**
    	*   Hide ports
    	*/
   	private boolean  m_hidePorts		=false;

   	/**
    	*   Disable port snapping
    	*/
   	private boolean  m_disablePortSnapping=false;

   	/**
    	*   Scale value, e.g.  1cm = [scaleValue] * km
    	*/
   	private double  m_scaleValue		=1;

   	/**
    	*   Scale units, e.g.  1cm = 100 *  [scaleUnit]
    	*/
   	private int     m_scaleUnit		=ShapeConst.MEASURE_TYPE_IN;

   	/**
    	*   Screen unit, e.g.  1 * [screenUnit] = 1000 * meter
    	*/
   	private int     m_screenUnit		=ShapeConst.MEASURE_TYPE_IN;

   	/**
    	*   Global directory for open and save files.
    	*/
   	private String    m_globalPath		="";


   	/** Export/Print graph with grid.*/
   	private boolean  m_exportWithGrid	=false;

   	/** Export/Print graph with ruler.*/
   	private boolean  m_exportWithRuler	=false;
	
	
	/** rotate type */
	private int	m_rotateType		=RotateSetupDialog.ROTATE_ANYANYGLE;
	/** rotate angle */
	private double m_rotateAngle		=10.0;


        /** global arrow format*/
        private Arrow	m_arrow		=new Arrow();
        /** global line format*/
        private LineFormat m_lineFormat	=new LineFormat();
        /** global fill format*/
        private FillFormat m_fillFormat	=new FillFormat();
        /** global font format*/
        private FontFormat m_fontFormat	=new FontFormat();
	/** global canvas format */
	private CanvasFormat m_canvasFormat =new CanvasFormat();

	/** get measure type, english or metric
	 *  @return current measurement type.
	 */
	public  int getMeasure(){
		return m_measure;
	}
	/** set measure type, english or metric
	 *  @param measure A new measurement type.
	 */
	public  void setMeasure(int measure){
		m_measure	=measure;     
		writeConfigFile();
	}
        
        /**
         *  Get if current measurement is metric or english
         *  @return True if is metric, false english.
         */
        public boolean isMetric(){
        	return (m_measure==ShapeConst.MEASURE_METRIC);
	}
        

   	/**
    	*   if assigned hidding ports .
    	*/
   	public boolean isHidePorts(){
   		return m_hidePorts;
   	}
   
   	/**
    	*   set if hide or show ports.
    	*/
   	public void setHidePorts(boolean hide){
   		m_hidePorts	=hide;
		writeConfigFile();
   	}


   	/**
    	*   if assigned disable port snapping.
    	*/
   	public boolean isDisablePortSnapping(){
   		return m_disablePortSnapping;
   	}
  
   	/**
    	*   set if hide or show ports.
    	*/
   	public void setDisablePortSnapping(boolean disable){
   		m_disablePortSnapping	=disable;
		writeConfigFile();
   	}


   	/**
    	*   Get the scale value, a scale value is something like << 1cm = [scaleValue] * km >>  
    	*   @return the scale value.
    	*/
   	public double getScaleValue(){
   		return m_scaleValue;
   	}
  
   	/**
    	*   Set the scale value
    	*   @param scale A new scale value
    	*/
   	public void setScaleValue(double scale){
   		m_scaleValue	=scale;
		writeConfigFile();
   	}

   	/**
    	*   Get the scale unit, a scale unit is something like << 1cm = 100 *  [scaleUnit] >>  
    	*   @return the scale unit.
    	*/
   	public int getScaleUnit(){
   		return m_scaleUnit;
   	}
  
   	/**
    	*   Set the scale unit
    	*   @param unit A new scale unit
    	*/
   	public void setScaleUnit(int unit){
   		m_scaleUnit	=unit;
		writeConfigFile();
   	}

   	/**
    	*   Get the screen unit, a screen unit is something like << 1 * [screenUnit] = 1000 * meter >>  
    	*   We only allowed CM or INch for current screen unit.
    	*   @return the screen unit.
    	*/
   	public int getScreenUnit(){
   		return m_screenUnit;
   	}
  
   	/**
    	*   Set the screen unit
    	*   We only allowed CM or INch for current screen unit.
    	*   @param unit A new screen unit
    	*/
   	public void setScreenUnit(int unit){
   		m_screenUnit	=unit;
		writeConfigFile();
   	}


   	/**
    	*   rotate type, in any angle, or fixed angle
    	*   @return the rotate type.
    	*/
   	public int getRotateType(){
   		return m_rotateType;
   	}
  
   	/**
    	*   Set the rotate type.
    	*   @param rotateType  A new rotate type.
    	*/
   	public void setRotateType(int rotateType){
   		m_rotateType	=rotateType;
		writeConfigFile();
   	}



   	/**
    	*   fixed rotate angle
    	*   @return the rotate angle.
    	*/
   	public double getRotateAngle(){
   		return m_rotateAngle;
   	}
  
   	/**
    	*   Set the fixed rotate angle.
    	*   @param rotateAngle  A new rotate angle.
    	*/
   	public void setRotateAngle(double rotateAngle){
   		m_rotateAngle	=rotateAngle;
		writeConfigFile();
   	}
   	
   	
   	/**
    	*   get the global path for open and save files.
    	*   @return the global path.
    	*/
   	public String getGlobalPath(){

⌨️ 快捷键说明

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