?? shapesettingdialog.java
字號:
return false;
}
}
if (ifOneDisabled)
return false;
else
return true;
}
//set disable modifying properties of objects in the list
private void setDisableModifyingProperties(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.setDisableModifyingProperties(disable);
}
}
//--------------disable motion-------------------------------------
//get disable motion of objects in the list
private boolean getDisableMotion(){
return getDisableMotion(m_list);
}
//get disable motion of objects in the list
public static boolean getDisableMotion(List l){
return getDisableMotion(l,false);
}
/**
* get disable motion of objects in the list
* @param ifOneDisabled True to check if any shape is disabled motion, False to check if all shape is disabled motion.
*/
public static boolean getDisableMotion(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.isDisableMotion())
return true;
}else if (!shape.isDisableMotion()){
return false;
}
}
if (ifOneDisabled)
return false;
else
return true;
}
//set disable motion of objects in the list
private void setDisableMotion(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.setDisableMotion(disable);
}
}
//--------------transparency-------------------------------------
//get transparency of objects in the list
private int getTransparency(){
return getTransparency(m_list);
}
/**
* get transparency of objects in the list
*/
public static int getTransparency(List l){
if (l==null || l.size()==0)
return 0;
try{
AbstractShape shape =(AbstractShape)l.get(0);
return shape.getTransparency();
}catch(Exception e){
return 0;
}
}
//set transparency of objects in the list
private void setTransparency(int transparency){
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.setTransparency(transparency);
}
}
//--------------Shape setting dialog-------------------------------------
private ShapeSettingDialog(Frame frame,
Component locationComp,
String title,
List list) {
super(frame, title, true);
setResizable(false);
m_list =list;
//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);
//main part of the dialog
hideShapeCheck =new JCheckBox(CADResource.getString("label.shapesetting.hideshape"));
hideShapeCheck.setFont(GUIConst.FONT_LABEL);
hideShapeCheck.setPreferredSize(new Dimension(200,30));
hideShapeCheck.setSelected(getInvisible());
disableScalingCheck =new JCheckBox(CADResource.getString("label.shapesetting.disablescaling"));
disableScalingCheck.setFont(GUIConst.FONT_LABEL);
disableScalingCheck.setPreferredSize(new Dimension(200,30));
disableScalingCheck.setSelected(getDisableScaling());
disableModifyingPropertiesCheck =new JCheckBox(CADResource.getString("label.shapesetting.disablemodifyingproperties"));
disableModifyingPropertiesCheck.setFont(GUIConst.FONT_LABEL);
disableModifyingPropertiesCheck.setPreferredSize(new Dimension(200,30));
disableModifyingPropertiesCheck.setSelected(getDisableModifyingProperties());
disableMotionCheck =new JCheckBox(CADResource.getString("label.shapesetting.disablemotion"));
disableMotionCheck.setFont(GUIConst.FONT_LABEL);
disableMotionCheck.setPreferredSize(new Dimension(200,30));
disableMotionCheck.setSelected(getDisableMotion());
//transparency
transparencyList =new JComboBox(transparencyAry);
transparencyList.setFont(GUIConst.FONT_DIALOG);
transparencyList.setSelectedIndex(getTransparency());
transparencyList.setMaximumRowCount(5);
transparencyList.setPreferredSize(new Dimension(80,32));
transparencyList.setMaximumSize(new Dimension(80,32));
transparencyList.setMinimumSize(new Dimension(80,32));
JLabel transparencyLabel =new JLabel(CADResource.getString("label.shapesetting.transparency"));
transparencyLabel.setFont(GUIConst.FONT_LABEL);
transparencyLabel.setPreferredSize(new Dimension(120, 32));
JLabel percentLabel =new JLabel("%");
percentLabel.setFont(GUIConst.FONT_LABEL);
percentLabel.setPreferredSize(new Dimension(20, 32));
JPanel transparencyPanel =new JPanel();
transparencyPanel.setLayout(new BoxLayout(transparencyPanel,BoxLayout.X_AXIS));
transparencyPanel.setBorder(BorderFactory.createEmptyBorder(0,0,0,0));
transparencyPanel.add(transparencyLabel);
transparencyPanel.add(Box.createRigidArea(new Dimension(5,0)));
transparencyPanel.add(transparencyList);
transparencyPanel.add(percentLabel);
transparencyPanel.setPreferredSize(new Dimension(200,32));
//add checkboxes to container.
JPanel container =new JPanel();
container.setLayout(new BoxLayout(container,BoxLayout.Y_AXIS));
container.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
JPanel hideShapePanel =new JPanel();
hideShapePanel.setBorder(BorderFactory.createEmptyBorder(0,0,0,0));
hideShapePanel.add(hideShapeCheck);
container.add(hideShapePanel);
container.add(Box.createRigidArea(new Dimension(0,5)));
JPanel disableScalingPanel =new JPanel();
disableScalingPanel.setBorder(BorderFactory.createEmptyBorder(0,0,0,0));
disableScalingPanel.add(disableScalingCheck);
container.add(disableScalingPanel);
container.add(Box.createRigidArea(new Dimension(0,5)));
JPanel disableModifyingPropertiesPanel =new JPanel();
disableModifyingPropertiesPanel.setBorder(BorderFactory.createEmptyBorder(0,0,0,0));
disableModifyingPropertiesPanel.add(disableModifyingPropertiesCheck);
container.add(disableModifyingPropertiesPanel);
container.add(Box.createRigidArea(new Dimension(0,5)));
JPanel disableMotionPanel =new JPanel();
disableMotionPanel.setBorder(BorderFactory.createEmptyBorder(0,0,0,0));
disableMotionPanel.add(disableMotionCheck);
container.add(disableMotionPanel);
container.add(Box.createRigidArea(new Dimension(0,5)));
container.add(transparencyPanel);
//Lay out the buttons from left to right.
JPanel buttonPane = new JPanel();
//buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS));
buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.X_AXIS));
buttonPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
//buttonPane.add(Box.createHorizontalGlue());
buttonPane.add(Box.createRigidArea(new Dimension(10, 0)));
buttonPane.add(confirmButton);
buttonPane.add(Box.createRigidArea(new Dimension(15, 0)));
buttonPane.add(cancelButton);
//Put everything together, using the content pane's BorderLayout.
Container contentPane = getContentPane();
contentPane.add(container, BorderLayout.CENTER);
contentPane.add(buttonPane, BorderLayout.SOUTH);
pack();
setLocationRelativeTo(locationComp);
}
//Handle clicks on the Set and Cancel buttons.
public void actionPerformed(ActionEvent e) {
if ("Confirm".equals(e.getActionCommand())) {
setInvisible(hideShapeCheck.isSelected());
setDisableScaling(disableScalingCheck.isSelected());
setDisableModifyingProperties(disableModifyingPropertiesCheck.isSelected());
setDisableMotion(disableMotionCheck.isSelected());
setTransparency(transparencyList.getSelectedIndex());
m_modified =true;
m_dialog.setVisible(false);
}else{
m_modified =false;
m_dialog.setVisible(false);
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -