|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.gicentre.utils.stat.LikertChart
public class LikertChart
Class for storing and drawing Likert scaled data. That is, a set of frequencies in an ordered dataset. Typically, these are questionnaire responses in the form 'strongly disagree', 'disagree', 'neutral', 'agree' and 'strongly agree'. Likert scales can be over any range, but are typically between 3 and 7 and usually odd.
Constructor Summary | |
---|---|
LikertChart(float[] frequencies)
Creates a Likert chart of the given set of frequencies. |
|
LikertChart(float[] frequencies,
float maxHeight,
float minHeight)
Creates a Likert chart of the given set of frequencies scaled to the given maximum and minimum value. |
|
LikertChart(float[] frequencies,
float numDontKnow,
float numNA,
float numMissing,
java.lang.String title)
Creates a Likert chart of the given set of frequencies and non-responses and the given short title. |
|
LikertChart(float[] frequencies,
float numDontKnow,
float numNA,
float numMissing,
java.lang.String title,
java.lang.String longTitle)
Creates a Likert chart of the given set of frequencies and non-responses and the given titles. |
Method Summary | |
---|---|
void |
animateFromBars()
Triggers an animation away from a histogram representation to the summary state. |
void |
animateToBars()
Triggers an animation to a histogram representation from the summary state. |
void |
animateToNewValues(float[] newFrequencies,
float newNumDontKnow,
float newNumNA,
float newNumMissing)
Provides an animated transition to the given set of values. |
void |
draw(processing.core.PApplet parent,
java.awt.geom.Rectangle2D bounds)
Draws the Likert chart within the given rectangle but without any text labelling. |
void |
draw(processing.core.PApplet parent,
java.awt.geom.Rectangle2D bounds,
processing.core.PFont font)
Draws the Likert chart within the given rectangle with text labelling in the given font. |
float |
getAnimationSpeed()
Reports the animation speed for all transitions (e.g. |
int |
getBarAt(float xCoord,
float yCoord)
Reports the bar at the given (x,y) location. |
float |
getConsensus()
Reports the consensus score of this Likert distribution. |
static java.util.Comparator<LikertChart> |
getConsensusComparator()
Provides a comparator that can be used for sorting Likert charts by their consensus scores. |
static java.util.Comparator<LikertChart> |
getCustomComparator()
Provides a custom comparator that can be used for sorting Likert charts in the order implied by the values provided to setOrder() . |
float[] |
getFrequencies()
Reports the frequency values that are used to produce the Likert chart. |
int |
getHighlightBar()
Reports the index of the currently highlighted bar or -1 if no bar highlighted. |
java.lang.String |
getLongTitle()
Reports the long title of this Likert chart. |
float |
getMean()
Reports the mean score of this Likert distribution. |
static java.util.Comparator<LikertChart> |
getMeanComparator()
Provides a comparator that can be used for sorting Likert charts by their mean scores. |
float |
getOrder()
Reports the order value used for custom ordering of a collection of Likert charts. |
int |
getSecondaryColour()
Reports the colour to be used for the secondary data in the chart. |
LikertChart |
getSecondaryData()
Reports the seconday data that may be drawn in this chart. |
int |
getTextColour()
Reports the colour to be used for the title of the chart and any other text. |
float |
getTextPadding()
Reports the extra padding between title and chart. |
float |
getTextSize()
Reports the size of the title text in pixels or -1 if text size is calculated automatically. |
java.lang.String |
getTitle()
Reports the title of this Likert chart. |
float |
getWidthScale()
Reports the proportion of the width allocated to each bar that contains a coloured bar. |
void |
setAnimationSpeed(float numFrames)
Sets the animation speed for all transitions (e.g. |
void |
setColourTable(ColourTable cTable)
Sets the colour table to be used to show the Likert chart. |
void |
setHighlightBar(int barIndex)
Allows a bar to be highlighted or highlight removed. |
void |
setOrder(float order)
Sets the order value used for custom ordering of a collection of Likert charts. |
void |
setScaleToPrimary(boolean usePrimary)
Determines whether bars are scaled to the primary data values or the secondary data values (if they exist). |
void |
setSecondaryChart(LikertChart secondaryChart)
Add a secondary chart to the Likert chart. |
void |
setSecondaryColour(int colour)
Sets the colour to be used for the secondary data in the chart. |
void |
setSecondaryDisplay(boolean showSecondary)
Determines whether or not the secondary chart can be displayed. |
void |
setSecondaryLineWidth(float width)
Sets the width of the secondary line symbolisation. |
void |
setShowBars(boolean showBars)
Determines if histogram bars should be shown. |
void |
setShowTitle(boolean showTitle)
Determines whether or not the title is displayed on the chart. |
void |
setTextColour(int colour)
Sets the colour to be used for displaying the title of the chart. |
void |
setTextPadding(float padding)
Sets the extra padding between title and chart. |
void |
setTextSize(float size)
Sets the size of the title text in pixels or -1 if text size is to be calculated automatically. |
void |
setWidthScale(float widthScale)
Sets the proportion of the width allocated to each bar that contains a coloured bar. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public LikertChart(float[] frequencies)
frequencies
- An ordered set of frequencies.public LikertChart(float[] frequencies, float maxHeight, float minHeight)
frequencies
- An ordered set of frequencies.maxHeight
- Maximum value by which the chart bars are scaled.minHeight
- Minimum value by which the chart bars are scaled.public LikertChart(float[] frequencies, float numDontKnow, float numNA, float numMissing, java.lang.String title)
frequencies
- An ordered set of frequencies.numDontKnow
- Number of 'Don't know' responses.numNA
- Number of 'not applicable' responses.numMissing
- Number of missing responses. This value can be used to provide
a fixed vertical scaling of several Likert charts.title
- Short title of chart or null if no title is to be shown.public LikertChart(float[] frequencies, float numDontKnow, float numNA, float numMissing, java.lang.String title, java.lang.String longTitle)
frequencies
- An ordered set of frequencies.numDontKnow
- Number of 'Don't know' responses.numNA
- Number of 'not applicable' responses.numMissing
- Number of missing responses. This value can be used to provide
a fixed vertical scaling of several Likert charts.title
- Short title of chart or null if no title is to be shown.longTitle
- Long title of chart or null if no long title is to be shown.Method Detail |
---|
public void draw(processing.core.PApplet parent, java.awt.geom.Rectangle2D bounds)
parent
- Processing applet in which to draw the chart.bounds
- Rectangle within which to scale the chart.public void draw(processing.core.PApplet parent, java.awt.geom.Rectangle2D bounds, processing.core.PFont font)
parent
- Processing applet in which to draw the chart.bounds
- Rectangle within which to scale the chart.font
- Font used to display text, or null if no text to be displayed.public void setColourTable(ColourTable cTable)
cTable
value should be null.
cTable
- Colour table to use for showing Likert chart.public void setWidthScale(float widthScale)
widthScale
- Proportion of the width allocated to each bar that is drawn.
Should be scaled between 0 and 1.public void setShowBars(boolean showBars)
showBars
- Bars are shown if true.public void setSecondaryChart(LikertChart secondaryChart)
setSecondaryDisplay(false)
.
secondaryChart
- Second set of data to display in chart, or null if no secondary data to be displayed.public void setSecondaryDisplay(boolean showSecondary)
showSecondary
- Secondary data displayed if true and they exist, otherwise no secondary data displayed.public void setSecondaryColour(int colour)
colour
- Colour to be used for secondary data (using Processing's integer colour format).public void setSecondaryLineWidth(float width)
width
- Width of lines used to draw Likert summary symbols (can be fractions of a pixel).public int getSecondaryColour()
public void setTextColour(int colour)
colour
- Colour to be used for chart title and any other text (using Processing's integer colour format).public int getTextColour()
public void setHighlightBar(int barIndex)
barIndex
- Index of the bar to highlight or -1 if no bar is to be highlighted.public int getHighlightBar()
public int getBarAt(float xCoord, float yCoord)
xCoord
- x screen coordinate of point to query.yCoord
- y screen coordinate of point to query.
public void animateToBars()
public void animateFromBars()
public void animateToNewValues(float[] newFrequencies, float newNumDontKnow, float newNumNA, float newNumMissing)
newFrequencies
- Frequency distribution of the new values to represent in the chart.newNumDontKnow
- Number of 'don't know' answers in the target distribution.newNumNA
- Number of Not Applicable answers in the target distribution.newNumMissing
- Number of missing values in the target distribution.public float getWidthScale()
public float[] getFrequencies()
public LikertChart getSecondaryData()
public void setScaleToPrimary(boolean usePrimary)
usePrimary
- Bars are scaled to primary values if true or secondary values if false and
there are secondary values to show.public void setShowTitle(boolean showTitle)
showTitle
- Title displayed if true.public java.lang.String getTitle()
public java.lang.String getLongTitle()
public float getMean()
public float getConsensus()
public void setOrder(float order)
order
- Order value used when providing a custom sort of charts.public void setAnimationSpeed(float numFrames)
numFrames
- Number of frames to complete a transition.public float getAnimationSpeed()
public void setTextSize(float size)
size
- Title text size in pixels.public float getTextSize()
public void setTextPadding(float padding)
padding
- Number of extra pixels between the title and the chart.public float getTextPadding()
public float getOrder()
public static java.util.Comparator<LikertChart> getCustomComparator()
setOrder()
. If two Likert
charts have the same order value, they are sorted into a consistent but
platform dependent order.
public static java.util.Comparator<LikertChart> getMeanComparator()
public static java.util.Comparator<LikertChart> getConsensusComparator()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |