📄 plainoperator.java
字号:
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
* Created on 2006/09/01
*
* @Author: Xiaojun Chen
* $Revision$ 1.0
*
*/
package eti.bi.alphaminer.tools.ExportCase;
import java.awt.Dimension;
import java.awt.Rectangle;
import java.io.IOException;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextPane;
import javax.swing.text.Style;
import javax.swing.text.StyleConstants;
import eti.bi.alphaminer.operation.operator.INodeInfo;
import eti.bi.alphaminer.operation.operator.Operator;
import eti.bi.alphaminer.vo.Node;
import eti.bi.exception.SysException;
import eti.bi.util.ResourceLoader;
public class PlainOperator extends JPanel{
private static int m_TextAreaWidth = Operator.m_TextAreaWidth;
private static int m_TextAreaHeight = Operator.m_TextAreaHeight;
private static int m_Icon_Offset_X = Operator.m_Icon_Offset_X;
private static int IMAGE_WIDTH= Operator.IMAGE_WIDTH;
private static int IMAGE_HEIGHT= Operator.IMAGE_HEIGHT;
private static int ICON_HEIGHT= Operator.ICON_HEIGHT;
private static int INTERVAL_IMAGE_MODE = Operator.INTERVAL_IMAGE_MODE;
private static int ICON_TEXT_SPACE_OFFSET = Operator.ICON_TEXT_SPACE_OFFSET;
private static int FONT_SIZE = Operator.FONT_SIZE;
private static String FONT_FAMILY = Operator.FONT_FAMILY;
/**
*
*/
private static final long serialVersionUID = -5252221939982749739L;
private Node node;
private INodeInfo nodeInfo;
private JLabel m_OperatorImage;
private JTextPane m_OperatorLabel;
public PlainOperator(Node aNode,INodeInfo a_NodeInfo) throws Exception{
if(aNode==null||a_NodeInfo==null) {
if(aNode==null) {
throw new Exception("No node!");
}
throw new Exception("No node info for node: "+aNode.getNodeID()+"!");
}
node = aNode;
nodeInfo = a_NodeInfo;
createOperator();
setContent();
}
private void createOperator() {
m_OperatorImage = new JLabel();
m_OperatorImage.setMaximumSize(new Dimension(30, 30));
m_OperatorImage.setMinimumSize(new Dimension(30, 30));
m_OperatorImage.setPreferredSize(new Dimension(30, 30));
m_OperatorImage.setBounds(new Rectangle(20, 2, 30, 30));
m_OperatorLabel = new JTextPane();
m_OperatorLabel.setEditable(false);
m_OperatorLabel.setOpaque(false);
m_OperatorLabel.setFocusable(false);
Style style = m_OperatorLabel.addStyle("ParagraphStyle", null);
StyleConstants.setFontSize(style,FONT_SIZE);
StyleConstants.setAlignment(style, StyleConstants.ALIGN_CENTER);
StyleConstants.setFontFamily(style,FONT_FAMILY);
m_OperatorLabel.setParagraphAttributes(style,true);
m_OperatorLabel.setBounds(new Rectangle(0, ICON_HEIGHT-(INTERVAL_IMAGE_MODE+ICON_TEXT_SPACE_OFFSET), m_TextAreaWidth, m_TextAreaHeight));
m_OperatorImage.setBounds(new Rectangle(m_Icon_Offset_X+2, 2, IMAGE_HEIGHT, IMAGE_WIDTH));
setBounds((int)node.getPositionX(), (int)node.getPositionY(), m_TextAreaWidth, m_TextAreaHeight+ICON_HEIGHT);
setLayout(null);
setOpaque(false);
add(m_OperatorImage, null);
add(m_OperatorLabel, null);
}
private void setContent() {
ImageIcon imageIcon=null;
try {
imageIcon = ResourceLoader.getOperatorImageIcon(nodeInfo.getFlowImageFileName(),nodeInfo.getJafFile());
} catch (SysException e) {
//TODO Auto-generated catch block
System.err.println("Load image: "+nodeInfo.getFlowImageFileName()+" fail!");
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
m_OperatorImage.setIcon(imageIcon);
m_OperatorLabel.setText(node.getNodeDescription());
}
public Rectangle getIconBounds()
{
//Operator Bounds relative to the Case Diagram
Rectangle thisBound = this.getBounds();
// Image Icon bouds relative to this operator
Rectangle relativeIconBound = m_OperatorImage.getBounds();
// Image Icon bounds relative to the Case Diagram
Rectangle absoluteIconBound = new Rectangle(thisBound.x+relativeIconBound.x,
thisBound.y+relativeIconBound.y,
relativeIconBound.width,
relativeIconBound.height);
return absoluteIconBound;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -