Package weka.gui.knowledgeflow

# Class MainKFPerspective

java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
weka.gui.AbstractPerspective
weka.gui.knowledgeflow.MainKFPerspective

All Implemented Interfaces:
  `ImageObserver`, `MenuContainer`, `Serializable`, `Accessible`, `Perspective`

@PerspectiveInfo(ID="knowledgeflow.main", title="Data mining processes", toolTipText="Data mining processes", iconPath="weka/gui/weka_icon_new_small.png") public class MainKFPerspective extends AbstractPerspective
Main perspective for the Knowledge flow application

Author:
  Mark Hall
See Also:
  - Serialized Form

- ## Nested Class Summary

  ## Nested classes/interfaces inherited from class javax.swing.JComponent

  `JComponent.AccessibleJComponent`

  ## Nested classes/interfaces inherited from class java.awt.Component

  `Component.BaselineResizeBehavior`

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final String`
  `FILE_EXTENSION_JSON`
  File extension for undo point files
  `static final String`
  `FLOW_PARENT_DIRECTORY_VARIABLE_KEY`
  Key for the environment variable that holds the parent directory of a loaded flow

  ### Fields inherited from class javax.swing.JComponent

  `TOOL_TIP_TEXT_KEY, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW`

  ### Fields inherited from class java.awt.Component

  `BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT`

  ### Fields inherited from interface java.awt.image.ImageObserver

  `ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `MainKFPerspective()`
  Construct a new MainKFPerspective

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `acceptsInstances()`
  Returns true if this perspective can do something meaningful with a set of instances
  `void`
  `addTab(String tabTitle)`
  Add a new titled tab to the UI
  `void`
  `addUntitledTab()`
  Add a new untitled tab to the UI
  `void`
  `clearDesignPaletteSelection()`
  Clear the current selection in the design palette
  `void`
  `closeAllTabs()`
  Close all the open tabs
  `void`
  `copyFlowToClipboard(Flow flow)`
  `void`
  `copyStepsToClipboard(List<StepVisual> steps)`
  Copy the supplied steps to the clipboard
  `boolean`
  `getAllowMultipleTabs()`
  Returns true if the perspective is allowing multiple tabs to be open
  `VisibleLayout`
  `getCurrentLayout()`
  Get the flow layout for the current (visible) tab
  `int`
  `getCurrentTabIndex()`
  Get the index of the current (visible) tab
  `boolean`
  `getDebug()`
  `Defaults`
  `getDefaultSettings()`
  Get the default settings for this perspective (or null if there are none)
  `VisibleLayout`
  `getLayoutAt(int index)`
  Get the flow layout at the supplied index
  `MainKFPerspectiveToolBar`
  `getMainToolBar()`
  Get the main toolbar
  `List<JMenu>`
  `getMenus()`
  Get an ordered list of menus to appear in the main menu bar.
  `int`
  `getNumTabs()`
  Get the number of open tabs
  `StepManagerImpl`
  `getPalleteSelectedStep()`
  Return the currently selected step in the design palette
  `String`
  `getPasteBuffer()`
  Get the contents of the paste buffer
  `<T> T`
  `getSetting(Settings.SettingKey propKey, T defaultVal)`
  Get the value of a setting for the main perspective
  `boolean`
  `getSnapToGrid()`
  Return true if the snap-to-grid button is selected
  `String`
  `getTabTitle(int index)`
  Get the title of the tab at the supplied index
  `TemplateManager`
  `getTemplateManager()`
  Get the template manager
  `boolean`
  `isMemoryLow()`
  Return true if memory is running low
  `void`
  `loadLayout()`
  Load a flow layout.
  `void`
  `loadLayout(File fFile, boolean newTab)`
  Load a flow layout.
  `void`
  `notifyIsDirty()`
  `boolean`
  `okToBeActive()`
  Returns true if this perspective is OK with being an active perspective - i.e.
  `void`
  `removeTab(int tabIndex)`
  Remove/close a tab
  `void`
  `setActive(boolean active)`
  Set active status of this perspective.
  `void`
  `setActiveTab(int tabIndex)`
  Set the active (visible) tab
  `void`
  `setAllowMultipleTabs(boolean allow)`
  Set whether multiple tabs are allowed
  `void`
  `setCurrentTabTitleEditedStatus(boolean edited)`
  Set the edited status for the current (visible) tab
  `void`
  `setFlowLayoutOperation(weka.gui.knowledgeflow.VisibleLayout.LayoutOperation opp)`
  Set the current flow layout operation
  `void`
  `setInstances(Instances instances)`
  Set instances (if this perspective can use them)
  `void`
  `settingsChanged()`
  Called when the user alters settings.
  `void`
  `showErrorDialog(Exception cause)`
  Popup an error dialog
  `void`
  `showInfoDialog(Object information, String title, boolean isWarning)`
  Popup an information dialog
  `boolean`
  `showMemoryIsLow()`
  Print a warning if memory is low (and show a GUI dialog if running in a graphical environment)

  ### Methods inherited from class weka.gui.AbstractPerspective

  `getMainApplication, getPerspectiveIcon, getPerspectiveID, getPerspectiveTipText, getPerspectiveTitle, instantiationComplete, requiresLog, setLoaded, setLog, setMainApplication, terminate, toString`

  ### Methods inherited from class javax.swing.JPanel

  `getAccessibleContext, getUI, getUIClassID, setUI, updateUI`

  ### Methods inherited from class javax.swing.JComponent

  `addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update`

  ### Methods inherited from class java.awt.Container

  `add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate`

  ### Methods inherited from class java.awt.Component

  `action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, createImage, createImage, createVolatileImage, createVolatileImage, dispatchEvent, enable, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, transferFocus, transferFocusBackward, transferFocusUpCycle`

  ### Methods inherited from class java.lang.Object

  `equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## Field Details

  - ### FLOW_PARENT_DIRECTORY_VARIABLE_KEY

    public static final String FLOW_PARENT_DIRECTORY_VARIABLE_KEY
    Key for the environment variable that holds the parent directory of a loaded flow
    See Also:
      - Constant Field Values

  - ### FILE_EXTENSION_JSON

    public static final String FILE_EXTENSION_JSON
    File extension for undo point files
    See Also:
      - Constant Field Values

- ## Constructor Details

  - ### MainKFPerspective

    public MainKFPerspective()
    Construct a new MainKFPerspective

- ## Method Details

  - ### getPalleteSelectedStep

    public StepManagerImpl getPalleteSelectedStep()
    Return the currently selected step in the design palette
    Returns:
      the step selected in the design palette, or null if no step is selected

  - ### showErrorDialog

    public void showErrorDialog(Exception cause)
    Popup an error dialog
    Parameters:
      `cause` - the exception associated with the error

  - ### showInfoDialog

    public void showInfoDialog(Object information, String title, boolean isWarning)
    Popup an information dialog
    Parameters:
      `information` - the information to display
      `title` - the title for the dialog
      `isWarning` - true if the dialog should be a warning dialog

  - ### setFlowLayoutOperation

    public void setFlowLayoutOperation(weka.gui.knowledgeflow.VisibleLayout.LayoutOperation opp)
    Set the current flow layout operation
    Parameters:
      `opp` - the operation to use

  - ### getSnapToGrid

    public boolean getSnapToGrid()
    Return true if the snap-to-grid button is selected
    Returns:
      true if snap-to-grid is turned on

  - ### clearDesignPaletteSelection

    public void clearDesignPaletteSelection()
    Clear the current selection in the design palette

  - ### getPasteBuffer

    public String getPasteBuffer()
    Get the contents of the paste buffer
    Returns:
      the contents of the paste buffer (in JSON)

  - ### copyStepsToClipboard

    public void copyStepsToClipboard(List<StepVisual> steps) throws WekaException
    Copy the supplied steps to the clipboard
    Parameters:
      `steps` - a list of steps to copy
    Throws:
      `WekaException` - if a problem occurs

  - ### copyFlowToClipboard

    public void copyFlowToClipboard(Flow flow) throws WekaException
    Throws:
      `WekaException`

  - ### getTemplateManager

    public TemplateManager getTemplateManager()
    Get the template manager
    Returns:
      the template manager

  - ### addUntitledTab

    public void addUntitledTab()
    Add a new untitled tab to the UI

  - ### addTab

    public void addTab(String tabTitle)
    Add a new titled tab to the UI
    Parameters:
      `tabTitle` - the title for the tab

  - ### setCurrentTabTitleEditedStatus

    public void setCurrentTabTitleEditedStatus(boolean edited)
    Set the edited status for the current (visible) tab
    Parameters:
      `edited` - true if the flow in the tab has been edited (but not saved)

  - ### getCurrentTabIndex

    public int getCurrentTabIndex()
    Get the index of the current (visible) tab
    Returns:
      the index of the visible tab

  - ### getNumTabs

    public int getNumTabs()
    Get the number of open tabs
    Returns:
      the number of open tabs

  - ### getTabTitle

    public String getTabTitle(int index)
    Get the title of the tab at the supplied index
    Parameters:
      `index` - the index of the tab to get the title for
    Returns:
      the title of the tab
    Throws:
      `IndexOutOfBoundsException` - if the index is out of range

  - ### setActiveTab

    public void setActiveTab(int tabIndex)
    Set the active (visible) tab
    Parameters:
      `tabIndex` - the index of the tab to make active

  - ### closeAllTabs

    public void closeAllTabs()
    Close all the open tabs

  - ### removeTab

    public void removeTab(int tabIndex)
    Remove/close a tab
    Parameters:
      `tabIndex` - the index of the tab to close

  - ### getCurrentLayout

    public VisibleLayout getCurrentLayout()
    Get the flow layout for the current (visible) tab
    Returns:
      the current flow layout

  - ### getLayoutAt

    public VisibleLayout getLayoutAt(int index)
    Get the flow layout at the supplied index
    Parameters:
      `index` - the index of the flow layout to get
    Returns:
      the flow layout at the index
    Throws:
      `IndexOutOfBoundsException` - if the index is out of range

  - ### getAllowMultipleTabs

    public boolean getAllowMultipleTabs()
    Returns true if the perspective is allowing multiple tabs to be open
    Returns:
      true if multiple tabs are allowed

  - ### setAllowMultipleTabs

    public void setAllowMultipleTabs(boolean allow)
    Set whether multiple tabs are allowed
    Parameters:
      `allow` - true if multiple tabs are allowed

  - ### getSetting

    public <T> T getSetting(Settings.SettingKey propKey, T defaultVal)
    Get the value of a setting for the main perspective
    Type Parameters:
      `T` - the type of the setting
    Parameters:
      `propKey` - the key of the setting to get
      `defaultVal` - the default value to use if nothing is set yet
    Returns:
      the value (or default value) for the setting

  - ### notifyIsDirty

    public void notifyIsDirty()

  - ### loadLayout

    public void loadLayout()
    Load a flow layout. Prompts via a filechooser

  - ### loadLayout

    public void loadLayout(File fFile, boolean newTab)
    Load a flow layout.
    Parameters:
      `fFile` - the file to load
      `newTab` - true if the flow should be loaded into a new tab

  - ### isMemoryLow

    public boolean isMemoryLow()
    Return true if memory is running low
    Returns:
      true if memory is running low

  - ### showMemoryIsLow

    public boolean showMemoryIsLow()
    Print a warning if memory is low (and show a GUI dialog if running in a graphical environment)
    Returns:
      true if user opts to continue (in the GUI case)

  - ### getDebug

    public boolean getDebug()

  - ### getMainToolBar

    public MainKFPerspectiveToolBar getMainToolBar()
    Get the main toolbar
    Returns:
      the main toolbar

  - ### setActive

    public void setActive(boolean active)
    Set active status of this perspective. True indicates that this perspective is the visible active perspective in the application
    Specified by:
      `setActive` in interface `Perspective`
    Overrides:
      `setActive` in class `AbstractPerspective`
    Parameters:
      `active` - true if this perspective is the active one

  - ### getMenus

    public List<JMenu> getMenus()
    Get an ordered list of menus to appear in the main menu bar. Return null for no menus
    Specified by:
      `getMenus` in interface `Perspective`
    Overrides:
      `getMenus` in class `AbstractPerspective`
    Returns:
      a list of menus to appear in the main menu bar or null for no menus

  - ### getDefaultSettings

    public Defaults getDefaultSettings()
    Get the default settings for this perspective (or null if there are none)
    Specified by:
      `getDefaultSettings` in interface `Perspective`
    Overrides:
      `getDefaultSettings` in class `AbstractPerspective`
    Returns:
      the default settings for this perspective, or null if the perspective does not have any settings

  - ### okToBeActive

    public boolean okToBeActive()
    Returns true if this perspective is OK with being an active perspective - i.e. the user can click on this perspective at this time in the perspective toolbar. For example, a Perspective might return false from this method if it needs a set of instances to operate but none have been supplied yet.
    Specified by:
      `okToBeActive` in interface `Perspective`
    Overrides:
      `okToBeActive` in class `AbstractPerspective`
    Returns:
      true if this perspective can be active at the current time

  - ### settingsChanged

    public void settingsChanged()
    Called when the user alters settings. The settings altered by the user are not necessarily ones related to this perspective
    Specified by:
      `settingsChanged` in interface `Perspective`
    Overrides:
      `settingsChanged` in class `AbstractPerspective`

  - ### acceptsInstances

    public boolean acceptsInstances()
    Returns true if this perspective can do something meaningful with a set of instances
    Specified by:
      `acceptsInstances` in interface `Perspective`
    Overrides:
      `acceptsInstances` in class `AbstractPerspective`
    Returns:
      true if this perspective accepts instances

  - ### setInstances

    public void setInstances(Instances instances)
    Set instances (if this perspective can use them)
    Specified by:
      `setInstances` in interface `Perspective`
    Overrides:
      `setInstances` in class `AbstractPerspective`
    Parameters:
      `instances` - the instances