public class GLayer extends Object implements PConstants
ADD, ALPHA, ALT, AMBIENT, ARC, ARGB, ARROW, BACKSPACE, BASELINE, BEVEL, BEZIER_VERTEX, BLEND, BLUR, BOTTOM, BOX, BREAK, BURN, CENTER, CHATTER, CHORD, CLAMP, CLOSE, CODED, COMPLAINT, CONTROL, CORNER, CORNERS, CROSS, CURVE_VERTEX, CUSTOM, DARKEST, DEG_TO_RAD, DELETE, DIAMETER, DIFFERENCE, DILATE, DIRECTIONAL, DISABLE_ASYNC_SAVEFRAME, DISABLE_BUFFER_READING, DISABLE_DEPTH_MASK, DISABLE_DEPTH_SORT, DISABLE_DEPTH_TEST, DISABLE_KEY_REPEAT, DISABLE_NATIVE_FONTS, DISABLE_OPENGL_ERRORS, DISABLE_OPTIMIZED_STROKE, DISABLE_STROKE_PERSPECTIVE, DISABLE_STROKE_PURE, DISABLE_TEXTURE_MIPMAPS, DODGE, DOWN, DXF, ELLIPSE, ENABLE_ASYNC_SAVEFRAME, ENABLE_BUFFER_READING, ENABLE_DEPTH_MASK, ENABLE_DEPTH_SORT, ENABLE_DEPTH_TEST, ENABLE_KEY_REPEAT, ENABLE_NATIVE_FONTS, ENABLE_OPENGL_ERRORS, ENABLE_OPTIMIZED_STROKE, ENABLE_STROKE_PERSPECTIVE, ENABLE_STROKE_PURE, ENABLE_TEXTURE_MIPMAPS, ENTER, EPSILON, ERODE, ESC, EXCLUSION, FX2D, GIF, GRAY, GROUP, HALF_PI, HAND, HARD_LIGHT, HINT_COUNT, HSB, IMAGE, INVERT, JAVA2D, JPEG, LANDSCAPE, LEFT, LIGHTEST, LINE, LINE_LOOP, LINE_STRIP, LINES, LINUX, MACOSX, MAX_FLOAT, MAX_INT, MIN_FLOAT, MIN_INT, MITER, MODEL, MODELVIEW, MOVE, MULTIPLY, NORMAL, OPAQUE, OPEN, OPENGL, ORTHOGRAPHIC, OTHER, OVERLAY, P2D, P3D, PATH, PDF, PERSPECTIVE, PI, PIE, platformNames, POINT, POINTS, POLYGON, PORTRAIT, POSTERIZE, PROBLEM, PROJECT, PROJECTION, QUAD, QUAD_BEZIER_VERTEX, QUAD_STRIP, QUADRATIC_VERTEX, QUADS, QUARTER_PI, RAD_TO_DEG, RADIUS, RECT, REPEAT, REPLACE, RETURN, RGB, RIGHT, ROUND, SCREEN, SHAPE, SHIFT, SOFT_LIGHT, SPAN, SPHERE, SPOT, SQUARE, SUBTRACT, SVG, TAB, TARGA, TAU, TEXT, THIRD_PI, THRESHOLD, TIFF, TOP, TRIANGLE, TRIANGLE_FAN, TRIANGLE_STRIP, TRIANGLES, TWO_PI, UP, VERTEX, WAIT, WHITESPACE, WINDOWS, X, Y, Z| Constructor and Description |
|---|
GLayer(PApplet parent,
String id,
float[] dim,
float[] xLim,
float[] yLim,
boolean xLog,
boolean yLog)
GLayer constructor
|
| Modifier and Type | Method and Description |
|---|---|
void |
addPoint(float x,
float y)
Adds a new point to the layer points
|
void |
addPoint(float x,
float y,
String label)
Adds a new point to the layer points
|
void |
addPoint(GPoint newPoint)
Adds a new point to the layer points
|
void |
addPoint(int index,
float x,
float y)
Adds a new point to the layer points
|
void |
addPoint(int index,
float x,
float y,
String label)
Adds a new point to the layer points
|
void |
addPoint(int index,
GPoint newPoint)
Adds a new point to the layer points
|
void |
addPoints(GPointsArray newPoints)
Adds new points to the layer points
|
void |
drawAnnotation(String text,
float x,
float y,
int horAlign,
int verAlign)
Draws an annotation at a given plot value
|
void |
drawFilledContour(int contourType,
float referenceValue)
Draws a filled contour connecting consecutive points in the layer and a
reference value
|
void |
drawHistogram()
Draws the histogram
|
void |
drawHorizontalLine(float value)
Draws an horizontal line
|
void |
drawHorizontalLine(float value,
int lc,
float lw)
Draws an horizontal line
|
void |
drawLabel(GPoint point)
Draws the label of a given point
|
void |
drawLabelAtPlotPos(float xPlot,
float yPlot)
Draws the label of the closest point in the layer to a given plot
position
|
void |
drawLine(float slope,
float yCut)
Draws a line defined by the slope and the cut in the y axis
|
void |
drawLine(float slope,
float yCut,
int lc,
float lw)
Draws a line defined by the slope and the cut in the y axis
|
void |
drawLine(GPoint point1,
GPoint point2)
Draws a line between two points
|
void |
drawLine(GPoint point1,
GPoint point2,
int lc,
float lw)
Draws a line between two points
|
void |
drawLines()
Draws lines connecting consecutive points in the layer
|
void |
drawPoint(GPoint point)
Draws a point
|
void |
drawPoint(GPoint point,
int pointColor,
float pointSize)
Draws a point
|
void |
drawPoint(GPoint point,
PImage pointImg)
Draws a point
|
void |
drawPoint(GPoint point,
PShape pointShape)
Draws a point
|
void |
drawPoint(GPoint point,
PShape pointShape,
int pointColor)
Draws a point
|
void |
drawPoints()
Draws the points inside the layer limits
|
void |
drawPoints(PImage pointImg)
Draws the points inside the layer limits
|
void |
drawPoints(PShape pointShape)
Draws the points inside the layer limits
|
void |
drawPolygon(GPointsArray polygonPoints,
int polygonColor)
Draws a polygon defined by a set of points
|
void |
drawVerticalLine(float value)
Draws a vertical line
|
void |
drawVerticalLine(float value,
int lc,
float lw)
Draws a vertical line
|
float[] |
getDim()
Returns the layer dimensions
|
GHistogram |
getHistogram()
Returns the layer histogram
|
String |
getId()
Returns the layer id
|
int |
getLineColor()
Returns the layer line color
|
float |
getLineWidth()
Returns the layer line width
|
GPoint |
getPointAtPlotPos(float xPlot,
float yPlot)
Returns the closest point (if any) to a given position in the plot
reference system
|
int[] |
getPointColors()
Returns the layer point colors array
|
int |
getPointIndexAtPlotPos(float xPlot,
float yPlot)
Returns the position index of the closest point (if any) to a given
position in the plot reference system
|
GPointsArray |
getPoints()
Returns a copy of the layer points
|
float[] |
getPointSizes()
Returns the layer point sizes array
|
GPointsArray |
getPointsRef()
Returns the layer points
|
float[] |
getXLim()
Returns the layer horizontal limits
|
boolean |
getXLog()
Returns the layer horizontal scale
|
float[] |
getYLim()
Returns the layer vertical limits
|
boolean |
getYLog()
Returns the layer vertical scale
|
boolean |
isId(String someId)
Checks if the layer's id is equal to a given id
|
boolean |
isInside(float xPlot,
float yPlot)
Checks if a given (xPlot, yPlot) position in the plot reference system is
inside the layer limits
|
boolean |
isInside(GPoint plotPoint)
Checks if a given point in the plot reference system is inside the layer
limits
|
boolean[] |
isInside(GPointsArray plotPts)
Checks if a given set of points in the plot reference system is inside
the layer limits
|
float[] |
plotToValue(float xPlot,
float yPlot)
Returns the plot values at a given position in the plot reference system
|
void |
removePoint(int index)
Removes one of the layer points
|
void |
setAllFontProperties(String newFontName,
int newFontColor,
int newFontSize)
Sets the font properties in the layer and the histogram
|
void |
setDim(float[] newDim)
Sets the layer dimensions, which should be equal to the plot box
dimensions
|
void |
setDim(float xDim,
float yDim)
Sets the layer dimensions
|
void |
setDrawHistLabels(boolean drawHistLabels)
Sets if the histogram labels will be drawn or not
|
void |
setFontColor(int newFontColor)
Sets the font color
|
void |
setFontName(String newFontName)
Sets the font name
|
void |
setFontProperties(String newFontName,
int newFontColor,
int newFontSize)
Sets all the font properties at once
|
void |
setFontSize(int newFontSize)
Sets the font size
|
void |
setHistBasePoint(GPoint newHistBasePoint)
Sets the histogram base point
|
void |
setHistType(int histType)
Sets the histogram type
|
void |
setHistVisible(boolean visible)
Sets if the histogram is visible or not
|
void |
setInside(boolean[] newInside)
Sets which points are inside the box
|
void |
setLabelBgColor(int newLabelBgColor)
Sets the label background color
|
void |
setLabelSeparation(float[] newLabelSeparation)
Sets the label separation
|
void |
setLimAndLog(float[] newXLim,
float[] newYLim,
boolean newXLog,
boolean newYLog)
Sets the horizontal and vertical limits and the horizontal and vertical
scales
|
void |
setLimAndLog(float xMin,
float xMax,
float yMin,
float yMax,
boolean newXLog,
boolean newYLog)
Sets the horizontal and vertical limits and the horizontal and vertical
scales
|
void |
setLineColor(int newLineColor)
Sets the line color
|
void |
setLineWidth(float newLineWidth)
Sets the line width
|
void |
setPoint(int index,
float x,
float y)
Sets one of the layer points
|
void |
setPoint(int index,
float x,
float y,
String label)
Sets one of the layer points
|
void |
setPoint(int index,
GPoint newPoint)
Sets one of the layer points
|
void |
setPointColor(int newPointColor)
Sets the points color
|
void |
setPointColors(int[] newPointColors)
Sets the points colors
|
void |
setPoints(GPointsArray newPoints)
Sets the layer points
|
void |
setPointSize(float newPointSize)
Sets the points size
|
void |
setPointSizes(float[] newPointSizes)
Sets the points sizes
|
void |
setXLim(float[] newXLim)
Sets the horizontal limits
|
void |
setXLim(float xMin,
float xMax)
Sets the horizontal limits
|
void |
setXLog(boolean newXLog)
Sets the horizontal scale
|
void |
setXYLim(float[] newXLim,
float[] newYLim)
Sets the horizontal and vertical limits
|
void |
setXYLim(float xMin,
float xMax,
float yMin,
float yMax)
Sets the horizontal and vertical limits
|
void |
setYLim(float[] newYLim)
Sets the vertical limits
|
void |
setYLim(float yMin,
float yMax)
Sets the vertical limits
|
void |
setYLog(boolean newYLog)
Sets the vertical scale
|
void |
startHistogram(int histType)
Initializes the histogram
|
float[] |
valueToPlot(float x,
float y)
Calculates the position of a given (x, y) point in the plot reference
system
|
GPoint |
valueToPlot(GPoint point)
Calculates the position of a given point in the plot reference system
|
GPointsArray |
valueToPlot(GPointsArray pts)
Calculates the positions of a given set of points in the plot reference
system
|
float |
valueToXPlot(float x)
Calculates the position of the x value in the plot reference system
|
float |
valueToYPlot(float y)
Calculates the position of the y value in the plot reference system
|
public GLayer(PApplet parent, String id, float[] dim, float[] xLim, float[] yLim, boolean xLog, boolean yLog)
parent - the parent Processing appletid - the layer iddim - the plot box dimensions in pixelsxLim - the horizontal limitsyLim - the vertical limitsxLog - the horizontal scale. True if it's logarithmicyLog - the vertical scale. True if it's logarithmicpublic boolean isId(String someId)
someId - the id to checkpublic float valueToXPlot(float x)
x - the x valuepublic float valueToYPlot(float y)
y - the y valuepublic float[] valueToPlot(float x,
float y)
x - the x valuey - the y valuepublic GPoint valueToPlot(GPoint point)
point - the pointpublic GPointsArray valueToPlot(GPointsArray pts)
pts - the set of pointspublic float[] plotToValue(float xPlot,
float yPlot)
xPlot - x position in the plot reference systemyPlot - y position in the plot reference systempublic boolean isInside(float xPlot,
float yPlot)
xPlot - x position in the plot reference systemyPlot - y position in the plot reference systempublic boolean isInside(GPoint plotPoint)
plotPoint - the point in the plot reference systempublic boolean[] isInside(GPointsArray plotPts)
plotPts - the set of points to checkpublic int getPointIndexAtPlotPos(float xPlot,
float yPlot)
xPlot - x position in the plot reference systemyPlot - y position in the plot reference systempublic GPoint getPointAtPlotPos(float xPlot, float yPlot)
xPlot - x position in the plot reference systemyPlot - y position in the plot reference systempublic void startHistogram(int histType)
histType - the type of histogram to use. It can be GPlot.VERTICAL or
GPlot.HORIZONTALpublic void drawPoints()
public void drawPoints(PShape pointShape)
pointShape - the shape that should be used to represent the pointspublic void drawPoints(PImage pointImg)
pointImg - the image that should be used to represent the pointspublic void drawPoint(GPoint point, int pointColor, float pointSize)
point - the point to drawpointColor - color to usepointSize - point size in pixelspublic void drawPoint(GPoint point)
point - the point to drawpublic void drawPoint(GPoint point, PShape pointShape)
point - the point to drawpointShape - the shape that should be used to represent the pointpublic void drawPoint(GPoint point, PShape pointShape, int pointColor)
point - the point to drawpointShape - the shape that should be used to represent the pointspointColor - color to usepublic void drawPoint(GPoint point, PImage pointImg)
point - the point to drawpointImg - the image that should be used to represent the pointpublic void drawLines()
public void drawLine(GPoint point1, GPoint point2, int lc, float lw)
point1 - first pointpoint2 - second pointlc - line colorlw - line widthpublic void drawLine(GPoint point1, GPoint point2)
point1 - first pointpoint2 - second pointpublic void drawLine(float slope,
float yCut,
int lc,
float lw)
slope - the line slopeyCut - the line y axis cutlc - line colorlw - line widthpublic void drawLine(float slope,
float yCut)
slope - the line slopeyCut - the line y axis cutpublic void drawHorizontalLine(float value,
int lc,
float lw)
value - line horizontal valuelc - line colorlw - line widthpublic void drawHorizontalLine(float value)
value - line horizontal valuepublic void drawVerticalLine(float value,
int lc,
float lw)
value - line vertical valuelc - line colorlw - line widthpublic void drawVerticalLine(float value)
value - line vertical valuepublic void drawFilledContour(int contourType,
float referenceValue)
contourType - the type of contours to use. It can be GPlot.VERTICAL or
GPlot.HORIZONTALreferenceValue - the reference value to use to close the contourpublic void drawLabel(GPoint point)
point - the pointpublic void drawLabelAtPlotPos(float xPlot,
float yPlot)
xPlot - x position in the plot reference systemyPlot - y position in the plot reference systempublic void drawHistogram()
public void drawPolygon(GPointsArray polygonPoints, int polygonColor)
polygonPoints - the points that define the polygonpolygonColor - the color to use to draw the polygon (contour and background)public void drawAnnotation(String text, float x, float y, int horAlign, int verAlign)
text - the annotation textx - x plot valuey - y plot valuehorAlign - text horizontal alignment. It can be RIGHT, LEFT or CENTERverAlign - text vertical alignment. It can be TOP, BOTTOM or CENTERpublic void setDim(float xDim,
float yDim)
xDim - the new layer x dimensionyDim - the new layer y dimensionpublic void setDim(float[] newDim)
newDim - the new layer dimensionspublic void setXLim(float xMin,
float xMax)
xMin - the minimum limit valuexMax - the maximum limit valuepublic void setXLim(float[] newXLim)
newXLim - the new horizontal limitspublic void setYLim(float yMin,
float yMax)
yMin - the minimum limit valueyMax - the maximum limit valuepublic void setYLim(float[] newYLim)
newYLim - the new vertical limitspublic void setXYLim(float xMin,
float xMax,
float yMin,
float yMax)
xMin - the minimum horizontal limit valuexMax - the maximum horizontal limit valueyMin - the minimum vertical limit valueyMax - the maximum vertical limit valuepublic void setXYLim(float[] newXLim,
float[] newYLim)
newXLim - the new horizontal limitsnewYLim - the new vertical limitspublic void setLimAndLog(float xMin,
float xMax,
float yMin,
float yMax,
boolean newXLog,
boolean newYLog)
xMin - the minimum horizontal limit valuexMax - the maximum horizontal limit valueyMin - the minimum vertical limit valueyMax - the maximum vertical limit valuenewXLog - the new horizontal scalenewYLog - the new vertical scalepublic void setLimAndLog(float[] newXLim,
float[] newYLim,
boolean newXLog,
boolean newYLog)
newXLim - the new horizontal limitsnewYLim - the new vertical limitsnewXLog - the new horizontal scalenewYLog - the new vertical scalepublic void setXLog(boolean newXLog)
newXLog - the new horizontal scalepublic void setYLog(boolean newYLog)
newYLog - the new vertical scalepublic void setPoints(GPointsArray newPoints)
newPoints - the new pointspublic void setPoint(int index,
float x,
float y,
String label)
index - the point positionx - the point new x coordinatey - the point new y coordinatelabel - the point new labelpublic void setPoint(int index,
float x,
float y)
index - the point positionx - the point new x coordinatey - the point new y coordinatepublic void setPoint(int index,
GPoint newPoint)
index - the point positionnewPoint - the new pointpublic void addPoint(float x,
float y,
String label)
x - the new point x coordinatey - the new point y coordinatelabel - the new point labelpublic void addPoint(float x,
float y)
x - the new point x coordinatey - the new point y coordinatepublic void addPoint(GPoint newPoint)
newPoint - the point to addpublic void addPoint(int index,
float x,
float y,
String label)
index - the position to add the pointx - the new point x coordinatey - the new point y coordinatelabel - the new point labelpublic void addPoint(int index,
float x,
float y)
index - the position to add the pointx - the new point x coordinatey - the new point y coordinatepublic void addPoint(int index,
GPoint newPoint)
index - the position to add the pointnewPoint - the point to addpublic void addPoints(GPointsArray newPoints)
newPoints - the points to addpublic void removePoint(int index)
index - the point positionpublic void setInside(boolean[] newInside)
newInside - a boolean array with the information whether a point is inside
or notpublic void setPointColors(int[] newPointColors)
newPointColors - the new point colorspublic void setPointColor(int newPointColor)
newPointColor - the new point colorpublic void setPointSizes(float[] newPointSizes)
newPointSizes - the new point sizespublic void setPointSize(float newPointSize)
newPointSize - the new point sizepublic void setLineColor(int newLineColor)
newLineColor - the new line colorpublic void setLineWidth(float newLineWidth)
newLineWidth - the new line widthpublic void setHistBasePoint(GPoint newHistBasePoint)
newHistBasePoint - the new histogram base pointpublic void setHistType(int histType)
histType - the new histogram type. It can be GPlot.HORIZONTAL or
GPlot.VERTICALpublic void setHistVisible(boolean visible)
visible - if true, the histogram is visiblepublic void setDrawHistLabels(boolean drawHistLabels)
drawHistLabels - if true, the histogram labels will be drawnpublic void setLabelBgColor(int newLabelBgColor)
newLabelBgColor - the new label background colorpublic void setLabelSeparation(float[] newLabelSeparation)
newLabelSeparation - the new label separationpublic void setFontName(String newFontName)
newFontName - the name of the new fontpublic void setFontColor(int newFontColor)
newFontColor - the new font colorpublic void setFontSize(int newFontSize)
newFontSize - the new font sizepublic void setFontProperties(String newFontName, int newFontColor, int newFontSize)
newFontName - the name of the new fontnewFontColor - the new font colornewFontSize - the new font sizepublic void setAllFontProperties(String newFontName, int newFontColor, int newFontSize)
newFontName - the new font namenewFontColor - the new font colornewFontSize - the new font sizepublic String getId()
public float[] getDim()
public float[] getXLim()
public float[] getYLim()
public boolean getXLog()
public boolean getYLog()
public GPointsArray getPoints()
public GPointsArray getPointsRef()
public int[] getPointColors()
public float[] getPointSizes()
public int getLineColor()
public float getLineWidth()
public GHistogram getHistogram()
Processing Library grafica by Javier Gracia Carpio. (c) 2015