|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectpapaya.Visuals
public class Visuals
Visuals is the parent class behind most of the other plotting classes.
It: 1. Contains some useful functions for the visual representation of your data (e.g. setting up your font, writing labels, mapping arrays to the plot right-left-top-bottom parameters, xTicks, yTicks, etc.) that should help you reduce the amount of code you end up writing. 2. Is extended by the available "Plotting" classes used to quickly give a visual snapshot of your data.
Field Summary | |
---|---|
int |
bgColor
Specifies the plot background color |
Fields inherited from interface papaya.PapayaConstants |
---|
BASELINE, big, biginv, BOTTOM, CENTER, CORNER, FONTNAME, GRAY, INDEX_NOT_FOUND, INDICES_NOT_FOUND, LEFT, LOGPI, MACHEP, MAXGAM, MAXLOG, MINLOG, RIGHT, SQRTH, SQTPI, STROKEWEIGHT, TEXTSIZE, TOP |
Constructor Summary | |
---|---|
Visuals(PApplet _theParent,
float _plotLeft,
float _plotTop,
float _plotWidth,
float _plotHeight)
The parent class behind the other plotting classes. |
Method Summary | |
---|---|
void |
drawAxes(int _sColor,
float _sWeight)
Draws the plot axes using a line with color _sColor, and weight _sWeight |
void |
drawRect()
Draw the plot background rectangle using the default plot dimensions and background color. |
void |
drawRect(float _left,
float _top,
float _width,
float _height,
int _rectColor)
Draws the plot background rectangle using the input dimensions and background color. |
float |
getBottom()
|
float |
getHeight()
|
float |
getLeft()
|
float |
getRight()
|
float |
getTop()
|
float |
getWidth()
|
void |
horizLine(float _xFrom,
float _xTo,
float _y,
int _sColor,
float _sWeight)
draws a horizonal line with color _sColor, and weight _sWeight |
void |
legendHoriz(float x,
float y,
int[] colors,
String[] labels)
Draws a legend going to the right with the first element situated at (x,y). |
void |
legendVert(float x,
float y,
int[] colors,
String[] labels)
Draws a legend going downwards with the first element situated at (x,y). |
void |
line(float _x1,
float _y1,
float _x2,
float _y2,
int _sColor,
float _sWeight)
Draws a straight line going from (x[0],y[0]) to (x[1],y[1]) with color _sColor, and weight _sWeight |
float[] |
mapXData(float[] data)
Maps the x-data from the range min(data) to max(data) to the plotLeft and plotLeft+plotWidth. |
float[] |
mapXData(float[] data,
float minXDat,
float maxXDat)
Maps the x-data from the range minXDat to maxXDat to the plotLeft and plotRight. |
float[] |
mapYData(float[] data)
Maps the y-data from the range min(data) to max(data) to the plotBottom and plotTop. |
float[] |
mapYData(float[] data,
float minYDat,
float maxYDat)
Maps the y-data from the range minYDat to maxYDat to the plotBottom and plotTop. |
void |
setBackgroundColor(int _backgroundColor)
|
void |
setHeight(float _plotHeight)
|
void |
setLeft(float _plotLeft)
|
void |
setTop(float _plotTop)
|
void |
setupFont(String _fontName,
int _xAlign,
int _yAlign,
int _tSize)
function for setting the font up for writing the labels |
void |
setupFont(String _fontName,
int _xAlign,
int _yAlign,
int _tSize,
int _fontColor)
overload setupFont function that takes in font color |
void |
setWidth(float _plotWidth)
|
void |
vertLine(float _yFrom,
float _yTo,
float _x,
int _sColor,
float _sWeight)
draws a vertical line with color _sColor, and weight _sWeight |
void |
writeLabels(float _text,
float _xPos,
float _yPos)
|
void |
writeLabels(PFont _plotFont,
float _text,
float _xPos,
float _yPos)
|
void |
writeLabels(PFont _plotFont,
String[] _text,
float[] _xPos,
float[] _yPos)
|
void |
writeLabels(PFont _plotFont,
String _text,
float _xPos,
float _yPos)
|
void |
writeLabels(String _text,
float _xPos,
float _yPos)
|
void |
writeTitle(String _title,
PFont _plotFont)
titles the plot given the String _title and the PFont |
void |
xLabels(float _left,
float _width,
float _xDatMin,
float _xDatMax,
int _numDiv)
Write the x-axis labels. |
void |
xLabels(float _left,
float _width,
String[] _xLabels)
Write the x-axis labels. |
void |
xTicks(float _left,
float _width,
int _numDiv,
int _tickHeight)
Draws the x-axis tickmarks. |
void |
yLabels(float _top,
float _height,
float _yDatMin,
float _yDatMax,
int _numDiv)
Write the y-axis labels. |
void |
yLabels(float _top,
float _height,
String[] _yLabels)
Write the y-axis labels. |
void |
YLines(int _numDiv)
Draws horizontal y-lines on the plot |
void |
yTicks(float _top,
float _height,
int _numDiv,
int _tickWidth)
Draws the y-axis tickmarks. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public int bgColor
Constructor Detail |
---|
public Visuals(PApplet _theParent, float _plotLeft, float _plotTop, float _plotWidth, float _plotHeight)
Visuals contains some useful functions for the (elementary!) visual representation of your data (e.g. setting up your font, writing labels, mapping arrays to the plot right-left-top-bottom parameters, xTicks, yTicks,legends, etc). Nothing very fancy like writing x-labels at an angle or computing your tax returns for you though so don't get your hopes up. Sorry.
_theParent
- the Processing papplet. Just "this" in your sketch._plotLeft
- the plot left_plotTop
- the plot top (in Processing coordinates!)_plotWidth
- the plot width_plotHeight
- the plot height.
The bottom of the plot area is then given by _plotTop + _plotHeight
while the right is _plotLeft + _plotWidth
.
Method Detail |
---|
public float[] mapXData(float[] data)
mappedData[i] = plotLeft + (data[i] - min) / (max-min) * plotWidth
.
This is not done directly though, but rather, the
Mat.map(float[] data, float low1, float high1, float low2, float high2)
function is used.
data
- the x data to map.
public float[] mapXData(float[] data, float minXDat, float maxXDat)
mappedData[i] = plotLeft + (data[i] - minXDat) / (maxXDat-minXDat) * plotWidth
.
This is not done directly though, but rather, the
Mat.map(float[] data, float low1, float high1, float low2, float high2)
function is used.
Note: No internal checks are done to make sure that the min/max values are in the data range.
data
- the x data to map.minXDat
- the minimum value to use in the data mapping.maxXDat
- the maximum value to use in the data mapping.
public float[] mapYData(float[] data)
mappedData[i] = plotBottom + (data[i] - min) / (max-min) * (-plotHeight)
.
(The minus sign above accounts for the difference in Processing's coordinate system
and what we associate with Top/Bottom).
The computation above is not done directly though, but rather, the
Mat.map(float[] data, float low1, float high1, float low2, float high2)
function is used.
data
- the y data to map.
public float[] mapYData(float[] data, float minYDat, float maxYDat)
mappedData[i] = plotBottom + (data[i] - minYDat) / (maxYDat-minYDat) * (-plotHeight)
.
(The minus sign above accounts for the difference in Processing's coordinate system
and what we associate with Top/Bottom).
The computation above is not done directly though, but rather, the
Mat.map(float[] data, float low1, float high1, float low2, float high2)
function is used.
Note: No internal checks are done to make sure that the min/max values are in the data range.
data
- the x data to map.minYDat
- the minimum value to use in the data mapping.maxYDat
- the maximum value to use in the data mapping.
public void drawAxes(int _sColor, float _sWeight)
public void drawRect()
public void drawRect(float _left, float _top, float _width, float _height, int _rectColor)
_left
- the left-most point of the rectangle_top
- the top-most point of the rectangle_width
- the width of the rectangle_height
- the height of the rectangle_rectColor
- the rectangle color.public void legendVert(float x, float y, int[] colors, String[] labels)
colors
- the legend colorslabels
- labels that go with each colorpublic void legendHoriz(float x, float y, int[] colors, String[] labels)
colors
- the legend colorslabels
- labels that go with each colorpublic void xTicks(float _left, float _width, int _numDiv, int _tickHeight)
_left
- left most tick position. Set to negative to make it default
to the plotLeft)_width
- (_left + _width) = right most tick position. Set to negative_numDiv
- the number of divisions. The number of tick marks drawn = _numDiv+1._tickHeight
- the height of the tick mark.public void xLabels(float _left, float _width, float _xDatMin, float _xDatMax, int _numDiv)
_left
- left most label position. Set to negative to make it default
to the plotLeft)_width
- (_left + _width) = right most label position. Set to negative
to make it default to the plotWidth_xDatMin
- minimum data value to show in the label_xDatMax
- maximum data value to show in the label_numDiv
- the number of divisions.public void xLabels(float _left, float _width, String[] _xLabels)
_left
- left most label position. Set to negative to make it default
to the plotLeft)_width
- (_left + _width) = right most label position. Set to negative
to make it default to the plotWidth_xLabels
- the String array of labels.public void yTicks(float _top, float _height, int _numDiv, int _tickWidth)
_top
- top most tick position in Processing's coordinate system.
Set to negative to make it default to the plotTop)_height
- (top + height) = bottom most label position in Processing's coordinate system.
Set to negative to make it default to the plotHeight._numDiv
- the number of divisions. The number of tick marks drawn = _numDiv+1._tickWidth
- the width of the tick mark.public void yLabels(float _top, float _height, float _yDatMin, float _yDatMax, int _numDiv)
_top
- top most label position in Processing's coordinate system.
Set to negative to make it default to the plotTop)_height
- (top + height) = bottom most label positionin Processing's coordinate system.
Set to negative to make it default to the plotHeight._yDatMin
- minimum data value to show in the label_yDatMax
- maximum data value to show in the label_numDiv
- the number of divisions.public void yLabels(float _top, float _height, String[] _yLabels)
_top
- top most label position in Processing's coordinate system.
Set to negative to make it default to the plotTop)_height
- (top + height) = bottom most label positionin Processing's coordinate system.
Set to negative to make it default to the plotHeight._yLabels
- the String array of labels.public void YLines(int _numDiv)
_numDiv
- number of divisions. The number of lines drawn = numDiv+1public void horizLine(float _xFrom, float _xTo, float _y, int _sColor, float _sWeight)
public void vertLine(float _yFrom, float _yTo, float _x, int _sColor, float _sWeight)
public void line(float _x1, float _y1, float _x2, float _y2, int _sColor, float _sWeight)
public void writeTitle(String _title, PFont _plotFont)
public void writeLabels(PFont _plotFont, String[] _text, float[] _xPos, float[] _yPos)
public void writeLabels(PFont _plotFont, String _text, float _xPos, float _yPos)
public void writeLabels(PFont _plotFont, float _text, float _xPos, float _yPos)
public void writeLabels(float _text, float _xPos, float _yPos)
public void writeLabels(String _text, float _xPos, float _yPos)
public void setupFont(String _fontName, int _xAlign, int _yAlign, int _tSize)
public void setupFont(String _fontName, int _xAlign, int _yAlign, int _tSize, int _fontColor)
public void setBackgroundColor(int _backgroundColor)
public float getLeft()
public float getRight()
public float getTop()
public float getBottom()
public float getWidth()
public float getHeight()
public void setLeft(float _plotLeft)
public void setWidth(float _plotWidth)
public void setTop(float _plotTop)
public void setHeight(float _plotHeight)
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |