?? shapesettingdialog.java
字號:
/**
* $Id:ShapeSettingDialog.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.event.ActionListener;
import java.awt.event.ActionEvent;
import java.util.Iterator;
import java.util.List;
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.JCheckBox;
import javax.swing.ImageIcon;
import javax.swing.ListCellRenderer;
import javax.swing.JList;
import javax.swing.JColorChooser;
import javax.swing.JComboBox;
import com.jfimagine.jfgraph.shape.base.AbstractShape;
import com.jfimagine.jfdraw.gui.ToolFactory;
import com.jfimagine.jfdraw.gui.resource.CADResource;
import com.jfimagine.jfdraw.gui.GUIConst;
/**
* ShapeSettingDialog class. A class is used to set the properties of a shape.
*
* @author CookieMaker
*
* @version $Revision: 1.1.1 $
*/
public class ShapeSettingDialog extends JDialog
implements ActionListener {
public static String[] transparencyAry;
static{
transparencyAry =new String[101];
for (int i=0; i<=100; i++){
transparencyAry[i] =""+i;
}
}
private static ShapeSettingDialog m_dialog;
private static List m_list;
private JCheckBox disableScalingCheck;
private JCheckBox disableModifyingPropertiesCheck;
private JCheckBox disableMotionCheck;
private JCheckBox hideShapeCheck;
private JComboBox transparencyList;
private static boolean m_modified =false;
/**
* Open an shape setting modifier window, to modify the line format.
*
* @param modalFrame Determines which frame the dialog depends on; it should be
* a component in the dialog's controlling frame.
*
* @param list A shape list to be modified
* @return True if modified shape, false otherwise.
*/
public static boolean newShapeSetting(Frame modalFrame,List list) {
return newShapeSetting(modalFrame,null,list);
}
/**
* Open an shape setting modifier window, to modify the line 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 list A shape list to be modified
*
* @return True if modified shape, false otherwise.
*/
public static boolean newShapeSetting(Frame modalFrame,Component refComp,List list) {
return showDialog(modalFrame,refComp,list);
}
/**
* 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 boolean showDialog(Component frameComp,
Component locationComp,
List list) {
Frame frame = JOptionPane.getFrameForComponent(frameComp);
m_dialog = new ShapeSettingDialog(frame,
locationComp,
CADResource.getString("dialog.shapesetting"),
list);
m_modified =false;
m_dialog.setVisible(true);
return m_modified;
}
//--------------hide shape-------------------------------------
//get if hide shape of objects in the list
private boolean getInvisible(){
return getInvisible(m_list);
}
//get hide shape of objects in the list
public static boolean getInvisible(List l){
return getInvisible(l,false);
}
/**
* get hide shape of objects in the list
* @param ifOneInvisible True to check if any shape is invisible, False to check if all shape is invisible.
*/
public static boolean getInvisible(List l,boolean ifOneInvisible){
if (l==null || l.size()==0)
return false;
Iterator it =l.iterator();
while (it!=null && it.hasNext()){
AbstractShape shape =(AbstractShape)it.next();
if (ifOneInvisible){
if (shape.isInvisible())
return true;
}else if (!shape.isInvisible()){
return false;
}
}
if (ifOneInvisible)
return false;
else
return true;
}
//set hide shape of objects in the list
private void setInvisible(boolean invisible){
if (m_list==null || m_list.size()==0)
return;
Iterator it =m_list.iterator();
while (it!=null && it.hasNext()){
AbstractShape shape =(AbstractShape)it.next();
shape.setInvisible(invisible);
}
}
//--------------disable scaling-------------------------------------
//get disable scaling of objects in the list
private boolean getDisableScaling(){
return getDisableScaling(m_list);
}
//get disable scaling of objects in the list
public static boolean getDisableScaling(List l){
return getDisableScaling(l,false);
}
/**
* get disable scaling of objects in the list
* @param ifOneDisabled True to check if any shape is disabled scaling, False to check if all shape is disabled scaling.
*/
public static boolean getDisableScaling(List l,boolean ifOneDisabled){
if (l==null || l.size()==0)
return false;
Iterator it =l.iterator();
while (it!=null && it.hasNext()){
AbstractShape shape =(AbstractShape)it.next();
if (ifOneDisabled){
if (shape.isDisableScaling())
return true;
}else if (!shape.isDisableScaling()){
return false;
}
}
if (ifOneDisabled)
return false;
else
return true;
}
//set disable scaling of objects in the list
private void setDisableScaling(boolean disable){
if (m_list==null || m_list.size()==0)
return;
Iterator it =m_list.iterator();
while (it!=null && it.hasNext()){
AbstractShape shape =(AbstractShape)it.next();
shape.setDisableScaling(disable);
}
}
//--------------disable modifying properties-------------------------------------
//get disable modifying properties of objects in the list
private boolean getDisableModifyingProperties(){
return getDisableModifyingProperties(m_list);
}
//get disable modifying properties of objects in the list
public static boolean getDisableModifyingProperties(List l){
return getDisableModifyingProperties(l,false);
}
/**
* get disable modifying properties of objects in the list
* @param ifOneDisabled True to check if any shape is disabled modifying properties, False to check if all shape is disabled modifying properties.
*/
public static boolean getDisableModifyingProperties(List l,boolean ifOneDisabled){
if (l==null || l.size()==0)
return false;
Iterator it =l.iterator();
while (it!=null && it.hasNext()){
AbstractShape shape =(AbstractShape)it.next();
if (ifOneDisabled){
if (shape.isDisableModifyingProperties())
return true;
}else if (!shape.isDisableModifyingProperties()){
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -