/projects/weka-3-6-9/weka-src/src/main/java/weka/gui/beans/KnowledgeFlowApp.java
Java | 1395 lines | 975 code | 154 blank | 266 comment | 160 complexity | 887968fe9ff4c6bd0dab424804d87142 MD5 | raw file
- /*
- * 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.
- */
- /*
- * KnowledgeFlowApp.java
- * Copyright (C) 2005 University of Waikato, Hamilton, New Zealand
- *
- */
- package weka.gui.beans;
- import java.awt.BorderLayout;
- import java.awt.Cursor;
- import java.awt.Dimension;
- import java.awt.Font;
- import java.awt.FontMetrics;
- import java.awt.Graphics;
- import java.awt.Graphics2D;
- import java.awt.GridLayout;
- import java.awt.Image;
- import java.awt.MenuItem;
- import java.awt.Point;
- import java.awt.PopupMenu;
- import java.awt.Rectangle;
- import java.awt.Toolkit;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.awt.event.InputEvent;
- import java.awt.event.MouseAdapter;
- import java.awt.event.MouseEvent;
- import java.awt.event.MouseMotionAdapter;
- import java.awt.image.BufferedImage;
- import java.beans.BeanInfo;
- import java.beans.Beans;
- import java.beans.Customizer;
- import java.beans.EventSetDescriptor;
- import java.beans.IntrospectionException;
- import java.beans.Introspector;
- import java.beans.MethodDescriptor;
- import java.beans.PropertyChangeEvent;
- import java.beans.PropertyChangeListener;
- import java.beans.beancontext.BeanContextChild;
- import java.beans.beancontext.BeanContextSupport;
- import java.io.BufferedWriter;
- import java.io.File;
- import java.io.FileInputStream;
- import java.io.FileOutputStream;
- import java.io.IOException;
- import java.io.InputStream;
- import java.io.InputStreamReader;
- import java.io.LineNumberReader;
- import java.io.ObjectInputStream;
- import java.io.ObjectOutputStream;
- import java.io.OutputStream;
- import java.io.OutputStreamWriter;
- import java.lang.reflect.Method;
- import java.text.SimpleDateFormat;
- import java.util.ArrayList;
- import java.util.Date;
- import java.util.Enumeration;
- import java.util.Hashtable;
- import java.util.Iterator;
- import java.util.Properties;
- import java.util.StringTokenizer;
- import java.util.TreeMap;
- import java.util.Vector;
- import javax.swing.Box;
- import javax.swing.ButtonGroup;
- import javax.swing.ImageIcon;
- import javax.swing.JButton;
- import javax.swing.JComponent;
- import javax.swing.JFileChooser;
- import javax.swing.JFrame;
- import javax.swing.JLabel;
- import javax.swing.JOptionPane;
- import javax.swing.JPanel;
- import javax.swing.JScrollPane;
- import javax.swing.JTabbedPane;
- import javax.swing.JTextArea;
- import javax.swing.JToggleButton;
- import javax.swing.JToolBar;
- import javax.swing.JWindow;
- import javax.swing.filechooser.FileFilter;
- import weka.core.ClassloaderUtil;
- import weka.core.Copyright;
- import weka.core.Environment;
- import weka.core.EnvironmentHandler;
- import weka.core.Memory;
- import weka.core.SerializedObject;
- import weka.core.Utils;
- import weka.core.xml.KOML;
- import weka.core.xml.XStream;
- import weka.gui.ExtensionFileFilter;
- import weka.gui.GenericObjectEditor;
- import weka.gui.GenericPropertiesCreator;
- import weka.gui.HierarchyPropertyParser;
- import weka.gui.LookAndFeel;
- import weka.gui.beans.xml.XMLBeans;
- import weka.gui.visualize.PrintablePanel;
- /**
- * Main GUI class for the KnowledgeFlow. Modifications to allow interoperability
- * with swt provided by Davide Zerbetto (davide dot zerbetto at eng dot it).
- *
- * @author Mark Hall
- * @version $Revision: 9495 $
- * @since 1.0
- * @see JPanel
- * @see PropertyChangeListener
- */
- public class KnowledgeFlowApp extends JPanel implements PropertyChangeListener {
- /** for serialization */
- private static final long serialVersionUID = -7064906770289728431L;
- /**
- * Location of the property file for the KnowledgeFlowApp
- */
- protected static String PROPERTY_FILE = "weka/gui/beans/Beans.props";
- /** Contains the editor properties */
- protected static Properties BEAN_PROPERTIES;
- private static ArrayList<Properties> BEAN_PLUGINS_PROPERTIES;
- /**
- * Holds the details needed to construct button bars for various supported
- * classes of weka algorithms/tools
- */
- private static Vector TOOLBARS = new Vector();
- /**
- * Loads KnowledgeFlow properties and any plugins (adds jars to the classpath)
- */
- public static void loadProperties() {
- if (BEAN_PROPERTIES == null) {
- System.out.println(Messages.getInstance().getString(
- "KnowledgeFlowApp_LoadProperties_Text_First"));
- /** Loads the configuration property file */
- // static {
- // Allow a properties file in the current directory to override
- try {
- BEAN_PROPERTIES = Utils.readProperties(PROPERTY_FILE);
- java.util.Enumeration keys = BEAN_PROPERTIES.propertyNames();
- if (!keys.hasMoreElements()) {
- throw new Exception(Messages.getInstance().getString(
- "KnowledgeFlowApp_LoadProperties_Exception_Text_First")
- + Messages.getInstance().getString(
- "KnowledgeFlowApp_LoadProperties_Exception_Text_Second")
- + PROPERTY_FILE
- + Messages.getInstance().getString(
- "KnowledgeFlowApp_LoadProperties_Exception_Text_Third")
- + System.getProperties().getProperty("user.home")
- + Messages.getInstance().getString(
- "KnowledgeFlowApp_LoadProperties_Exception_Text_Fourth"));
- }
- } catch (Exception ex) {
- JOptionPane
- .showMessageDialog(
- null,
- ex.getMessage(),
- Messages
- .getInstance()
- .getString(
- "KnowledgeFlowApp_LoadProperties_Exception_JOptionPaneShowMessageDialog_Text"),
- JOptionPane.ERROR_MESSAGE);
- }
- // try and load any plugin beans properties
- File pluginDir = new File(System.getProperty("user.home")
- + File.separator + ".knowledgeFlow" + File.separator + "plugins");
- if (pluginDir.exists() && pluginDir.isDirectory()) {
- BEAN_PLUGINS_PROPERTIES = new ArrayList<Properties>();
- // How many sub-dirs are there?
- File[] contents = pluginDir.listFiles();
- for (int i = 0; i < contents.length; i++) {
- if (contents[i].isDirectory() && contents[i].listFiles().length > 0) {
- try {
- Properties tempP = new Properties();
- File propFile = new File(contents[i].getPath() + File.separator
- + "Beans.props");
- tempP.load(new FileInputStream(propFile));
- BEAN_PLUGINS_PROPERTIES.add(tempP);
- // Now try and add all jar files in this directory to the
- // classpath
- File anyJars[] = contents[i].listFiles();
- for (int j = 0; j < anyJars.length; j++) {
- if (anyJars[j].getPath().endsWith(".jar")) {
- System.out.println(Messages.getInstance().getString(
- "KnowledgeFlowApp_LoadProperties_Text_Second")
- + anyJars[j].getPath()
- + Messages.getInstance().getString(
- "KnowledgeFlowApp_LoadProperties_Text_Third"));
- ClassloaderUtil.addFile(anyJars[j].getPath());
- }
- }
- } catch (Exception ex) {
- // Don't make a fuss
- System.err.println(Messages.getInstance().getString(
- "KnowledgeFlowApp_LoadProperties_Error_Text_First")
- + contents[i].getPath());
- }
- }
- // BEAN_PLUGINS_PROPERTIES = new Properties();
- // BEAN_PLUGINS_PROPERTIES.load(new FileInputStream(pluginDir));
- }
- } else {
- // make the plugin directory for the user
- pluginDir.mkdir();
- }
- }
- }
- /**
- * Initializes the temporary files necessary to construct the toolbars from.
- */
- private static void init() {
- System.out.println(Messages.getInstance().getString(
- "KnowledgeFlowApp_Init_Text_First"));
- try {
- TreeMap wrapList = new TreeMap();
- GenericPropertiesCreator creator = new GenericPropertiesCreator();
- Properties GEOProps = null;
- if (creator.useDynamic()) {
- creator.execute(false);
- /*
- * now process the keys in the GenericObjectEditor.props. For each key
- * that has an entry in the Beans.props associating it with a bean
- * component a button tool bar will be created
- */
- GEOProps = creator.getOutputProperties();
- } else {
- // Read the static information from the GenericObjectEditor.props
- GEOProps = Utils.readProperties("weka/gui/GenericObjectEditor.props");
- }
- Enumeration en = GEOProps.propertyNames();
- while (en.hasMoreElements()) {
- String geoKey = (String) en.nextElement();
- // try to match this key with one in the Beans.props file
- String beanCompName = BEAN_PROPERTIES.getProperty(geoKey);
- if (beanCompName != null) {
- // add details necessary to construct a button bar for this class
- // of algorithms
- Vector newV = new Vector();
- // check for a naming alias for this toolbar
- String toolBarNameAlias = BEAN_PROPERTIES.getProperty(geoKey
- + ".alias");
- String toolBarName = (toolBarNameAlias != null) ? toolBarNameAlias
- : geoKey.substring(geoKey.lastIndexOf('.') + 1, geoKey.length());
- // look for toolbar ordering information for this wrapper type
- String order = BEAN_PROPERTIES.getProperty(geoKey + ".order");
- Integer intOrder = (order != null) ? new Integer(order)
- : new Integer(0);
- // Name for the toolbar (name of weka algorithm class)
- newV.addElement(toolBarName);
- // Name of bean capable of handling this class of algorithm
- newV.addElement(beanCompName);
- // add the root package for this key
- String rootPackage = geoKey.substring(0, geoKey.lastIndexOf('.'));
- newV.addElement(rootPackage);
- // All the weka algorithms of this class of algorithm
- String wekaAlgs = GEOProps.getProperty(geoKey);
- Hashtable roots = GenericObjectEditor.sortClassesByRoot(wekaAlgs);
- Hashtable hpps = new Hashtable();
- Enumeration enm = roots.keys();
- while (enm.hasMoreElements()) {
- String root = (String) enm.nextElement();
- String classes = (String) roots.get(root);
- weka.gui.HierarchyPropertyParser hpp = new weka.gui.HierarchyPropertyParser();
- hpp.build(classes, ", ");
- // System.err.println(hpp.showTree());
- hpps.put(root, hpp);
- }
- // ------ test the HierarchyPropertyParser
- /*
- * weka.gui.HierarchyPropertyParser hpp = new
- * weka.gui.HierarchyPropertyParser(); hpp.build(wekaAlgs, ", ");
- *
- * System.err.println(hpp.showTree());
- */
- // ----- end test the HierarchyPropertyParser
- // newV.addElement(hpp); // add the hierarchical property parser
- newV.addElement(hpps); // add the hierarchical property parser
- StringTokenizer st = new StringTokenizer(wekaAlgs, ", ");
- while (st.hasMoreTokens()) {
- String current = st.nextToken().trim();
- newV.addElement(current);
- }
- wrapList.put(intOrder, newV);
- // TOOLBARS.addElement(newV);
- }
- }
- Iterator keysetIt = wrapList.keySet().iterator();
- while (keysetIt.hasNext()) {
- Integer key = (Integer) keysetIt.next();
- Vector newV = (Vector) wrapList.get(key);
- if (newV != null) {
- TOOLBARS.addElement(newV);
- }
- }
- } catch (Exception ex) {
- JOptionPane
- .showMessageDialog(
- null,
- Messages
- .getInstance()
- .getString(
- "KnowledgeFlowApp_Init_Exception_JOptionPaneShowMessageDialog_Text_First")
- + System.getProperties().getProperty("user.home")
- + Messages
- .getInstance()
- .getString(
- "KnowledgeFlowApp_Init_Exception_JOptionPaneShowMessageDialog_Text_Second"),
- Messages
- .getInstance()
- .getString(
- "KnowledgeFlowApp_Init_Exception_JOptionPaneShowMessageDialog_Text_Third"),
- JOptionPane.ERROR_MESSAGE);
- }
- try {
- String standardToolBarNames = BEAN_PROPERTIES
- .getProperty("weka.gui.beans.KnowledgeFlow.standardToolBars");
- StringTokenizer st = new StringTokenizer(standardToolBarNames, ", ");
- while (st.hasMoreTokens()) {
- String tempBarName = st.nextToken().trim();
- // construct details for this toolbar
- Vector newV = new Vector();
- // add the name of the toolbar
- newV.addElement(tempBarName);
- // indicate that this is a standard toolbar (no wrapper bean)
- newV.addElement("null");
- String toolBarContents = BEAN_PROPERTIES
- .getProperty("weka.gui.beans.KnowledgeFlow." + tempBarName);
- StringTokenizer st2 = new StringTokenizer(toolBarContents, ", ");
- while (st2.hasMoreTokens()) {
- String tempBeanName = st2.nextToken().trim();
- newV.addElement(tempBeanName);
- }
- TOOLBARS.addElement(newV);
- }
- } catch (Exception ex) {
- JOptionPane
- .showMessageDialog(
- null,
- ex.getMessage(),
- Messages
- .getInstance()
- .getString(
- "KnowledgeFlowApp_Init_Exception_JOptionPaneShowMessageDialog_Text_Fourth"),
- JOptionPane.ERROR_MESSAGE);
- }
- }
- /**
- * Used for displaying the bean components and their visible connections
- *
- * @author <a href="mailto:mhall@cs.waikato.ac.nz">Mark Hall</a>
- * @version $Revision: 9495 $
- * @since 1.0
- * @see PrintablePanel
- */
- protected class BeanLayout extends PrintablePanel {
- /** for serialization */
- private static final long serialVersionUID = -146377012429662757L;
- @Override
- public void paintComponent(Graphics gx) {
- super.paintComponent(gx);
- BeanInstance.paintLabels(gx);
- BeanConnection.paintConnections(gx);
- // BeanInstance.paintConnections(gx);
- if (m_mode == CONNECTING) {
- gx.drawLine(m_startX, m_startY, m_oldX, m_oldY);
- } else if (m_mode == SELECTING) {
- gx.drawRect((m_startX < m_oldX) ? m_startX : m_oldX,
- (m_startY < m_oldY) ? m_startY : m_oldY,
- Math.abs(m_oldX - m_startX), Math.abs(m_oldY - m_startY));
- }
- }
- @Override
- public void doLayout() {
- super.doLayout();
- Vector comps = BeanInstance.getBeanInstances();
- for (int i = 0; i < comps.size(); i++) {
- BeanInstance bi = (BeanInstance) comps.elementAt(i);
- JComponent c = (JComponent) bi.getBean();
- Dimension d = c.getPreferredSize();
- c.setBounds(bi.getX(), bi.getY(), d.width, d.height);
- c.revalidate();
- }
- }
- }
- // Used for measuring and splitting icon labels
- // over multiple lines
- FontMetrics m_fontM;
- // constants for operations in progress
- protected static final int NONE = 0;
- protected static final int MOVING = 1;
- protected static final int CONNECTING = 2;
- protected static final int ADDING = 3;
- protected static final int SELECTING = 4;
- // which operation is in progress
- private int m_mode = NONE;
- /** the extension for the user components, when serialized to XML */
- protected final static String USERCOMPONENTS_XML_EXTENSION = ".xml";
- /**
- * Button group to manage all toolbar buttons
- */
- private final ButtonGroup m_toolBarGroup = new ButtonGroup();
- /**
- * Holds the selected toolbar bean
- */
- private Object m_toolBarBean;
- /**
- * The layout area
- */
- private final BeanLayout m_beanLayout = new BeanLayout();
- /**
- * Tabbed pane to hold tool bars
- */
- private final JTabbedPane m_toolBars = new JTabbedPane();
- /**
- * Stuff relating to plugin beans
- */
- private JToolBar m_pluginsToolBar = null;
- private Box m_pluginsBoxPanel = null;
- /**
- * Stuff relating to user created meta beans
- */
- private JToolBar m_userToolBar = null;
- private Box m_userBoxPanel = null;
- private final Vector m_userComponents = new Vector();
- private boolean m_firstUserComponentOpp = true;
- private JToggleButton m_pointerB;
- private JButton m_saveB;
- private JButton m_loadB;
- private JButton m_stopB;
- private JButton m_helpB;
- private JButton m_newB;
- /**
- * Reference to bean being manipulated
- */
- private BeanInstance m_editElement;
- /**
- * Event set descriptor for the bean being manipulated
- */
- private EventSetDescriptor m_sourceEventSetDescriptor;
- /**
- * Used to record screen coordinates during move, select and connect
- * operations
- */
- private int m_oldX, m_oldY;
- private int m_startX, m_startY;
- /** The file chooser for selecting layout files */
- protected JFileChooser m_FileChooser = new JFileChooser(new File(
- System.getProperty("user.dir")));
- protected LogPanel m_logPanel = new LogPanel();// new LogPanel(null, true);
- protected BeanContextSupport m_bcSupport = new BeanContextSupport();
- /** the extension for the serialized setups (Java serialization) */
- public final static String FILE_EXTENSION = ".kf";
- /** the extension for the serialized setups (Java serialization) */
- public final static String FILE_EXTENSION_XML = ".kfml";
- /**
- * A filter to ensure only KnowledgeFlow files in binary format get shown in
- * the chooser
- */
- protected FileFilter m_KfFilter = new ExtensionFileFilter(FILE_EXTENSION,
- Messages.getInstance().getString("KnowledgeFlowApp_KfFilter_Text_First")
- + FILE_EXTENSION
- + Messages.getInstance().getString(
- "KnowledgeFlowApp_KfFilter_Text_Second"));
- /**
- * A filter to ensure only KnowledgeFlow files in KOML format get shown in the
- * chooser
- */
- protected FileFilter m_KOMLFilter = new ExtensionFileFilter(
- KOML.FILE_EXTENSION + "kf", Messages.getInstance().getString(
- "KnowledgeFlowApp_KOMLFilter_Text_Second")
- + KOML.FILE_EXTENSION
- + Messages.getInstance().getString(
- "KnowledgeFlowApp_KOMLFilter_Text_Third"));
- /**
- * A filter to ensure only KnowledgeFlow files in XStream format get shown in
- * the chooser
- */
- protected FileFilter m_XStreamFilter = new ExtensionFileFilter(
- XStream.FILE_EXTENSION + "kf", Messages.getInstance().getString(
- "KnowledgeFlowApp_XStreamFilter_Text_Second")
- + XStream.FILE_EXTENSION
- + Messages.getInstance().getString(
- "KnowledgeFlowApp_XStreamFilter_Text_Third"));
- /**
- * A filter to ensure only KnowledgeFlow layout files in XML format get shown
- * in the chooser
- */
- protected FileFilter m_XMLFilter = new ExtensionFileFilter(
- FILE_EXTENSION_XML, Messages.getInstance().getString(
- "KnowledgeFlowApp_XMLFilter_Text_First")
- + FILE_EXTENSION_XML
- + Messages.getInstance().getString(
- "KnowledgeFlowApp_XMLFilter_Text_Second"));
- /** the scrollbar increment of the layout scrollpane */
- protected int m_ScrollBarIncrementLayout = 20;
- /** the scrollbar increment of the components scrollpane */
- protected int m_ScrollBarIncrementComponents = 50;
- /** the flow layout width */
- protected int m_FlowWidth = 1024;
- /** the flow layout height */
- protected int m_FlowHeight = 768;
- /** the preferred file extension */
- protected String m_PreferredExtension = FILE_EXTENSION;
- /** whether to store the user components in XML or in binary format */
- protected boolean m_UserComponentsInXML = false;
- /** Environment variables for the current flow */
- protected Environment m_flowEnvironment = new Environment();
- /**
- * Set the environment variables to use. NOTE: loading a new layout resets
- * back to the default set of variables
- *
- * @param env
- */
- public void setEnvironment(Environment env) {
- m_flowEnvironment = env;
- setEnvironment();
- }
- private void setEnvironment() {
- // pass m_flowEnvironment to all components
- // that implement EnvironmentHandler
- Vector beans = BeanInstance.getBeanInstances();
- for (int i = 0; i < beans.size(); i++) {
- Object temp = ((BeanInstance) beans.elementAt(i)).getBean();
- if (temp instanceof EnvironmentHandler) {
- ((EnvironmentHandler) temp).setEnvironment(m_flowEnvironment);
- }
- }
- }
- /**
- * Creates a new <code>KnowledgeFlowApp</code> instance.
- */
- // modifications by Zerbetto
- // public KnowledgeFlowApp() {
- public KnowledgeFlowApp(boolean showFileMenu) {
- if (BEAN_PROPERTIES == null) {
- loadProperties();
- init();
- }
- m_showFileMenu = showFileMenu;
- // end modifications by Zerbetto
- // Grab a fontmetrics object
- JWindow temp = new JWindow();
- temp.setVisible(true);
- temp.getGraphics().setFont(new Font(null, Font.PLAIN, 9));
- m_fontM = temp.getGraphics().getFontMetrics();
- temp.setVisible(false);
- // some GUI defaults
- try {
- m_ScrollBarIncrementLayout = Integer.parseInt(BEAN_PROPERTIES
- .getProperty("ScrollBarIncrementLayout", ""
- + m_ScrollBarIncrementLayout));
- m_ScrollBarIncrementComponents = Integer.parseInt(BEAN_PROPERTIES
- .getProperty("ScrollBarIncrementComponents", ""
- + m_ScrollBarIncrementComponents));
- m_FlowWidth = Integer.parseInt(BEAN_PROPERTIES.getProperty("FlowWidth",
- "" + m_FlowWidth));
- m_FlowHeight = Integer.parseInt(BEAN_PROPERTIES.getProperty("FlowHeight",
- "" + m_FlowHeight));
- m_PreferredExtension = BEAN_PROPERTIES.getProperty("PreferredExtension",
- m_PreferredExtension);
- m_UserComponentsInXML = Boolean.valueOf(
- BEAN_PROPERTIES.getProperty("UserComponentsInXML", ""
- + m_UserComponentsInXML)).booleanValue();
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- // FileChooser
- m_FileChooser.addChoosableFileFilter(m_KfFilter);
- if (KOML.isPresent()) {
- m_FileChooser.addChoosableFileFilter(m_KOMLFilter);
- }
- if (XStream.isPresent()) {
- m_FileChooser.addChoosableFileFilter(m_XStreamFilter);
- }
- m_FileChooser.addChoosableFileFilter(m_XMLFilter);
- if (m_PreferredExtension.equals(FILE_EXTENSION_XML)) {
- m_FileChooser.setFileFilter(m_XMLFilter);
- } else if (KOML.isPresent()
- && m_PreferredExtension.equals(KOML.FILE_EXTENSION + "kf")) {
- m_FileChooser.setFileFilter(m_KOMLFilter);
- } else if (XStream.isPresent()
- && m_PreferredExtension.equals(XStream.FILE_EXTENSION + "kf")) {
- m_FileChooser.setFileFilter(m_XStreamFilter);
- } else {
- m_FileChooser.setFileFilter(m_KfFilter);
- }
- m_FileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
- m_bcSupport.setDesignTime(true);
- m_beanLayout.setLayout(null);
- // handle mouse events
- m_beanLayout.addMouseListener(new MouseAdapter() {
- @Override
- public void mousePressed(MouseEvent me) {
- if (m_toolBarBean == null) {
- if (((me.getModifiers() & InputEvent.BUTTON1_MASK) == InputEvent.BUTTON1_MASK)
- && m_mode == NONE) {
- BeanInstance bi = BeanInstance.findInstance(me.getPoint());
- JComponent bc = null;
- if (bi != null) {
- bc = (JComponent) (bi.getBean());
- }
- if (bc != null && (bc instanceof Visible)) {
- m_editElement = bi;
- m_oldX = me.getX();
- m_oldY = me.getY();
- m_mode = MOVING;
- }
- if (m_mode != MOVING) {
- m_mode = SELECTING;
- m_oldX = me.getX();
- m_oldY = me.getY();
- m_startX = m_oldX;
- m_startY = m_oldY;
- Graphics2D gx = (Graphics2D) m_beanLayout.getGraphics();
- gx.setXORMode(java.awt.Color.white);
- // gx.drawRect(m_oldX, m_oldY, m_oldX, m_oldY);
- // gx.drawLine(m_startX, m_startY, m_startX, m_startY);
- gx.dispose();
- m_mode = SELECTING;
- }
- }
- }
- }
- @Override
- public void mouseReleased(MouseEvent me) {
- if (m_editElement != null && m_mode == MOVING) {
- m_editElement = null;
- revalidate();
- m_beanLayout.repaint();
- m_mode = NONE;
- }
- if (m_mode == SELECTING) {
- revalidate();
- m_beanLayout.repaint();
- m_mode = NONE;
- checkSubFlow(m_startX, m_startY, me.getX(), me.getY());
- }
- }
- @Override
- public void mouseClicked(MouseEvent me) {
- BeanInstance bi = BeanInstance.findInstance(me.getPoint());
- if (m_mode == ADDING || m_mode == NONE) {
- // try and popup a context sensitive menu if we have
- // been clicked over a bean.
- if (bi != null) {
- JComponent bc = (JComponent) bi.getBean();
- // if we've been double clicked, then popup customizer
- // as long as we're not a meta bean
- if (me.getClickCount() == 2 && !(bc instanceof MetaBean)) {
- try {
- Class custClass = Introspector.getBeanInfo(bc.getClass())
- .getBeanDescriptor().getCustomizerClass();
- if (custClass != null) {
- if (bc instanceof BeanCommon) {
- if (!((BeanCommon) bc).isBusy()) {
- popupCustomizer(custClass, bc);
- }
- } else {
- popupCustomizer(custClass, bc);
- }
- }
- } catch (IntrospectionException ex) {
- ex.printStackTrace();
- }
- } else if (((me.getModifiers() & InputEvent.BUTTON1_MASK) != InputEvent.BUTTON1_MASK)
- || me.isAltDown()) {
- doPopup(me.getPoint(), bi, me.getX(), me.getY());
- }
- } else {
- if (((me.getModifiers() & InputEvent.BUTTON1_MASK) != InputEvent.BUTTON1_MASK)
- || me.isAltDown()) {
- // find connections if any close to this point
- int delta = 10;
- deleteConnectionPopup(
- BeanConnection.getClosestConnections(
- new Point(me.getX(), me.getY()), delta), me.getX(),
- me.getY());
- } else if (m_toolBarBean != null) {
- // otherwise, if a toolbar button is active then
- // add the component
- addComponent(me.getX(), me.getY());
- }
- }
- }
- if (m_mode == CONNECTING) {
- // turn off connecting points and remove connecting line
- m_beanLayout.repaint();
- Vector beanInstances = BeanInstance.getBeanInstances();
- for (int i = 0; i < beanInstances.size(); i++) {
- JComponent bean = (JComponent) ((BeanInstance) beanInstances
- .elementAt(i)).getBean();
- if (bean instanceof Visible) {
- ((Visible) bean).getVisual().setDisplayConnectors(false);
- }
- }
- if (bi != null) {
- boolean doConnection = false;
- if (!(bi.getBean() instanceof BeanCommon)) {
- doConnection = true;
- } else {
- // Give the target bean a chance to veto the proposed
- // connection
- if (((BeanCommon) bi.getBean()).
- // connectionAllowed(m_sourceEventSetDescriptor.getName())) {
- connectionAllowed(m_sourceEventSetDescriptor)) {
- doConnection = true;
- }
- }
- if (doConnection) {
- // attempt to connect source and target beans
- if (bi.getBean() instanceof MetaBean) {
- BeanConnection.doMetaConnection(m_editElement, bi,
- m_sourceEventSetDescriptor, m_beanLayout);
- } else {
- BeanConnection bc = new BeanConnection(m_editElement, bi,
- m_sourceEventSetDescriptor);
- }
- }
- m_beanLayout.repaint();
- }
- m_mode = NONE;
- m_editElement = null;
- m_sourceEventSetDescriptor = null;
- }
- }
- });
- m_beanLayout.addMouseMotionListener(new MouseMotionAdapter() {
- @Override
- public void mouseDragged(MouseEvent me) {
- if (m_editElement != null && m_mode == MOVING) {
- ImageIcon ic = ((Visible) m_editElement.getBean()).getVisual()
- .getStaticIcon();
- int width = ic.getIconWidth() / 2;
- int height = ic.getIconHeight() / 2;
- /*
- * m_editElement.setX(m_oldX-width);
- * m_editElement.setY(m_oldY-height);
- */
- m_editElement.setXY(m_oldX - width, m_oldY - height);
- m_beanLayout.repaint();
- // note the new points
- m_oldX = me.getX();
- m_oldY = me.getY();
- }
- if (m_mode == SELECTING) {
- m_beanLayout.repaint();
- m_oldX = me.getX();
- m_oldY = me.getY();
- }
- }
- @Override
- public void mouseMoved(MouseEvent e) {
- if (m_mode == CONNECTING) {
- m_beanLayout.repaint();
- // note the new coordinates
- m_oldX = e.getX();
- m_oldY = e.getY();
- }
- }
- });
- String date = (new SimpleDateFormat("EEEE, d MMMM yyyy"))
- .format(new Date());
- m_logPanel.logMessage(Messages.getInstance().getString(
- "KnowledgeFlowApp_MouseClicked_LogPanel_LogMessage_Text_First"));
- m_logPanel.logMessage(Messages.getInstance().getString(
- "KnowledgeFlowApp_MouseClicked_LogPanel_LogMessage_Text_Second"));
- m_logPanel.logMessage(Messages.getInstance().getString(
- "KnowledgeFlowApp_MouseClicked_LogPanel_LogMessage_Text_Third")
- + Copyright.getToYear()
- + " "
- + Copyright.getOwner()
- + ", "
- + Copyright.getAddress());
- m_logPanel.logMessage(Messages.getInstance().getString(
- "KnowledgeFlowApp_MouseClicked_LogPanel_LogMessage_Text_Fourth")
- + Copyright.getURL());
- m_logPanel.logMessage(date);
- m_logPanel.statusMessage(Messages.getInstance().getString(
- "KnowledgeFlowApp_MouseClicked_LogPanel_StatusMessage_Text_First"));
- m_logPanel.getStatusTable().addMouseListener(new MouseAdapter() {
- @Override
- public void mouseClicked(MouseEvent e) {
- if (m_logPanel.getStatusTable().rowAtPoint(e.getPoint()) == 0) {
- if (((e.getModifiers() & InputEvent.BUTTON1_MASK) != InputEvent.BUTTON1_MASK)
- || e.isAltDown()) {
- System.gc();
- Runtime currR = Runtime.getRuntime();
- long freeM = currR.freeMemory();
- long totalM = currR.totalMemory();
- long maxM = currR.maxMemory();
- m_logPanel.logMessage(Messages.getInstance().getString(
- "KnowledgeFlowApp_MouseClicked_LogPanel_LogMessage_Text_Fifth")
- + String.format("%,d", freeM)
- + " / "
- + String.format("%,d", totalM)
- + " / "
- + String.format("%,d", maxM));
- m_logPanel
- .statusMessage(Messages
- .getInstance()
- .getString(
- "KnowledgeFlowApp_MouseClicked_LogPanel_StatusMessage_Text_Second")
- + String.format("%,d", freeM)
- + " / "
- + String.format("%,d", totalM)
- + " / "
- + String.format("%,d", maxM));
- }
- }
- }
- });
- JPanel p1 = new JPanel();
- p1.setLayout(new BorderLayout());
- p1.setBorder(javax.swing.BorderFactory.createCompoundBorder(
- javax.swing.BorderFactory
- .createTitledBorder(Messages
- .getInstance()
- .getString(
- "KnowledgeFlowApp_P1_JPanel_BorderFactoryCreateTitledBorder_Text")),
- javax.swing.BorderFactory.createEmptyBorder(0, 5, 5, 5)));
- final JScrollPane js = new JScrollPane(m_beanLayout);
- p1.add(js, BorderLayout.CENTER);
- js.getVerticalScrollBar().setUnitIncrement(m_ScrollBarIncrementLayout);
- js.getHorizontalScrollBar().setUnitIncrement(m_ScrollBarIncrementLayout);
- setLayout(new BorderLayout());
- add(p1, BorderLayout.CENTER);
- m_beanLayout.setSize(m_FlowWidth, m_FlowHeight);
- Dimension d = m_beanLayout.getPreferredSize();
- m_beanLayout.setMinimumSize(d);
- m_beanLayout.setMaximumSize(d);
- m_beanLayout.setPreferredSize(d);
- Dimension d2 = new Dimension(100, 170);
- m_logPanel.setPreferredSize(d2);
- m_logPanel.setMinimumSize(d2);
- add(m_logPanel, BorderLayout.SOUTH);
- setUpToolBars();
- loadUserComponents();
- }
- private Image loadImage(String path) {
- Image pic = null;
- // Modified by Zerbetto
- // java.net.URL imageURL = ClassLoader.getSystemResource(path);
- java.net.URL imageURL = this.getClass().getClassLoader().getResource(path);
- // end modifications
- if (imageURL == null) {
- // System.err.println("Warning: unable to load "+path);
- } else {
- pic = Toolkit.getDefaultToolkit().getImage(imageURL);
- }
- return pic;
- }
- /**
- * Describe <code>setUpToolBars</code> method here.
- */
- private void setUpToolBars() {
- JPanel toolBarPanel = new JPanel();
- toolBarPanel.setLayout(new BorderLayout());
- // modifications by Zerbetto
- // first construct the toolbar for saving, loading etc
- if (m_showFileMenu) {
- JToolBar fixedTools = new JToolBar();
- fixedTools.setOrientation(JToolBar.VERTICAL);
- m_saveB = new JButton(new ImageIcon(loadImage(BeanVisual.ICON_PATH
- + "Save24.gif")));
- m_saveB.setToolTipText(Messages.getInstance().getString(
- "KnowledgeFlowApp_SaveB_SetToolTipText_Text"));
- m_loadB = new JButton(new ImageIcon(loadImage(BeanVisual.ICON_PATH
- + "Open24.gif")));
- m_loadB.setToolTipText(Messages.getInstance().getString(
- "KnowledgeFlowApp_LoadB_SetToolTipText_Text"));
- m_newB = new JButton(new ImageIcon(loadImage(BeanVisual.ICON_PATH
- + "New24.gif")));
- m_newB.setToolTipText(Messages.getInstance().getString(
- "KnowledgeFlowApp_NewB_SetToolTipText_Text"));
- fixedTools.add(m_newB);
- fixedTools.add(m_saveB);
- fixedTools.add(m_loadB);
- m_saveB.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- saveLayout();
- }
- });
- m_loadB.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- m_flowEnvironment = new Environment();
- loadLayout();
- }
- });
- m_newB.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent ae) {
- clearLayout();
- }
- });
- fixedTools.setFloatable(false);
- toolBarPanel.add(fixedTools, BorderLayout.WEST);
- }
- m_stopB = new JButton(new ImageIcon(loadImage(BeanVisual.ICON_PATH
- + "Stop24.gif")));
- m_helpB = new JButton(new ImageIcon(loadImage(BeanVisual.ICON_PATH
- + "Help24.gif")));
- m_stopB.setToolTipText(Messages.getInstance().getString(
- "KnowledgeFlowApp_StopB_SetToolTipText_Text"));
- m_helpB.setToolTipText(Messages.getInstance().getString(
- "KnowledgeFlowApp_HelpB_SetToolTipText_Text"));
- Image tempI = loadImage(BeanVisual.ICON_PATH + "Pointer.gif");
- m_pointerB = new JToggleButton(new ImageIcon(tempI));
- m_pointerB.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- m_toolBarBean = null;
- m_mode = NONE;
- setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
- }
- });
- // Dimension dP = m_saveB.getPreferredSize();
- // Dimension dM = m_saveB.getMaximumSize();
- // Dimension dP = m_stopB.getPreferredSize();
- // Dimension dM = m_stopB.getMaximumSize();
- // m_pointerB.setPreferredSize(dP);
- // m_pointerB.setMaximumSize(dM);
- m_toolBarGroup.add(m_pointerB);
- JToolBar fixedTools2 = new JToolBar();
- fixedTools2.setOrientation(JToolBar.VERTICAL);
- fixedTools2.setFloatable(false);
- fixedTools2.add(m_pointerB);
- fixedTools2.add(m_helpB);
- fixedTools2.add(m_stopB);
- // m_helpB.setPreferredSize(dP);
- // m_helpB.setMaximumSize(dP);
- m_helpB.setSize(m_pointerB.getSize().width, m_pointerB.getSize().height);
- toolBarPanel.add(fixedTools2, BorderLayout.EAST);
- // end modifications by Zerbetto
- m_stopB.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- m_logPanel.statusMessage(Messages.getInstance().getString(
- "KnowledgeFlowApp_StopB_LogPanel_StatusMessage_Text_First"));
- stopFlow();
- m_logPanel.statusMessage(Messages.getInstance().getString(
- "KnowledgeFlowApp_StopB_LogPanel_StatusMessage_Text_Second"));
- }
- });
- m_helpB.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent ae) {
- popupHelp();
- }
- });
- final int STANDARD_TOOLBAR = 0;
- final int WEKAWRAPPER_TOOLBAR = 1;
- int toolBarType = STANDARD_TOOLBAR;
- // set up wrapper toolbars
- for (int i = 0; i < TOOLBARS.size(); i++) {
- Vector tempBarSpecs = (Vector) TOOLBARS.elementAt(i);
- // name for the tool bar
- String tempBarName = (String) tempBarSpecs.elementAt(0);
- // Used for weka leaf packages
- Box singletonHolderPanel = null;
- // name of the bean component to handle this class of weka algorithms
- String tempBeanCompName = (String) tempBarSpecs.elementAt(1);
- // a JPanel holding an instantiated bean + label ready to be added
- // to the current toolbar
- JPanel tempBean;
- // the root package for weka algorithms
- String rootPackage = "";
- weka.gui.HierarchyPropertyParser hpp = null;
- Hashtable hpps = null;
- // Is this a wrapper toolbar?
- if (tempBeanCompName.compareTo("null") != 0) {
- tempBean = null;
- toolBarType = WEKAWRAPPER_TOOLBAR;
- rootPackage = (String) tempBarSpecs.elementAt(2);
- // hpp = (weka.gui.HierarchyPropertyParser)tempBarSpecs.elementAt(3);
- hpps = (Hashtable) tempBarSpecs.elementAt(3);
- try {
- // modifications by Zerbetto
- // Beans.instantiate(null, tempBeanCompName);
- Beans.instantiate(this.getClass().getClassLoader(), tempBeanCompName);
- // end modifications by Zerbetto
- } catch (Exception ex) {
- // ignore
- System.err.println(Messages.getInstance().getString(
- "KnowledgeFlowApp_Error_Text")
- + tempBeanCompName);
- break;
- }
- } else {
- toolBarType = STANDARD_TOOLBAR;
- }
- // a toolbar to hold buttons---one for each algorithm
- JToolBar tempToolBar = new JToolBar();
- // System.err.println(tempToolBar.getLayout());
- // tempToolBar.setLayout(new FlowLayout());
- int z = 2;
- if (toolBarType == WEKAWRAPPER_TOOLBAR) {
- Enumeration enm = hpps.keys();
- while (enm.hasMoreElements()) {
- String root = (String) enm.nextElement();
- String userPrefix = "";
- hpp = (HierarchyPropertyParser) hpps.get(root);
- if (!hpp.goTo(rootPackage)) {
- System.out.println(Messages.getInstance().getString(
- "KnowledgeFlowApp_Text_First"));
- // System.exit(1);
- userPrefix = root + ".";
- }
- String[] primaryPackages = hpp.childrenValues();
- for (int kk = 0; kk < primaryPackages.length; kk++) {
- hpp.goToChild(primaryPackages[kk]);
- // check to see if this is a leaf - if so then there are no
- // sub packages
- if (hpp.isLeafReached()) {
- if (singletonHolderPanel == null) {
- singletonHolderPanel = Box.createHorizontalBox();
- singletonHolderPanel.setBorder(javax.swing.BorderFactory
- .createTitledBorder(tempBarName));
- }
- String algName = hpp.fullValue();
- tempBean = instantiateToolBarBean(true, tempBeanCompName, algName);
- if (tempBean != null) {
- // tempToolBar.add(tempBean);
- singletonHolderPanel.add(tempBean);
- }
- hpp.goToParent();
- } else {
- // make a titledborder JPanel to hold all the schemes in this
- // package
- // JPanel holderPanel = new JPanel();
- Box holderPanel = Box.createHorizontalBox();
- holderPanel.setBorder(javax.swing.BorderFactory
- .createTitledBorder(userPrefix + primaryPackages[kk]));
- processPackage(holderPanel, tempBeanCompName, hpp);
- tempToolBar.add(holderPanel);
- }
- }
- if (singletonHolderPanel != null) {
- tempToolBar.add(singletonHolderPanel);
- singletonHolderPanel = null;
- }
- }
- } else {
- Box holderPanel = Box.createHorizontalBox();
- holderPanel.setBorder(javax.swing.BorderFactory
- .createTitledBorder(tempBarName));
- for (int j = z; j < tempBarSpecs.size(); j++) {
- tempBean = null;
- tempBeanCompName = (String) tempBarSpecs.elementAt(j);
- tempBean = instantiateToolBarBean(
- (toolBarType == WEKAWRAPPER_TOOLBAR), tempBeanCompName, "");
- if (tempBean != null) {
- // set tool tip text (if any)
- // setToolTipText(tempBean)
- holderPanel.add(tempBean);
- }
- }
- tempToolBar.add(holderPanel);
- }
- JScrollPane tempJScrollPane = createScrollPaneForToolBar(tempToolBar);
- // ok, now create tabbed pane to hold this toolbar
- m_toolBars.addTab(tempBarName, null, tempJScrollPane, tempBarName);
- }
- // Any plugin components to process?
- if (BEAN_PLUGINS_PROPERTIES != null && BEAN_PLUGINS_PROPERTIES.size() > 0) {
- for (int i = 0; i < BEAN_PLUGINS_PROPERTIES.size(); i++) {
- Properties tempP = BEAN_PLUGINS_PROPERTIES.get(i);
- JPanel tempBean = null;
- String components = tempP
- .getProperty("weka.gui.beans.KnowledgeFlow.Plugins");
- StringTokenizer st2 = new StringTokenizer(components, ", ");
- while (st2.hasMoreTokens()) {
- String tempBeanCompName = st2.nextToken().trim();
- tempBean = instantiateToolBarBean(false, tempBeanCompName, "");
- if (m_pluginsToolBar == null) {
- // need to create the plugins tab and toolbar
- setUpPluginsToolBar();
- }
- m_pluginsBoxPanel.add(tempBean);
- }
- }
- }
- toolBarPanel.add(m_toolBars, BorderLayout.CENTER);
- // add(m_toolBars, BorderLayout.NORTH);
- add(toolBarPanel, BorderLayout.NORTH);
- }
- private void stopFlow() {
- Vector components = BeanInstance.getBeanInstances();
- for (int i = 0; i < components.size(); i++) {
- Object temp = ((BeanInstance) components.elementAt(i)).getBean();
- if (temp instanceof BeanCommon) {
- ((BeanCommon) temp).stop();
- }
- }
- }
- private JScrollPane createScrollPaneForToolBar(JToolBar tb) {
- JScrollPane tempJScrollPane = new JScrollPane(tb,
- JScrollPane.VERTICAL_SCROLLBAR_NEVER,
- JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
- Dimension d = tb.getPreferredSize();
- tempJScrollPane.setMinimumSize(new Dimension((int) d.getWidth(), (int) (d
- .getHeight() + 15)));
- tempJScrollPane.setPreferredSize(new Dimension((int) d.getWidth(), (int) (d
- .getHeight() + 15)));
- tempJScrollPane.getHorizontalScrollBar().setUnitIncrement(
- m_ScrollBarIncrementComponents);
- return tempJScrollPane;
- }
- private void processPackage(JComponent holderPanel, String tempBeanCompName,
- weka.gui.HierarchyPropertyParser hpp) {
- if (hpp.isLeafReached()) {
- // instantiate a bean and add it to the holderPanel
- // System.err.println("Would add "+hpp.fullValue());
- String algName = hpp.fullValue();
- JPanel tempBean = instantiateToolBarBean(true, tempBeanCompName, algName);
- if (tempBean != null) {
- holderPanel.add(tempBean);
- }
- hpp.goToParent();
- return;
- }
- String[] children = hpp.childrenValues();
- for (int i = 0; i < children.length; i++) {
- hpp.goToChild(children[i]);
- processPackage(holderPanel, tempBeanCompName, hpp);
- }
- hpp.goToParent();
- }
- /**
- * Instantiates a bean for display in the toolbars
- *
- * @param wekawrapper true if the bean to be instantiated is a wekawrapper
- * @param tempBeanCompName the name of the bean to instantiate
- * @param algName holds the name of a weka algorithm to configure the bean
- * with if it is a wekawrapper bean
- * @return a JPanel holding the instantiated (and configured bean)
- */
- private JPanel instantiateToolBarBean(boolean wekawrapper,
- String tempBeanCompName, String algName) {
- Object tempBean;
- if (wekawrapper) {
- try {
- // modifications by Zerbetto
- // tempBean = Beans.instantiate(null, tempBeanCompName);
- tempBean = Beans.instantiate(this.getClass().getClassLoader(),
- tempBeanCompName);
- // end modifications by Zerbetto
- } catch (Exception ex) {
- System.err.println(Messages.getInstance().getString(
- "KnowledgeFlowApp_InstantiateToolBarBean_Error_Text_First")
- + tempBeanCompName + "KnowledgeFlowApp.instantiateToolBarBean()");
- return null;
- }
- if (tempBean instanceof WekaWrapper) {
- // algName = (String)tempBarSpecs.elementAt(j);
- Class c = null;
- try {
- c = Class.forName(algName);
- } catch (Exception ex) {
- System.err.println(Messages.getInstance().getString(
- "KnowledgeFlowApp_InstantiateToolBarBean_Error_Text_Third")
- + algName);
- return null;
- }
- try {
- Object o = c.newInstance();
- ((WekaWrapper) tempBean).setWrappedAlgorithm(o);
- } catch (Exception ex) {
- System.err.println(Messages.getInstance().getString(
- "KnowledgeFlowApp_InstantiateToolBarBean_Error_Text_Fourth")
- + tempBeanCompName
- + Messages.getInstance().getString(
- "KnowledgeFlowApp_InstantiateToolBarBean_Error_Text_Fifth")
- + algName);
- return null;
- }
- }
- } else {
- try {
- // modifications by Zerbetto
- // tempBean = Beans.instantiate(null, tempBeanCompName);
- tempBean = Beans.instantiate(this.getClass().getClassLoader(),
- tempBeanCompName);
- // end modifications
- } catch (Exception ex) {
- ex.printStackTrace();
- System.err.println(Messages.getInstance().getString(
- "KnowledgeFlowApp_InstantiateToolBarBean_Error_Text_Sixth")
- + tempBeanCompName + "KnowledgeFlowApp.setUpToolBars()");
- return null;
- }
- }
- if (tempBean instanceof BeanContextChild) {
- m_bcSupport.add(tempBean);
- }
- if (tempBean instanceof Visible) {
- ((Visible) tempBean).getVisual().scale(3);
- }
- return makeHolderPanelForToolBarBean(tempBeanCompName, tempBean,
- wekawrapper, algName, false);
- }
- /**
- * Instantiates (by making a serialized copy) the supplied template meta bean
- * for display in the user tool bar
- *
- * @param bean the prototype MetaBean to display in the toolbar
- */
- private JPanel instantiateToolBarMetaBean(MetaBean bean) {
- // copy the bean via serialization
- ((Visible) bean).getVisual().removePropertyChangeListener(this);
- bean.removePropertyChangeListenersSubFlow(this);
- Object copy = null;
- try {
- SerializedObject so = new SerializedObject(bean);
- copy = so.getObject();
- } catch (Exception ex) {
- ex.printStackTrace();
- return null;
- }
- ((Visible) bean).getVisual().addPropertyChangeListener(this);
- bean.addPropertyChangeListenersSubFlow(this);
- String displayName = "";
- //
- if (copy instanceof Visible) {
- ((Visible) copy).getVisual().scale(3);
- displayName = ((Visible) copy).getVisual().getText();
- }
- return makeHolderPanelForToolBarBean(displayName, copy, false, null, true);
- }
- private JPanel makeHolderPanelForToolBarBean(final String tempName,
- Object tempBean, boolean wekawrapper, String algName,
- final boolean metabean) {
- // ---------------------------------------
- JToggleButton tempButton;
- final JPanel tempP = new JPanel();
- JLabel tempL = new JLabel();
- tempL.setFont(new Font(null, Font.PLAIN, 9));
- String labelName = (wekawrapper == true) ? algName : tempName;
- labelName = labelName.substring(labelName.lastIndex