org.jplot2d.util
Class LineHatchPaint
- java.lang.Object
-
- org.jplot2d.util.LineHatchPaint
-
- All Implemented Interfaces:
- java.awt.Paint, java.awt.Transparency
public class LineHatchPaint extends java.lang.Object implements java.awt.PaintThe LineHatchPaint class provides a way to fill a Shape with line hatch pattern. Because Java require instances of classes implementing Paint must be read-only, this class is more like a factory to create paint instance for renderer threads.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class and Description static classLineHatchPaint.PointComparatorNXdescend Xstatic classLineHatchPaint.PointComparatorNYdescend Ystatic classLineHatchPaint.PointComparatorXascend Xstatic classLineHatchPaint.PointComparatorYascend Y
-
Constructor Summary
Constructors Constructor and Description LineHatchPaint(java.awt.Color color, java.awt.BasicStroke stroke, double angle, double spacing)Construct a LineHatchPaint with given arguments.LineHatchPaint(double angle)Construct a LineHatchPaint with the given angle.LineHatchPaint(float width, double angle, double spacing)Construct a LineHatchPaint with the given angle.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description static booleanapproxBetween(double a, double b, double v)static java.awt.geom.Line2D[]calcHatchLinesClipped(LineHatchPaint lhp, java.awt.geom.Rectangle2D clip, double scale)java.awt.Shape[]calcHatchShapes(java.awt.Shape shape, java.awt.geom.Rectangle2D clip, double scale)Calculate hatch shapes to fill the given shape.java.awt.PaintContextcreateContext(java.awt.image.ColorModel cm, java.awt.Rectangle deviceBounds, java.awt.geom.Rectangle2D userBounds, java.awt.geom.AffineTransform xform, java.awt.RenderingHints hints)doublegetAngle()java.awt.ColorgetColor()doublegetSpacing()java.awt.BasicStrokegetStroke()intgetTransparency()static booleanintersectLines(java.awt.geom.Line2D line, double x3, double y3, double x4, double y4, double[] point)The method checks up if line and line (x3, y3) - (x4, y4) intersect.
-
-
-
Constructor Detail
-
LineHatchPaint
public LineHatchPaint(double angle)
Construct a LineHatchPaint with the given angle. The default values:- color: BLACK
- line width: 0.0
- line style: solid
- line spacing: 6pt
- Parameters:
angle- the counterclockwise angle in degrees from horizontal
-
LineHatchPaint
public LineHatchPaint(float width, double angle, double spacing)Construct a LineHatchPaint with the given angle. The default values:- color: BLACK
- line style: solid
- Parameters:
width- the line widthangle- the counterclockwise angle in degrees from horizontalspacing- the spacing, in point(1/72 inch), between the parallel lines
-
LineHatchPaint
public LineHatchPaint(java.awt.Color color, java.awt.BasicStroke stroke, double angle, double spacing)Construct a LineHatchPaint with given arguments.- Parameters:
width- the line widthdash- the dash array. null means solid lineangle- the counterclockwise angle in degrees from horizontalspacing- the spacing, in point(1/72 inch), between the parallel lines
-
-
Method Detail
-
getColor
public java.awt.Color getColor()
-
getStroke
public java.awt.BasicStroke getStroke()
-
getAngle
public double getAngle()
-
getSpacing
public double getSpacing()
-
createContext
public java.awt.PaintContext createContext(java.awt.image.ColorModel cm, java.awt.Rectangle deviceBounds, java.awt.geom.Rectangle2D userBounds, java.awt.geom.AffineTransform xform, java.awt.RenderingHints hints)- Specified by:
createContextin interfacejava.awt.Paint
-
getTransparency
public int getTransparency()
- Specified by:
getTransparencyin interfacejava.awt.Transparency
-
calcHatchShapes
public java.awt.Shape[] calcHatchShapes(java.awt.Shape shape, java.awt.geom.Rectangle2D clip, double scale)Calculate hatch shapes to fill the given shape.- Parameters:
shape- the shape to hatchclip- the clipscale-- Returns:
- hatch shapes
-
calcHatchLinesClipped
public static java.awt.geom.Line2D[] calcHatchLinesClipped(LineHatchPaint lhp, java.awt.geom.Rectangle2D clip, double scale)
-
intersectLines
public static boolean intersectLines(java.awt.geom.Line2D line, double x3, double y3, double x4, double y4, double[] point)The method checks up if line and line (x3, y3) - (x4, y4) intersect. If lines intersect then the result parameters are saved to point array. The size of array point must be at least 2. Note the algorithm is not symmetric. The given line is the primary line.- Parameters:
line- the primary linex3-y3-x4-y4-point-- Returns:
- true if two lines intersect
-
approxBetween
public static boolean approxBetween(double a, double b, double v)
-
-
DMelt 3.0 © DataMelt by jWork.ORG