org.apache.jmeter.visualizers.gui

Class AbstractVisualizer

Implemented Interfaces:
ChangeListener, Clearable, JMeterGUIComponent, Printable, UnsharedComponent, Visualizer
Known Direct Subclasses:
AssertionVisualizer, DistributionGraphVisualizer, GraphAccumVisualizer, GraphVisualizer, MailerVisualizer, MonitorHealthVisualizer, SimpleDataWriter, SplineVisualizer, StatGraphVisualizer, StatVisualizer, SummaryReport, TableVisualizer, ViewResultsFullVisualizer

public abstract class AbstractVisualizer
extends AbstractListenerGui
implements Visualizer, ChangeListener, UnsharedComponent, Clearable

This is the base class for JMeter GUI components which can display test results in some way. It provides the following conveniences to developers:
  • Provides convenience methods to help you make a JMeter-compatible GUI:
  • For most developers, making a new visualizer is primarly for the purpose of either calculating new statistics on the sample results that other visualizers don't calculate, or displaying the results visually in a new and interesting way. Making a new visualizer for either of these purposes is easy - just extend this class and implement the add(SampleResult) method and display the results as you see fit. This AbstractVisualizer and the default ResultCollector handle logging and registering to receive SampleEvents for you - all you need to do is include the JPanel created by makeTitlePanel somewhere in your gui to allow users set the log file.

    If you are doing more than that, you may need to extend ResultCollector as well and modify the configure(TestElement), modifyTestElement(TestElement), and createTestElement() methods to create and modify your alternate ResultCollector. For an example of this, see the MailerVisualizer.

    Field Summary

    protected ResultCollector
    collector
    protected boolean
    isStats

    Fields inherited from class org.apache.jmeter.gui.AbstractJMeterGuiComponent

    namePanel

    Constructor Summary

    AbstractVisualizer()

    Method Summary

    void
    clearGui()
    void
    configure(TestElement el)
    protected void
    configureTestElement(AbstractListenerElement mc)
    This provides a convenience for extenders when they implement the JMeterGUIComponent.createTestElement() method.
    TestElement
    createTestElement()
    protected JCheckBox
    getErrorLoggingCheckbox()
    Gets the checkbox which selects whether or not only errors should be logged.
    String
    getFile()
    Gets the filename which has been entered in the FilePanel.
    protected Component
    getFilePanel()
    Gets the file panel which allows the user to save results to a file.
    protected ResultCollector
    getModel()
    Provides access to the ResultCollector model class for extending implementations.
    boolean
    isStats()
    protected Container
    makeTitlePanel()
    Create a standard title section for JMeter components.
    void
    modifyTestElement(TestElement c)
    void
    setFile(String filename)
    Sets the filename which results will be saved to.
    protected void
    setModel(ResultCollector collector)
    Provides extending classes the opportunity to set the ResultCollector model for the Visualizer.
    void
    stateChanged(ChangeEvent e)
    Invoked when the target of the listener has changed its state.

    Methods inherited from class org.apache.jmeter.visualizers.gui.AbstractListenerGui

    createPopupMenu, getMenuCategories

    Methods inherited from class org.apache.jmeter.gui.AbstractJMeterGuiComponent

    clearGui, configure, configureTestElement, createTitleLabel, getComment, getDocAnchor, getName, getNamePanel, getNode, getPrintableComponent, getStaticLabel, isEnabled, makeBorder, makeScrollPane, makeScrollPane, makeTitlePanel, setComment, setEnabled, setName, setNode

    Field Details

    collector

    protected ResultCollector collector

    isStats

    protected boolean isStats

    Constructor Details

    AbstractVisualizer

    public AbstractVisualizer()

    Method Details

    clearGui

    public void clearGui()
    Specified by:
    clearGui in interface JMeterGUIComponent
    Overrides:
    clearGui in interface AbstractJMeterGuiComponent

    configure

    public void configure(TestElement el)
    Specified by:
    configure in interface JMeterGUIComponent
    Overrides:
    configure in interface AbstractJMeterGuiComponent

    configureTestElement

    protected void configureTestElement(AbstractListenerElement mc)
    This provides a convenience for extenders when they implement the JMeterGUIComponent.createTestElement() method. This method will set the name, gui class, and test class for the created Test Element. It should be called by every extending class when creating Test Elements, as that will best assure consistent behavior.
    Parameters:
    mc - the TestElement being created.

    createTestElement

    public TestElement createTestElement()
    Specified by:
    createTestElement in interface JMeterGUIComponent

    getErrorLoggingCheckbox

    protected JCheckBox getErrorLoggingCheckbox()
    Returns:
    the error logging checkbox

    getFile

    public String getFile()
    Gets the filename which has been entered in the FilePanel. Subclasses don't normally need to call this method, because configuration of the FilePanel is handled in this base class.
    Returns:
    the current filename

    getFilePanel

    protected Component getFilePanel()
    Returns:
    the file panel allowing users to save results

    getModel

    protected ResultCollector getModel()
    Provides access to the ResultCollector model class for extending implementations. Using this method and setModel(ResultCollector) is only necessary if your visualizer requires a differently behaving ResultCollector. Using these methods will allow maximum reuse of the methods provided by AbstractVisualizer in this event.

    isStats

    public boolean isStats()
    Specified by:
    isStats in interface Visualizer

    makeTitlePanel

    protected Container makeTitlePanel()
    Create a standard title section for JMeter components. This includes the title for the component and the Name Panel allowing the user to change the name for the component. The AbstractVisualizer also adds the FilePanel allowing the user to save the results, and the error logging checkbox, allowing the user to choose whether or not only errors should be logged.

    This method is typically added to the top of the component at the beginning of the component's init method.

    Overrides:
    makeTitlePanel in interface AbstractJMeterGuiComponent
    Returns:
    a panel containing the component title, name panel, file panel, and error logging checkbox

    modifyTestElement

    public void modifyTestElement(TestElement c)
    Specified by:
    modifyTestElement in interface JMeterGUIComponent

    setFile

    public void setFile(String filename)
    Sets the filename which results will be saved to. This will set the filename in the FilePanel. Subclasses don't normally need to call this method, because configuration of the FilePanel is handled in this base class.
    Parameters:
    filename - the new filename

    setModel

    protected void setModel(ResultCollector collector)
    Provides extending classes the opportunity to set the ResultCollector model for the Visualizer. This is useful to allow maximum reuse of the methods from AbstractVisualizer.
    Parameters:
    collector -

    stateChanged

    public void stateChanged(ChangeEvent e)
    Invoked when the target of the listener has changed its state. This implementation assumes that the target is the FilePanel, and will update the result collector for the new filename.
    Parameters:
    e - the event that has occurred

    Copyright © 1998-2010 Apache Software Foundation. All Rights Reserved.