Class DrawingUtil

java.lang.Object
  extended byDrawingUtil

public class DrawingUtil
extends java.lang.Object

Utility class for rendering.

Author:
Lulin Song

Constructor Summary
DrawingUtil()
           
 
Method Summary
static void drawCentred(java.awt.Graphics2D g2, java.lang.String text, float centerX, float centerY, boolean textLayoutBounds)
          Draw a text string which is centered in given location.
static void drawCircle(java.awt.Graphics2D g2d, double[] data, float[] xData, float[] yData, java.awt.Color c, float xs, float ys, float xOff, float yOff, float radius)
          Draw circles using pass in x and y coordinates.
static void drawDots(java.awt.Graphics2D g2d, float[] xData, float[] yData, float xs, float ys, java.awt.Color c, float xOff, float yOff)
          Draw points centered at (xData[i],yData[i]) and radius is 1.
 void drawLegendBox(java.awt.Graphics2D g2, int width, int ht)
          Draw the legend box.
static void drawLegendTicks(java.awt.Graphics2D g2, float startX, float startY, float endX, float endY, java.lang.String[] tickMarks, int type)
          Draw legend's tick marks.
static void drawLineSegments(java.awt.Graphics2D g2d, float[] xData, float[] yData, float xs, float ys, java.awt.Color c, float xOff, float yOff)
          Draw line segments using pass in x and y coordinates.
static void drawLineSegmentsTickMarks(java.awt.Graphics2D g2d, float[] xData, float[] yData, float xs, float ys, java.awt.Color c, float xOff, float yOff, java.lang.String[] strs)
          Draw line segments using pass in x and y coordinates.
static void drawPolyLine(java.awt.Graphics2D g2d, float[] xData, float[] yData, float xs, float ys, java.awt.Color c, float xOff, float yOff)
          Draw a poly line using pass in x and y coordinates.
static void drawRects(java.awt.Graphics2D g2d, int[][] data, java.awt.Color[] c, float xs, float ys, float xOff, float yOff)
          Draw points centered at (xData[i],yData[i]) and radius is 1.
static void drawStringsInBox(java.awt.Graphics2D g2, int width, int ht, java.lang.String[] strs, java.awt.Font f)
          Draw an array of strings in a bounding box with origin in (0,0).
static void printFontNames()
          Will print out all available english font names in the system.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DrawingUtil

public DrawingUtil()
Method Detail

drawCentred

public static void drawCentred(java.awt.Graphics2D g2,
                               java.lang.String text,
                               float centerX,
                               float centerY,
                               boolean textLayoutBounds)
Draw a text string which is centered in given location.

Parameters:
g2 - Graphics2D context in which the string will be drawn.
text - text string
centerX - center's x position
centerY - center's y position
textLayoutBounds - if true, will create a new TextLayout,otherwise use the old one

printFontNames

public static void printFontNames()
Will print out all available english font names in the system.


drawLegendTicks

public static void drawLegendTicks(java.awt.Graphics2D g2,
                                   float startX,
                                   float startY,
                                   float endX,
                                   float endY,
                                   java.lang.String[] tickMarks,
                                   int type)
Draw legend's tick marks.

Parameters:
g2 - Graphics2D context which we drawn
startX - start x position
startY - start y position
endX - x end position
endY - y end position
tickMarks - the tick marks' name such 1,2 or 0.2, 0.4, etc
type - =1 draw X ticks, =2 draw Y left ticks, =3 draw Y right ticks ,=4 vertical gray line.

drawPolyLine

public static void drawPolyLine(java.awt.Graphics2D g2d,
                                float[] xData,
                                float[] yData,
                                float xs,
                                float ys,
                                java.awt.Color c,
                                float xOff,
                                float yOff)
Draw a poly line using pass in x and y coordinates. Assume the origin is (0,0).

Parameters:
xData - x coordinates
yData - y coordinates
xs - scale for x coordinates so the x position fits the legend box.
ys - scale for y coordinates so the y position fits legend box.
xOff - offset for x axis. x axis start with xOff
yOff - offset for y axis. y axis start with yOff

drawLineSegmentsTickMarks

public static void drawLineSegmentsTickMarks(java.awt.Graphics2D g2d,
                                             float[] xData,
                                             float[] yData,
                                             float xs,
                                             float ys,
                                             java.awt.Color c,
                                             float xOff,
                                             float yOff,
                                             java.lang.String[] strs)
Draw line segments using pass in x and y coordinates. Assume the origin is (0,0).

Parameters:
xData - x coordinates
yData - y coordinates
xs - scale for x coordinates so the x position fits the legend box.
ys - scale for y coordinates so the y position fits legend box.
xOff - offset for x axis. x axis start with xOff
yOff - offset for y axis. y axis start with yOff
strs - tick mark names.

drawLineSegments

public static void drawLineSegments(java.awt.Graphics2D g2d,
                                    float[] xData,
                                    float[] yData,
                                    float xs,
                                    float ys,
                                    java.awt.Color c,
                                    float xOff,
                                    float yOff)
Draw line segments using pass in x and y coordinates. Assume the origin is (0,0).

Parameters:
xData - x coordinates
yData - y coordinates
xs - scale for x coordinates so the x position fits the legend box.
ys - scale for y coordinates so the y position fits legend box.
xOff - offset for x axis. x axis start with xOff
yOff - offset for y axis. y axis start with yOff

drawDots

public static void drawDots(java.awt.Graphics2D g2d,
                            float[] xData,
                            float[] yData,
                            float xs,
                            float ys,
                            java.awt.Color c,
                            float xOff,
                            float yOff)
Draw points centered at (xData[i],yData[i]) and radius is 1. Assume the origin is (0,0).

Parameters:
xData - array of x coordinates
yData - array of y coordinates
xs - scale for x coordinates so the x position fits the legend box.
ys - scale for y coordinates so the y position fits legend box.
xOff - offset for x axis. x axis start with xOff
yOff - offset for y axis. y axis start with yOff

drawRects

public static void drawRects(java.awt.Graphics2D g2d,
                             int[][] data,
                             java.awt.Color[] c,
                             float xs,
                             float ys,
                             float xOff,
                             float yOff)
Draw points centered at (xData[i],yData[i]) and radius is 1. Assume the origin is (0,0).

Parameters:
data - array of x,y coordinates
xs - scale for x coordinates so the x position fits the rectangle box.
ys - scale for y coordinates so the y position fits rectangle box.
xOff - offset for x axis. x axis start with xOff
yOff - offset for y axis. y axis start with yOff

drawLegendBox

public void drawLegendBox(java.awt.Graphics2D g2,
                          int width,
                          int ht)
Draw the legend box.

Parameters:
g2 - Graphic2D where all drawing happens.
width - width of the legend box.
ht - height of the legend box.

drawStringsInBox

public static void drawStringsInBox(java.awt.Graphics2D g2,
                                    int width,
                                    int ht,
                                    java.lang.String[] strs,
                                    java.awt.Font f)
Draw an array of strings in a bounding box with origin in (0,0). The font size will be resized according the string length and bounding box.

Parameters:
g2 - a Graphics2D object to be drawn in.
width - bounding box width
ht - bounding box height
strs - the array of strings
f - default font

drawCircle

public static void drawCircle(java.awt.Graphics2D g2d,
                              double[] data,
                              float[] xData,
                              float[] yData,
                              java.awt.Color c,
                              float xs,
                              float ys,
                              float xOff,
                              float yOff,
                              float radius)
Draw circles using pass in x and y coordinates. Assume the origin is (0,0).

Parameters:
g2d - a Graphics2D object to be drawn in.
xData - x coordinates for the center of the circle
yData - y coordinates for the center of the circle
data - ratios to radius of the circle
xs - scale of x axis
ys - scale of y axis
xOff - offset for x axis. x axis start with xOff
yOff - offset for y axis. y axis END with yOff
radius - radius of the circle