Package hec.gfx2d
Class Gfx2dDrawUtil
java.lang.Object
hec.gfx2d.Gfx2dDrawUtil
This is a static class which implements drawing routines that draw clipped
Line Segments and PolyLines. These routines have been adopted from the
Visual Basic code written by Mark Jensen @ the Hydrologic Engineering Center
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidcomputeVisibleSymbols(int[] xpoints, int[] ypoints, int numPts, boolean autoSkip, int offset, int skip, float sSize, boolean[] visibleSymbols) static voiddrawConformingString(Graphics g, int[] xarray, int[] yarray, int numPoints, String str, int labelAlign, int labelPosition, double coord, int baseoffset, Font font, Color color, int bank, float priority) This is a public method that draws a string label that conforms to a given line.static voiddrawPoints(Graphics g, int[] xpoints, int[] ypoints, int numPts, boolean[] showPoints, int symbolType, Color sLineColor, Color sFillColor, float sSize, boolean autoSkip, int offset, int skip) Draws the visible points along a line.static voiddrawPoints(Graphics g, int[] xpoints, int[] ypoints, int numPts, boolean[] showPoints, int symbolType, Color sLineColor, Color sFillColor, float sSize, boolean autoSkip, int offset, int skip, int symbolThickness) static voiddrawString(JComponent c, Graphics g, String text, int x, int y) Draws the string at the specified location.static voiddrawString(JComponent c, Graphics g, String text, int x, int y, int rotate) static voidfillPolygonClipped(Graphics g, Rectangle rect, int[] xpoints, int[] ypoints, int numPts) This method draws a polygon into a region bounded by a given rectangle.static voidfillPolygonClipped(Graphics g, Rectangle rect, int[] xpoints, int[] ypoints, int numPts, int fillType) This method draws a polygon into a region bounded by a given rectangle.static voidfillPolygonClipped(Graphics g, Rectangle rect, int[] xpoints, int[] ypoints, int numPts, Paint fillPaint) static voidplotClippedLine(Graphics g, Rectangle rect, int x1, int y1, int x2, int y2) This method draws a line segment to a region bounded by a given rectangle.static voidplotPolyLineClipped(Graphics g, Rectangle rect, int[] xpoints, int[] ypoints, int numPts) This method draws a poly line into a region bounded by a given rectangle.static voidplotPolyLineClipped(Graphics g, Rectangle rect, int[] xpoints, int[] ypoints, int numPts, boolean showPts) This method draws a poly line into a region bounded by a given rectangle.static voidplotPolyLineClipped(Graphics g, Rectangle rect, int[] xpoints, int[] ypoints, int numPts, boolean showLine, boolean showPts) This method draws a poly line into a region bounded by a given rectangle.static voidplotPolyLineClipped(Graphics g, Rectangle rect, int[] xpoints, int[] ypoints, int numPts, boolean showLine, Color lineColor, float lineWidth, boolean showPts, int symbolType, float symbolSize, Color sFillColor, Color sLineColor) This method draws a poly line into a region bounded by a given rectangle.static voidplotPolyLineClipped(Graphics g, Rectangle rect, int[] xpoints, int[] ypoints, int numPts, boolean showLine, Color lineColor, float lineWidth, boolean showPts, int symbolType, float symbolSize, Color sFillColor, Color sLineColor, boolean autoSkip, int offset, int skip, boolean drawLabel, String label, int labelAlign, int labelPosition, Font labelFont, Color labelColor) This method draws a poly line into a region bounded by a given rectangle.static voidplotPolyLineClipped(Graphics g, Rectangle rect, int[] xpoints, int[] ypoints, int numPts, boolean showLine, Color lineColor, float lineWidth, boolean showPts, int symbolType, float symbolSize, Color sFillColor, Color sLineColor, int offset, int skip) This method draws a poly line into a region bounded by a given rectangle.
-
Field Details
-
DEVICE_RESOLUTION
public static int DEVICE_RESOLUTION
-
-
Constructor Details
-
Gfx2dDrawUtil
public Gfx2dDrawUtil()
-
-
Method Details
-
plotClippedLine
This method draws a line segment to a region bounded by a given rectangle. If the line is too large for the rectangle, the line is clipped i.e. only the visible part is drawn. If the line segment occurs outside the rectangle it is ignored.- Parameters:
g- - the graphics context to draw to.rect- - the bounding box of the drawing areax1- - the x coordinate of the begining of the liney1- - the y coordinate of the begining of the linex2- - the x coordinate of the end of the liney2- - the y coordinate of the end of the line
-
plotPolyLineClipped
public static void plotPolyLineClipped(Graphics g, Rectangle rect, int[] xpoints, int[] ypoints, int numPts) This method draws a poly line into a region bounded by a given rectangle. All points on the line that lie outside the rectangle are clipped off. If the entire poly line occurs outside the rectange then it is ignored- Parameters:
g- - the graphics context to draw torect- - the bounding box of the drawing areaxpoints- - the array of x-coordinates for the poly lineypoints- - tha array of y-coordinates for the poly linenumPts- - the number of coordinates to draw
-
plotPolyLineClipped
public static void plotPolyLineClipped(Graphics g, Rectangle rect, int[] xpoints, int[] ypoints, int numPts, boolean showPts) This method draws a poly line into a region bounded by a given rectangle. All points on the line that lie outside the rectangle are clipped off. If the entire poly line occurs outside the rectange then it is ignored- Parameters:
g- - the graphics context to draw torect- - the bounding box of the drawing areaxpoints- - the array of x-coordinates for the poly lineypoints- - tha array of y-coordinates for the poly linenumPts- - the number of coordinates to drawshowPts- - if true, plots the data points
-
plotPolyLineClipped
public static void plotPolyLineClipped(Graphics g, Rectangle rect, int[] xpoints, int[] ypoints, int numPts, boolean showLine, boolean showPts) This method draws a poly line into a region bounded by a given rectangle. All points on the line that lie outside the rectangle are clipped off. If the entire poly line occurs outside the rectange then it is ignored- Parameters:
g- - the graphics context to draw torect- - the bounding box of the drawing areaxpoints- - the array of x-coordinates for the poly lineypoints- - tha array of y-coordinates for the poly linenumPts- - the number of coordinates to drawshowLine- - if true, plots the lineshowPts- - if true, plots the data points
-
plotPolyLineClipped
public static void plotPolyLineClipped(Graphics g, Rectangle rect, int[] xpoints, int[] ypoints, int numPts, boolean showLine, Color lineColor, float lineWidth, boolean showPts, int symbolType, float symbolSize, Color sFillColor, Color sLineColor) This method draws a poly line into a region bounded by a given rectangle. All points on the line that lie outside the rectangle are clipped off. If the entire poly line occurs outside the rectange then it is ignored- Parameters:
g- - the graphics context to draw torect- - the bounding box of the drawing areaxpoints- - the array of x-coordinates for the poly lineypoints- - tha array of y-coordinates for the poly linenumPts- - the number of coordinates to drawshowLine-lineColor- - the color to draw the line, if null, uses the default color of blue.showPts- - if true, plots the data pointslineWidth-symbolType- - the type of symbol to draw if showPts is true. Use constant defined in hec.gfx2d.SymbolsFillColor- - the fill Color for the symbol. If null, uses default color of blue.sLineColor- - the line Color for the symbol. If null, uses default color of blue.symbolSize-
-
plotPolyLineClipped
public static void plotPolyLineClipped(Graphics g, Rectangle rect, int[] xpoints, int[] ypoints, int numPts, boolean showLine, Color lineColor, float lineWidth, boolean showPts, int symbolType, float symbolSize, Color sFillColor, Color sLineColor, int offset, int skip) This method draws a poly line into a region bounded by a given rectangle. All points on the line that lie outside the rectangle are clipped off. If the entire poly line occurs outside the rectange then it is ignored- Parameters:
g- - the graphics context to draw torect- - the bounding box of the drawing areaxpoints- - the array of x-coordinates for the poly lineypoints- - tha array of y-coordinates for the poly linenumPts- - the number of coordinates to drawshowLine-lineColor- - the color to draw the line, if null, uses the default color of blue.lineWidth-showPts- - if true, plots the data pointssymbolType- - the type of symbol to draw if showPts is true. Use constant defined in hec.gfx2d.SymbolsymbolSize-sFillColor- - the fill Color for the symbol. If null, uses default color of blue.sLineColor- - the line Color for the symbol. If null, uses default color of blue.offset- - the number of points from the start of data to skipskip- - the number of points to skip, 0 skip none, 1 - skip every other point, etc
-
plotPolyLineClipped
public static void plotPolyLineClipped(Graphics g, Rectangle rect, int[] xpoints, int[] ypoints, int numPts, boolean showLine, Color lineColor, float lineWidth, boolean showPts, int symbolType, float symbolSize, Color sFillColor, Color sLineColor, boolean autoSkip, int offset, int skip, boolean drawLabel, String label, int labelAlign, int labelPosition, Font labelFont, Color labelColor) This method draws a poly line into a region bounded by a given rectangle. All points on the line that lie outside the rectangle are clipped off. If the entire poly line occurs outside the rectange then it is ignored- Parameters:
g- - the graphics context to draw torect- - the bounding box of the drawing areaxpoints- - the array of x-coordinates for the poly lineypoints- - tha array of y-coordinates for the poly linenumPts- - the number of coordinates to drawlineColor- - the color to draw the line, if null, uses the default color of blue.showPts- - if true, plots the data pointssymbolType- - the type of symbol to draw if showPts is true. Use constant defined in hec.gfx2d.SymbolsFillColor- - the fill Color for the symbol. If null, uses default color of blue.sLineColor- - the line Color for the symbol. If null, uses default color of blue.autoSkip- - this is true if this method should draw points so they do not overlap. if true the offset and skip values are ignored.offset- - the number of points from the start of data to skipskip- - the number of points to skip, 0 skip none, 1 - skip every other point, etcdrawLabel- - if true, draws a label based on the label and label position propertieslabel- - the label to draw.labelFont- - the font to draw the label withlabelColor- - the color used to draw the label
-
drawPoints
public static void drawPoints(Graphics g, int[] xpoints, int[] ypoints, int numPts, boolean[] showPoints, int symbolType, Color sLineColor, Color sFillColor, float sSize, boolean autoSkip, int offset, int skip) Draws the visible points along a line.- Parameters:
g- - the graphics context to draw toxpoints- - the list of visible xpointsypoints- - the list of visible ypointsnumPts- - the number of visible pointsshowPoints- - an array of booleans saying if a particular point is drawn, true to draw false to skipsymbolType- - the symbol type to use. @see hec.gfx2d.SymbolsLineColor- - the symbol line colorsFillColor- - the symbol fill colorsSize- - the size of the symbol to use.autoSkip- - this is true if this method should draw points so they do not overlap. if true the offset and skip values are ignored.offset- - the number of points from the start of data to skipskip- - the number of points to skip, 0 skip none, 1 - skip every other point, etc
-
drawPoints
-
fillPolygonClipped
public static void fillPolygonClipped(Graphics g, Rectangle rect, int[] xpoints, int[] ypoints, int numPts) This method draws a polygon into a region bounded by a given rectangle. All points on the polygon that lie outside the rectangle are clipped off. If the entire polygon occurs outside the rectange then it is ignored. The polygon is filled solid.- Parameters:
g- - the graphics context to draw torect- - the bounding box of the drawing areaxpoints- - the array of x-coordinates for the poly lineypoints- - tha array of y-coordinates for the poly linenumPts- - the number of coordinates to draw
-
fillPolygonClipped
public static void fillPolygonClipped(Graphics g, Rectangle rect, int[] xpoints, int[] ypoints, int numPts, int fillType) This method draws a polygon into a region bounded by a given rectangle. All points on the polygon that lie outside the rectangle are clipped off. If the entire polygon occurs outside the rectange then it is ignored- Parameters:
g- - the graphics context to draw torect- - the bounding box of the drawing areaxpoints- - the array of x-coordinates for the poly lineypoints- - tha array of y-coordinates for the poly linenumPts- - the number of coordinates to drawfillType- - the fill type to use, SOLID, DIAGONAL, CROSS, etc
-
fillPolygonClipped
-
drawConformingString
public static void drawConformingString(Graphics g, int[] xarray, int[] yarray, int numPoints, String str, int labelAlign, int labelPosition, double coord, int baseoffset, Font font, Color color, int bank, float priority) This is a public method that draws a string label that conforms to a given line. In other words the string trys to match the curve of the line.- Parameters:
g- the graphics context to draw the string toxarray- the list of x-coordinates points in pixelsyarray- the list of y-coordinates of the line in pixelsnumPoints- the number of points contained in the xarray/yarraystr- the string to drawlabelAlign- Marks the position of the label on the line either G2dLineProperties.LABEL_ALIGN_RIGHT/LABEL_ALIGN_LEFTlabelPosition-coord-baseoffset-font- the font to use when drawing the stringcolor- the color of the stringbank-priority-
-
computeVisibleSymbols
public static void computeVisibleSymbols(int[] xpoints, int[] ypoints, int numPts, boolean autoSkip, int offset, int skip, float sSize, boolean[] visibleSymbols) -
drawString
Draws the string at the specified location.- Parameters:
c- JComponent that will display the string, may be nullg- Graphics to draw the text totext- String to displayx- X coordinate to draw the text aty- Y coordinate to draw the text at
-
drawString
-