public class BallotGraph extends Graph
javax.swing.JPanel.AccessibleJPanel
javax.swing.JComponent.AccessibleJComponent
ABOVE, BELOW, HORIZONTAL, LEFT, RIGHT, showModelDistribution, VERTICAL
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Constructor and Description |
---|
BallotGraph()
This defaut constructor creates a new ballot graphs with winner total 50 and
lose count 30.
|
BallotGraph(int a,
int b)
This general constructor creates a new ballot graph with specified values of
the winner total (the number of votes that the winner receives) and loser total
(the number of votes that the loser receives).
|
Modifier and Type | Method and Description |
---|---|
void |
countVotes()
This method randomly counts the votes.
|
java.awt.Color |
getGraphColor()
This method returns the color for the graph of the random walk (the
winners lead as a function of the number of votes counted).
|
int |
getLoserTotal()
This method returns the total number of votes that the loser receives.
|
double |
getProbability()
This method gets the probability of the ballot event.
|
int |
getVoteTotal()
This method returns the total number of votes.
|
int[] |
getWinnerLead()
This method gets the array of winner leads.
|
int |
getWinnerLead(int i)
This method gets the winner lead at a specified time index.
|
int |
getWinnerTotal()
This method returns the total number of votes that the winner receives.
|
boolean |
isVotesCounted()
This method gets the state of the votes counted variable
|
boolean |
isWinnerAlwaysAhead()
This method gets the state of the ballot event (true or false).
|
void |
paintComponent(java.awt.Graphics g)
This method draws the graph of the random walk.
|
void |
reset()
This method resets the balot graph.
|
void |
setGraphColor(java.awt.Color c)
This method sets the color for the graph of the random walk (the
winners lead as a function of the number of votes counted).
|
void |
setLoserTotal(int b)
This method sets the total number of votes that the loser receives.
|
void |
setParameters(int a,
int b)
This method sets the basic parameters: the winner count and loser count.
|
void |
setWinnerTotal(int a)
This method sets the total number of votes that the winner receives.
|
drawAxis, drawAxis, drawAxis, drawBox, drawBox, drawBoxPlot, drawBoxPlot, drawCircle, drawLabel, drawLine, drawPoint, drawTick, drawTick, fillBox, fillBox, fillBoxPlot, fillBoxPlot, fillCircle, format, getBottomMargin, getLeftMargin, getPointSize, getRightMargin, getTopMargin, getXGraph, getXMax, getXMin, getXPixels, getXScale, getYGraph, getYMax, getYMin, getYPixels, getYScale, setMargins, setPointSize, setScale, setShowModelDistribution
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, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, 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, hide, 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
public BallotGraph(int a, int b)
a
- the winner count.b
- the loser count.public BallotGraph()
public void setParameters(int a, int b)
a
- the winner countb
- the loser count.public void setWinnerTotal(int a)
a
- the winner totalpublic int getWinnerTotal()
public void setLoserTotal(int b)
b
- the loser totalpublic int getLoserTotal()
public int getVoteTotal()
public void countVotes()
public int getWinnerLead(int i)
i
- the indexpublic int[] getWinnerLead()
public boolean isWinnerAlwaysAhead()
public boolean isVotesCounted()
public double getProbability()
public void paintComponent(java.awt.Graphics g)
paintComponent
in class javax.swing.JComponent
public void reset()
public void setGraphColor(java.awt.Color c)
c
- the graph colorpublic java.awt.Color getGraphColor()