📄 operator.java
字号:
// <<21/07/2005 Kenneth Lai: Add for JHelp
m_TransparentHelpButton.setBounds(new Rectangle(m_Icon_Offset_X+2, 2, IMAGE_HEIGHT, IMAGE_WIDTH));
// 21/07/2005 Kenneth Lai: Add for JHelp>>
m_OperatorLabel.setBounds(new Rectangle(0, ICON_HEIGHT-(INTERVAL_IMAGE_MODE+ICON_TEXT_SPACE_OFFSET), m_TextAreaWidth, m_TextAreaHeight));
m_DropEventPanel.setBounds(new Rectangle(0, ICON_HEIGHT-(INTERVAL_IMAGE_MODE+ICON_TEXT_SPACE_OFFSET), m_TextAreaWidth, m_TextAreaHeight));
// These setBorder are used for debug purpose
//m_ModePanel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
//m_OperatorLabel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
//m_DropEventPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
//this.setBorder(BorderFactory.createLineBorder(Color.BLACK));
this.setLayout(null);
this.setOpaque(false);
this.add(m_ModePanel, null);
// ** m_DropEventPanel have to be added before OperatorLabel so as to catch the drop event
this.add(m_DropEventPanel, null);
this.add(m_OperatorLabel, null);
this.add(m_OperatorImage, null);
// <<21/07/2005 Kenneth Lai: Add for JHelp
this.add(m_TransparentHelpButton, null);
// 21/07/2005 Kenneth Lai: Add for JHelp>>
// setOperatorBounds(this.getLocation());
//m_Label.addMouseListener(this);
//m_Label.addKeyListener(this);
}
abstract public boolean hasResult() throws SysException;
public void loadTempOutputData() throws SysException
{
if (m_OutputBIObject!=null)
{
if (m_OutputBIObject.getBIData()!=null)
{
m_OutputBIObject.getBIData().loadTempBIData();
}
if (m_OutputBIObject.getBIModel()!=null)
{
m_OutputBIObject.getBIModel().loadTempBIModel();
}
}
}
/* public void clearDependentParameters(){
System.out.println("clear dependent parameters: " + m_NodeID);
try
{
Vector childs = CaseHandler.getChildOperators(m_CaseID, m_NodeID);
if (childs==null)
return;
Operator op = null;
for (int i=0; i<childs.size(); i++)
{
op = ((CaseDiagramPanel) m_CaseWindow.getDiagramDrawingPanel()).getOperator((String) children.elementAt(i));
op.clearDependentParameters();
}
}
catch (BaseException be)
{
System.out.println(be.getMessage());
}
}
*/
public void clearResult()
{
//clearMode();
if (m_OutputBIObject!=null)
{
m_OutputBIObject.clear();
}
try
{
Vector children = m_CaseHandler.getChildOperators(m_CaseID,m_NodeID);
if (children==null)
return;
Operator op = null;
for (int i=0; i<children.size(); i++)
{
op = (Operator)children.elementAt(i);
op.clearResult();
}
}
catch (BaseException be)
{
System.out.println(be.getMessage());
}
}
public void clearInput()
{
clearMode();
if (m_InputBIObject != null)
{
for(int i=0; i<m_InputBIObject.length; i++){
if(m_InputBIObject[i] != null)
m_InputBIObject[i].clear();
}
}
}
abstract public void execute(IOperatorNode a_OperatorNode, Vector<Operator> a_Parents) throws SysException, AppException, MiningException;
/**
* Display parameters of MiningAlgorithmSpecification.
*
* @param miningAlgorithmSpecification MiningAlgorithmSpefification whose parameters are displayed
* @throws MiningException could not display parameters
*/
public void displayMiningAlgSpecParameters(MiningAlgorithmSpecification miningAlgorithmSpecification) throws MiningException
{
String show = "";
MiningAlgorithmParameter[] attribute = miningAlgorithmSpecification.getInputAttribute();
if( attribute.length > 0 )
{
m_SystemMessageHandler.appendMessage(Resource.srcStr("AlgorithmMessage") + miningAlgorithmSpecification.getName());
}
String name, desc, method, type, value;
for (int i = 0; i < attribute.length; i++)
{
name = attribute[i].getName();
desc = attribute[i].getDescr();
method = attribute[i].getMethod();
type = attribute[i].getType();
value = attribute[i].getValue();
show = show + Resource.srcStr("Name")+" = " + name + "; " + Resource.srcStr("Descr")+" = " + desc + "; " + Resource.srcStr("Method")+" = " + method + "; " + Resource.srcStr("Value")+" = " + value + "; "+Resource.srcStr("Type")+" = " + type + "\n";
}
m_SystemMessageHandler.appendMessage(show);
}
public IBIObject getOutputBIObject()
{
return m_OutputBIObject;
}
public void setInputBIObject(IBIObject aMiningObject)
{
// Default int setting to the first InputBIObject
m_InputBIObject[0] = aMiningObject;
}
public IBIObject getInputBIObject()
{
// Default in getting the first InputBIObject
return m_InputBIObject[0];
}
/*
public String getExpectedDataSourceName()
{
}*/
public void setInputBIObject(IBIObject a_MiningObject, int a_Num) throws AppException
{
if (a_Num <0 || a_Num > MAX_PARENT)
{
throw new AppException("Too much input objects. Check if too much nodes are connected.");
}
// Default int setting to the first InputBIObject
m_InputBIObject[a_Num] = a_MiningObject;
}
protected IBIObject getInputBIObject(int a_Num) throws AppException
{
if (a_Num <0 || a_Num > MAX_PARENT)
{
throw new AppException("Too much input objects. Check if too much nodes are connected.");
}
return m_InputBIObject[a_Num];
}
protected void setOutputBIObject(IBIObject aMiningObject)
{
m_OutputBIObject = aMiningObject;
}
public void writeTempFile() throws SysException {
IOperatorNode operatorNode = m_CaseHandler.getOperatorNode(m_CaseID, m_NodeID);
IBIData aOutputBIData = getOutputBIObject().getBIData();
if(haschanged) {
operatorNode.setParameterValue("Temporary data", aOutputBIData.getTempBIDataPath());
aOutputBIData.writeTempBIData();
haschanged = false;
}
else {
String tempFilePath = operatorNode.getParameterValue("Temporary data");
if(tempFilePath==null) {
operatorNode.setParameterValue("Temporary data", aOutputBIData.getTempBIDataPath());
tempFilePath = operatorNode.getParameterValue("Temporary data");
}
File tempFile = new File(tempFilePath);
if(!tempFile.exists()) {
aOutputBIData.writeTempBIData();
}
}
}
public void writeTempModelFile() throws SysException {
IOperatorNode operatorNode = m_CaseHandler.getOperatorNode(m_CaseID, m_NodeID);
IBIModel aOutputBIModel = getOutputBIObject().getBIModel();
if(haschanged) {
operatorNode.setParameterValue("Temporary model", aOutputBIModel.getTempBIModelPath());
aOutputBIModel.writeTempBIModel();
haschanged = false;
}
else {
String tempFilePath = operatorNode.getParameterValue("Temporary model");
if(tempFilePath==null) {
operatorNode.setParameterValue("Temporary model", aOutputBIModel.getTempBIModelPath());
tempFilePath = operatorNode.getParameterValue("emporary model");
}
File tempFile = new File(tempFilePath);
if(!tempFile.exists()) {
aOutputBIModel.writeTempBIModel();
}
}
}
/*
* Method to check if the operator accept the other opeartor as the parent.
* Return true if accept, otherwise, return false;
*/
public boolean acceptParent(Operator a_Operator) throws SysException
{
return true;
}
/*
* Method to check if the operator accept the other opeartor as the child.
* Return true if accept, otherwise, return false;
*/
public boolean acceptChild(Operator a_Operator) throws SysException
{
return true;
}
/*
* Method to check if the operator is read to execute. It mainly checks
* the number of parents is enough or not.
* Noted that it assume the type of the parents are correct.
*/
public boolean readyExecute() throws SysException
{
int numParents = m_CaseHandler.getNumParents(m_CaseID, m_NodeID);
IOperatorNode thisNode = m_CaseHandler.getOperatorNode(m_CaseID, m_NodeID);
if (thisNode == null)
{
throw new SysException("Invalid Node Handle.");
}
return (numParents>=thisNode.getMinNumParent());
}
/* (non-Javadoc)
* @see java.awt.dnd.DropTargetListener#dragEnter(java.awt.dnd.DropTargetDragEvent)
*/
public void dragEnter(DropTargetDragEvent arg0) {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see java.awt.dnd.DropTargetListener#dragOver(java.awt.dnd.DropTargetDragEvent)
*/
public void dragOver(DropTargetDragEvent arg0) {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see java.awt.dnd.DropTargetListener#dropActionChanged(java.awt.dnd.DropTargetDragEvent)
*/
public void dropActionChanged(DropTargetDragEvent arg0) {
// TODO Auto-generated method stub
}
/**
* To catch the drop event with the operator label as drop target
* @see java.awt.dnd.DropTargetListener#drop(java.awt.dnd.DropTargetDropEvent)
**/
public void drop(DropTargetDropEvent a_DropEvent) {
// Get the dropping point relative to the operator label
Point dropPoint = a_DropEvent.getLocation();
// Adjust the dropping point in relative to the case diagram
Point operatorPoint = this.getLocation();
Point labelPoint = m_OperatorLabel.getLocation();
Point adjustedPoint = new Point();
// Caculate the adjusted point adding the operator location, operator label location and drop location
adjustedPoint.setLocation(operatorPoint.getX()+labelPoint.getX()+dropPoint.getX(), operatorPoint.getY()+labelPoint.getY()+dropPoint.getY());
ICaseDiagram thisCaseDiagramPanel = m_CaseHandler.getCaseDiagram(m_CaseID);
try {
//Invoke CaseDiagramPanel drop() and pass the drop event, adjusted dropping point
thisCaseDiagramPanel.drop(a_DropEvent, adjustedPoint);
} catch (SysException e) {
e.printStackTrace();
}
}
/* (non-Javadoc)
* @see java.awt.dnd.DropTargetListener#dragExit(java.awt.dnd.DropTargetEvent)
*/
public void dragExit(DropTargetEvent arg0) {
// TODO Auto-generated method stub
}
/**
* @return Returns the m_OperatorDefinitionID.
*/
public String getOperatorDefinitionID() {
return m_OperatorDefinitionID;
}
public INodeInfo getNodeInfo(){
return m_NodeInfo;
}
//2006/07/29 Xiaojun Chen
public Vector getParentOperators() throws SysException{
return m_CaseHandler.getParentOperators(m_CaseID,
m_NodeID);
}
/**
* @param operatorDefinitionID The m_OperatorDefinitionID to set.
*/
public void setOperatorDefinitionID(String operatorDefinitionID) {
m_OperatorDefinitionID = operatorDefinitionID;
}
// << 22/07/2005 Kenneth Lai: Added for JHelp
public void Update(boolean a_HelpState) {
setHelpMode(a_HelpState);
}
/**
* Sets the help state of this operator.
* @param a_HelpState help state.
*/
private void setHelpState(boolean a_HelpState) {
m_HelpState = a_HelpState;
}
public void setHelpMode(boolean a_HelpState) {
setHelpState(a_HelpState);
m_TransparentHelpButton.setVisible(a_HelpState);
m_TransparentHelpButton.setEnabled(a_HelpState);
}
/**
*
* */
public void setProcessModel(OperatorProgressModel processModel){
this.processModel = processModel;
}
public OperatorProgressModel getProcessModel(){
return processModel;
}
public void resetLocale(INodeInfo nodeInfo) {
String appendDescription = null;
String Description = getDescription();
if(this instanceof InputOperator){
int index = Description.indexOf('[');
if(index>=0){
appendDescription =Resource.srcStr("InputFileTitle") + Description.substring(index);
}
else{
appendDescription = Resource.srcStr("InputFileTitle");
}
}
else{
appendDescription = Description.replaceAll(m_NodeInfo.getDisplayName(), nodeInfo.getDisplayName());
}
m_NodeInfo = nodeInfo;
setDescription(appendDescription);
//setOperatorImage(m_OperatorInfo.getFlowImageFileName(),m_OperatorInfo.getJafFile());
//m_OperatorLabel.setText(getDescription());
this.repaint();
}
/**
* respond dispose event
* */
public void dispose() {
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -