public class SerializedModelSaver extends JPanel implements BeanCommon, Visible, BatchClassifierListener, IncrementalClassifierListener, BatchClustererListener, EnvironmentHandler, Serializable
JPanel.AccessibleJPanel
JComponent.AccessibleJComponent
Container.AccessibleAWTContainer
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
Modifier and Type | Field and Description |
---|---|
static int |
BINARY |
static String |
FILE_EXTENSION
the extension for serialized models (binary Java serialization)
|
static int |
KOMLV |
protected Environment |
m_env
The environment variables.
|
protected Object |
m_listenee
Non null if this object is a target for any events.
|
protected Logger |
m_logger
The log for this bean
|
protected BeanVisual |
m_visual
Default visual for data sources
|
static ArrayList<Tag> |
s_fileFormatsAvailable
Available file formats.
|
static int |
XSTREAM |
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor and Description |
---|
SerializedModelSaver()
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
acceptClassifier(BatchClassifierEvent ce)
Accept and save a batch trained classifier.
|
void |
acceptClassifier(IncrementalClassifierEvent ce)
Accept and save an incrementally trained classifier.
|
void |
acceptClusterer(BatchClustererEvent ce)
Accept and save a batch trained clusterer.
|
boolean |
connectionAllowed(EventSetDescriptor esd)
Returns true if, at this time,
the object will accept a connection according to the supplied
EventSetDescriptor.
|
boolean |
connectionAllowed(String eventName)
Returns true if, at this time,
the object will accept a connection according to the supplied
event name.
|
void |
connectionNotification(String eventName,
Object source)
Notify this object that it has been registered as a listener with
a source with respect to the supplied event name.
|
void |
disconnectionNotification(String eventName,
Object source)
Notify this object that it has been deregistered as a listener with
a source with respect to the supplied event name.
|
String |
getCustomName()
Get the custom (descriptive) name for this bean (if one has been set)
|
File |
getDirectory()
Get the directory that the model(s) will be saved into
|
Tag |
getFileFormat()
Get the file format to use for saving.
|
String |
getPrefix()
Get the prefix to prepend to the model file names.
|
boolean |
getUseRelativePath()
Get whether to use relative paths for the directory.
|
BeanVisual |
getVisual()
Get the visual being used by this data source.
|
String |
globalInfo()
Global info for this bean.
|
boolean |
isBusy()
Returns true if.
|
protected String |
sanitizeFilename(String filename)
makes sure that the filename is valid, i.e., replaces slashes,
backslashes and colons with underscores ("_").
|
static void |
saveBinary(File saveTo,
Object model,
Instances header)
Save a model in binary form.
|
static void |
saveKOML(File saveTo,
Object model,
Instances header)
Save a model in KOML deep object serialized XML form.
|
static void |
saveXStream(File saveTo,
Object model,
Instances header)
Save a model in XStream deep object serialized XML form.
|
void |
setCustomName(String name)
Set a custom (descriptive) name for this bean
|
void |
setDirectory(File d)
Set the directory that the model(s) will be saved into.
|
void |
setEnvironment(Environment env)
Set environment variables to use.
|
void |
setFileFormat(Tag ff)
Set the file format to use for saving.
|
void |
setLog(Logger logger)
Set a log for this bean.
|
void |
setPrefix(String p)
Set the prefix to prepend to the model file names.
|
void |
setUseRelativePath(boolean rp)
Set whether to use relative paths for the directory.
|
void |
setVisual(BeanVisual newVisual)
Set the visual for this data source.
|
void |
stop()
Stop any processing that the bean might be doing.
|
void |
useDefaultVisual()
Use the default images for this bean.
|
Tag |
validateFileFormat(Tag ff)
Validate the file format.
|
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, 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, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, 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, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
add, add, add, add, add, addContainerListener, addImpl, 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, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, 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, getPeer, 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, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
protected BeanVisual m_visual
protected Object m_listenee
protected transient Logger m_logger
public static final int BINARY
public static final int KOMLV
public static final int XSTREAM
public static final String FILE_EXTENSION
public static ArrayList<Tag> s_fileFormatsAvailable
protected transient Environment m_env
public void setCustomName(String name)
setCustomName
in interface BeanCommon
name
- the name to usepublic String getCustomName()
getCustomName
in interface BeanCommon
public void useDefaultVisual()
useDefaultVisual
in interface Visible
public void setVisual(BeanVisual newVisual)
public BeanVisual getVisual()
public boolean connectionAllowed(EventSetDescriptor esd)
connectionAllowed
in interface BeanCommon
esd
- the EventSetDescriptorpublic boolean connectionAllowed(String eventName)
connectionAllowed
in interface BeanCommon
eventName
- the eventpublic void connectionNotification(String eventName, Object source)
connectionNotification
in interface BeanCommon
eventName
- the eventsource
- the source with which this object has been registered as
a listenerpublic void disconnectionNotification(String eventName, Object source)
disconnectionNotification
in interface BeanCommon
eventName
- the eventsource
- the source with which this object has been registered as
a listenerpublic void setLog(Logger logger)
setLog
in interface BeanCommon
logger
- a weka.gui.Logger
valuepublic void stop()
stop
in interface BeanCommon
public boolean isBusy()
isBusy
in interface BeanCommon
protected String sanitizeFilename(String filename)
filename
- the filename to cleansepublic void acceptClusterer(BatchClustererEvent ce)
acceptClusterer
in interface BatchClustererListener
ce
- a BatchClassifierEvent
valuepublic void acceptClassifier(IncrementalClassifierEvent ce)
acceptClassifier
in interface IncrementalClassifierListener
ce
- the BatchClassifierEvent containing the classifierpublic void acceptClassifier(BatchClassifierEvent ce)
acceptClassifier
in interface BatchClassifierListener
ce
- the BatchClassifierEvent containing the classifierpublic static void saveBinary(File saveTo, Object model, Instances header) throws IOException
saveTo
- the file name to save tomodel
- the model to saveheader
- the header of the data that was used to train the model (optional)IOException
public static void saveKOML(File saveTo, Object model, Instances header) throws Exception
saveTo
- the file name to save tomodel
- the model to saveheader
- the header of the data that was used to train the model (optional)Exception
public static void saveXStream(File saveTo, Object model, Instances header) throws Exception
saveTo
- the file name to save tomodel
- the model to saveheader
- the header of the data that was used to train the model (optional)Exception
public File getDirectory()
public void setDirectory(File d)
d
- the directory to save topublic void setUseRelativePath(boolean rp)
rp
- true if relative paths are to be usedpublic boolean getUseRelativePath()
public String getPrefix()
public void setPrefix(String p)
p
- the prefix to prependpublic String globalInfo()
public void setFileFormat(Tag ff)
ff
- the file format to usepublic Tag getFileFormat()
public Tag validateFileFormat(Tag ff)
ff
- the current file format to validatepublic void setEnvironment(Environment env)
setEnvironment
in interface EnvironmentHandler
env
- the environment variables to
useCopyright © 2015 University of Waikato, Hamilton, NZ. All rights reserved.