Package microsim.gui.plot
Class Weighted_HistogramSimulationPlotter
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.JInternalFrame
-
- microsim.gui.plot.Weighted_HistogramSimulationPlotter
-
- All Implemented Interfaces:
java.awt.image.ImageObserver
,java.awt.MenuContainer
,java.io.Serializable
,javax.accessibility.Accessible
,javax.swing.RootPaneContainer
,javax.swing.WindowConstants
,microsim.event.EventListener
public class Weighted_HistogramSimulationPlotter extends javax.swing.JInternalFrame implements microsim.event.EventListener
A Weighted_HistogramSimulationPlotter is able to display a histogram of one or more data sources that each implements the Weight interface, and can be updated during the simulation. It is based on JFreeChart library and uses data sources based on the microsim.statistics.weighted* interfaces.
Note that the weights are taken into account by adding the weight to the count of the histogram bin corresponding to the value associated with the weight. E.g, if a weighted object has value of 1.6 and weight of 5.3, the count of 5.3 is placed in the histogram bin appropriate for the value of 1.6.Title: JAS-mine
Description: Java Agent-based Simulation library
Copyright (C) 2017 Ross Richardson
This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.- Author:
- Ross Richardson
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class javax.swing.JInternalFrame
CONTENT_PANE_PROPERTY, FRAME_ICON_PROPERTY, GLASS_PANE_PROPERTY, IS_CLOSED_PROPERTY, IS_ICON_PROPERTY, IS_MAXIMUM_PROPERTY, IS_SELECTED_PROPERTY, LAYERED_PANE_PROPERTY, MENU_BAR_PROPERTY, ROOT_PANE_PROPERTY, TITLE_PROPERTY
-
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
-
-
Constructor Summary
Constructors Constructor Description Weighted_HistogramSimulationPlotter(java.lang.String title, java.lang.String xaxis, org.jfree.data.statistics.HistogramType type, int bins)
Constructor for histogram chart objects with chart legend displayed by default and all data samples shown, showing only the latest population data as time moves forward.Weighted_HistogramSimulationPlotter(java.lang.String title, java.lang.String xaxis, org.jfree.data.statistics.HistogramType type, int bins, java.lang.Double minimum, java.lang.Double maximum, boolean includeLegend)
Constructor for scatterplot chart objects, featuring a toggle to hide the chart legend and to set the minimum and maximum values displayed in the chart, with values below the minimum assigned to the first bin, and values above the maximum assigned to the last bin.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addCollectionSource(java.lang.String name, microsim.statistics.weighted.IWeightedDoubleArraySource source)
Add a new series buffer, retrieving value from IWeightedDoubleSource objects in a collection.void
addCollectionSource(java.lang.String name, microsim.statistics.weighted.IWeightedFloatArraySource source)
Add a new series buffer, retrieving value from IWeightedFloatSource objects in a collection.void
addCollectionSource(java.lang.String name, microsim.statistics.weighted.IWeightedIntArraySource source)
Add a new series buffer, retrieving value from IWeightedIntArraySource objects in a collection.void
addCollectionSource(java.lang.String name, microsim.statistics.weighted.IWeightedLongArraySource source)
Add a new series buffer, retrieving value from IWeightedLongSource objects in a collection.void
onEvent(java.lang.Enum<?> type)
void
update()
-
Methods inherited from class javax.swing.JInternalFrame
addInternalFrameListener, dispose, doDefaultCloseAction, getAccessibleContext, getContentPane, getDefaultCloseOperation, getDesktopIcon, getDesktopPane, getFocusCycleRootAncestor, getFocusOwner, getFrameIcon, getGlassPane, getInternalFrameListeners, getJMenuBar, getLastCursor, getLayer, getLayeredPane, getMenuBar, getMostRecentFocusOwner, getNormalBounds, getRootPane, getTitle, getUI, getUIClassID, getWarningString, hide, isClosable, isClosed, isFocusCycleRoot, isIcon, isIconifiable, isMaximizable, isMaximum, isResizable, isSelected, moveToBack, moveToFront, pack, remove, removeInternalFrameListener, reshape, restoreSubcomponentFocus, setClosable, setClosed, setContentPane, setCursor, setDefaultCloseOperation, setDesktopIcon, setFocusCycleRoot, setFrameIcon, setGlassPane, setIcon, setIconifiable, setJMenuBar, setLayer, setLayer, setLayeredPane, setLayout, setMaximizable, setMaximum, setMenuBar, setNormalBounds, setResizable, setSelected, setTitle, setUI, show, toBack, toFront, 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, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, 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, 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, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, 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, 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, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
-
-
-
Constructor Detail
-
Weighted_HistogramSimulationPlotter
public Weighted_HistogramSimulationPlotter(java.lang.String title, java.lang.String xaxis, org.jfree.data.statistics.HistogramType type, int bins)
Constructor for histogram chart objects with chart legend displayed by default and all data samples shown, showing only the latest population data as time moves forward. Note - values falling on the boundary of adjacent bins will be assigned to the higher indexed bin. If it is desired set the minimum and maximum values displayed, or to turn the legend off, use the constructor: HistogramSimulationPlotter(String title, String xaxis, HistogramType type, int bins, double minimum, double maximum, boolean includeLegend)- Parameters:
title
- - title of the chartxaxis
- - name of the x-axistype
- - the type of the histogram: either FREQUENCY, RELATIVE_FREQUENCY, or SCALE_AREA_TO_1bins
- - the number of bins in the histogram
-
Weighted_HistogramSimulationPlotter
public Weighted_HistogramSimulationPlotter(java.lang.String title, java.lang.String xaxis, org.jfree.data.statistics.HistogramType type, int bins, java.lang.Double minimum, java.lang.Double maximum, boolean includeLegend)
Constructor for scatterplot chart objects, featuring a toggle to hide the chart legend and to set the minimum and maximum values displayed in the chart, with values below the minimum assigned to the first bin, and values above the maximum assigned to the last bin. Note - values falling on the boundary of adjacent bins will be assigned to the higher indexed bin.- Parameters:
title
- - title of the chartxaxis
- - name of the x-axistype
- - the type of the histogram: either FREQUENCY, RELATIVE_FREQUENCY, or SCALE_AREA_TO_1bins
- - the number of bins in the histogramminimum
- - any data value less than minimum will be assigned to the first binmaximum
- - any data value greater than maximum will be assigned to the last binincludeLegend
- - toggles whether to include the legend. If displaying a very large number of different series in the chart, it may be useful to turn the legend off as it will occupy a lot of space in the GUI.maxSamples
- - the number of 'snapshots' of data displayed in the chart. Only data from the last 'maxSamples' updates will be displayed in the chart, so if the chart is updated at each 'time-step', then only the most recent 'maxSamples' time-steps will be shown on the chart. If the user wishes to accumulate all data points from the simulation run, i.e. to display all available data from all previous time-steps, set this to 0.
-
-
Method Detail
-
onEvent
public void onEvent(java.lang.Enum<?> type)
- Specified by:
onEvent
in interfacemicrosim.event.EventListener
-
update
public void update()
-
addCollectionSource
public void addCollectionSource(java.lang.String name, microsim.statistics.weighted.IWeightedDoubleArraySource source)
Add a new series buffer, retrieving value from IWeightedDoubleSource objects in a collection.- Parameters:
name
- The name of the series, which is shown in the legend.source
- A collection containing the sources.
-
addCollectionSource
public void addCollectionSource(java.lang.String name, microsim.statistics.weighted.IWeightedFloatArraySource source)
Add a new series buffer, retrieving value from IWeightedFloatSource objects in a collection.- Parameters:
name
- The name of the series, which is shown in the legend.source
- A collection containing the sources.
-
addCollectionSource
public void addCollectionSource(java.lang.String name, microsim.statistics.weighted.IWeightedIntArraySource source)
Add a new series buffer, retrieving value from IWeightedIntArraySource objects in a collection.- Parameters:
name
- The name of the series, which is shown in the legend.source
- A collection containing the sources.
-
addCollectionSource
public void addCollectionSource(java.lang.String name, microsim.statistics.weighted.IWeightedLongArraySource source)
Add a new series buffer, retrieving value from IWeightedLongSource objects in a collection.- Parameters:
name
- The name of the series, which is shown in the legend.source
- A collection containing the sources.
-
-