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

📄 fontformatdialog.java

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

import java.awt.BorderLayout;
import java.awt.Frame;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Container;
import java.awt.Color;
import java.awt.GraphicsEnvironment;
import java.awt.Font;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.BorderFactory;

import javax.swing.JPanel;
import javax.swing.JButton;
import javax.swing.JScrollPane;
import javax.swing.JOptionPane;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JComboBox;
import javax.swing.ImageIcon;
import javax.swing.ListCellRenderer;
import javax.swing.JList;
import javax.swing.JColorChooser;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;

import com.jfimagine.jfgraph.shape.decorate.FontFormat;
import com.jfimagine.jfgraph.shape.decorate.FillFormat;
import com.jfimagine.jfgraph.shape.decorate.LineFormat;
import com.jfimagine.jfdraw.gui.ToolFactory;
import com.jfimagine.jfdraw.gui.resource.CADResource;   
import com.jfimagine.utils.commonutil.CommonUtil;
import com.jfimagine.jfdraw.gui.GUIConst;
import com.jfimagine.jfdraw.gui.GUIUtils;

import com.jfimagine.jfdraw.gui.GlobalSettings;


 /**
 * FontFormatDialog class.  A class used to get a new font format in gui by user.
 *
 * @author     CookieMaker    
 *
 * @version $Revision: 1.00 $
 */  
public class FontFormatDialog extends JDialog
                        implements ActionListener {


    public static String[] fontSizeAry; //= { "8", "9", "10", "12", "14", "18", "24", "36", "48", "64", "96" };
    static{
    	fontSizeAry	=new String[1000];
    	for (int i=1; i<1000; i++){
    		fontSizeAry[i-1]   =""+i;	
    	}
    }
    //Style defined in java.awt.Font: PLAIN=0, BOLD=1, ITALIC=2
    public static String[] fontStyleAry = { 
				CADResource.getString("label.font.fontstyle.plain"),
				CADResource.getString("label.font.fontstyle.bold"),
				CADResource.getString("label.font.fontstyle.italic"),
				CADResource.getString("label.font.fontstyle.bolditalic")
				};

    private static FontFormatDialog m_dialog;
    private static FontFormat m_fontFormat;

    private JComboBox fontSizeList;
    private JComboBox fontNameList;
    private JComboBox fontStyleList;
    private JButton   fontColorButton;  
    private Color  m_fontColor;

    private JCheckBox useStrokeAndFillCheck;
    private JButton   strokeLineButton;  
    private JButton   fillStyleButton;  
    

    public static String[] transparencyAry; 
    static{
    	transparencyAry	=new String[101];
    	for (int i=0; i<=100; i++){
    		transparencyAry[i]   =""+i;	
    	}
    }    
    private JComboBox transparencyList;
                               
    /**
     * Open an font format modifier window, to modify the font format.
     *
     * @param modalFrame  Determines which frame the dialog depends on; it should be
     * a component in the dialog's controlling frame. 
     *
     * @param fontFormat initial font format.
     * @return The font format.
     */
    public static FontFormat getNewFontFormat(Frame modalFrame,FontFormat fontFormat) {
    	return getNewFontFormat(modalFrame,null,fontFormat);
    }    

    /**
     * Open an font format modifier window, to modify the font format.
     *
     * @param modalFrame  Determines which frame the dialog depends on; it should be
     * a component in the dialog's controlling frame. 
     *
     * @param refComp  This should be null if you want the dialog
     * to come up with its left corner in the center of the screen;
     * otherwise, it should be the component on top of which the
     * dialog should appear.
     *
     * @param fontFormat initial font format.
     *
     * @return The font format.
     */
    public static FontFormat getNewFontFormat(Frame modalFrame,Component refComp,FontFormat fontFormat) {
    	return showDialog(modalFrame,refComp,fontFormat);
    }    


    /**
     * Set up and show the dialog.  The first Component argument
     * determines which frame the dialog depends on; it should be
     * a component in the dialog's controlling frame. The second
     * Component argument should be null if you want the dialog
     * to come up with its left corner in the center of the screen;
     * otherwise, it should be the component on top of which the
     * dialog should appear.
     */
    private static FontFormat showDialog(Component frameComp,
                                    Component locationComp,
                                    FontFormat fontFormat) {
        Frame frame = JOptionPane.getFrameForComponent(frameComp);
        m_dialog = new FontFormatDialog(frame,
                                locationComp,
                                CADResource.getString("dialog.fontFormat"),
                                fontFormat);
        m_dialog.setVisible(true);
        return m_fontFormat;
    }


    private FontFormatDialog(Frame frame,
                       Component locationComp,
                       String title,
                       FontFormat fontFormat) {
        super(frame, title, true);
	setResizable(false);
        
        //initiate initial font format and this font format.
        if (fontFormat==null)
                fontFormat      =new FontFormat();
        m_fontFormat  =new FontFormat();
        m_fontFormat.setValue(fontFormat);

         /****************************************
          * Create and initialize the buttons.
          ****************************************/
        JButton cancelButton = new JButton(CADResource.getString("button.cancel"));
        cancelButton.setFont(GUIConst.FONT_BUTTON);
        cancelButton.addActionListener(this);

        final JButton confirmButton = new JButton(CADResource.getString("button.confirm"));
        confirmButton.setFont(GUIConst.FONT_BUTTON);
        confirmButton.setActionCommand("Confirm");
        confirmButton.addActionListener(this);
        getRootPane().setDefaultButton(confirmButton);

        final JButton defaultButton = new JButton(CADResource.getString("button.defaultvalue"));
        defaultButton.setFont(GUIConst.FONT_BUTTON);
        defaultButton.setActionCommand("Default");
        defaultButton.addActionListener(this);

	
    	strokeLineButton	=new JButton(CADResource.getString("label.font.dialog.strokeLine"));  
        strokeLineButton.setFont(GUIConst.FONT_BUTTON);
        strokeLineButton.setActionCommand("StrokeLineSetup");
        strokeLineButton.addActionListener(this);

    	fillStyleButton	=new JButton(CADResource.getString("label.font.dialog.fillStyle"));  
        fillStyleButton.setFont(GUIConst.FONT_BUTTON);
        fillStyleButton.setActionCommand("FillStyleSetup");
        fillStyleButton.addActionListener(this);


        /************************************************
         *   font name,size,style and font color labels and combos.
         ************************************************/
        JLabel  nameLabel	=new JLabel(CADResource.getString("label.font.dialog.fontName"));
        nameLabel.setFont(GUIConst.FONT_LABEL);
        nameLabel.setPreferredSize(new Dimension(140, 32));

        JLabel  styleLabel	=new JLabel(CADResource.getString("label.font.dialog.fontStyle"));
        styleLabel.setFont(GUIConst.FONT_LABEL);
        styleLabel.setPreferredSize(new Dimension(140, 32));

        JLabel  sizeLabel	=new JLabel(CADResource.getString("label.font.dialog.fontSize"));
        sizeLabel.setFont(GUIConst.FONT_LABEL);
        sizeLabel.setPreferredSize(new Dimension(140, 32));

        JLabel  colorLabel	=new JLabel(CADResource.getString("label.font.dialog.fontColor"));
        colorLabel.setFont(GUIConst.FONT_LABEL);
        colorLabel.setPreferredSize(new Dimension(140, 32));

	//transparency
        transparencyList 	=new JComboBox(transparencyAry);
        transparencyList.setFont(GUIConst.FONT_DIALOG);
        transparencyList.setSelectedIndex(fontFormat.getTransparency());
        transparencyList.setMaximumRowCount(5);

⌨️ 快捷键说明

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