下面列出了怎么用java.awt.geom.GeneralPath的API类实例代码及写法,或者点击链接到github查看源代码。
/**
* Returns the shape for the window for this dial. Some dial layers will
* request that their drawing be clipped within this window.
*
* @param frame the reference frame (<code>null</code> not permitted).
*
* @return The shape of the dial's window.
*/
@Override
public Shape getWindow(Rectangle2D frame) {
Rectangle2D innerFrame = DialPlot.rectangleByRadius(frame,
this.innerRadius, this.innerRadius);
Rectangle2D outerFrame = DialPlot.rectangleByRadius(frame,
this.outerRadius, this.outerRadius);
Arc2D inner = new Arc2D.Double(innerFrame, this.startAngle,
this.extent, Arc2D.OPEN);
Arc2D outer = new Arc2D.Double(outerFrame, this.startAngle
+ this.extent, -this.extent, Arc2D.OPEN);
GeneralPath p = new GeneralPath();
Point2D point1 = inner.getStartPoint();
p.moveTo((float) point1.getX(), (float) point1.getY());
p.append(inner, true);
p.append(outer, true);
p.closePath();
return p;
}
/**
* Initialises the renderer.
* <P>
* This method will be called before the first item is rendered, giving the
* renderer an opportunity to initialise any state information it wants to
* maintain. The renderer can do nothing if it chooses.
*
* @param g2 the graphics device.
* @param dataArea the area inside the axes.
* @param plot the plot.
* @param data the data.
* @param info an optional info collection object to return data back to
* the caller.
*
* @return The renderer state.
*/
@Override
public XYItemRendererState initialise(Graphics2D g2,
Rectangle2D dataArea, XYPlot plot, XYDataset data,
PlotRenderingInfo info) {
double dpi = 72;
// Integer dpiVal = (Integer) g2.getRenderingHint(HintKey.DPI);
// if (dpiVal != null) {
// dpi = dpiVal.intValue();
// }
State state = new State(info);
state.seriesPath = new GeneralPath();
state.intervalPath = new GeneralPath();
state.dX = 72.0 / dpi;
return state;
}
public Shape mapShape(Shape s) {
if (LOGMAP) LOG.format("mapshape on path: %s\n", LayoutPathImpl.SegmentPath.this);
PathIterator pi = s.getPathIterator(null, 1); // cheap way to handle curves.
if (LOGMAP) LOG.format("start\n");
init();
final double[] coords = new double[2];
while (!pi.isDone()) {
switch (pi.currentSegment(coords)) {
case SEG_CLOSE: close(); break;
case SEG_MOVETO: moveTo(coords[0], coords[1]); break;
case SEG_LINETO: lineTo(coords[0], coords[1]); break;
default: break;
}
pi.next();
}
if (LOGMAP) LOG.format("finish\n\n");
GeneralPath gp = new GeneralPath();
for (Segment seg: segments) {
gp.append(seg.gp, false);
}
return gp;
}
/**
* Draws a polygon with the vertices
* (<em>x</em><sub>0</sub>, <em>y</em><sub>0</sub>),
* (<em>x</em><sub>1</sub>, <em>y</em><sub>1</sub>), ...,
* (<em>x</em><sub><em>n</em>–1</sub>, <em>y</em><sub><em>n</em>–1</sub>).
*
* @param x an array of all the <em>x</em>-coordinates of the polygon
* @param y an array of all the <em>y</em>-coordinates of the polygon
* @throws IllegalArgumentException unless {@code x[]} and {@code y[]}
* are of the same length
* @throws IllegalArgumentException if any coordinate is either NaN or infinite
* @throws IllegalArgumentException if either {@code x[]} or {@code y[]} is {@code null}
*/
public static void polygon(double[] x, double[] y) {
validateNotNull(x, "x-coordinate array");
validateNotNull(y, "y-coordinate array");
for (int i = 0; i < x.length; i++) validate(x[i], "x[" + i + "]");
for (int i = 0; i < y.length; i++) validate(y[i], "y[" + i + "]");
int n1 = x.length;
int n2 = y.length;
if (n1 != n2) throw new IllegalArgumentException("arrays must be of the same length");
int n = n1;
if (n == 0) return;
GeneralPath path = new GeneralPath();
path.moveTo((float) scaleX(x[0]), (float) scaleY(y[0]));
for (int i = 0; i < n; i++)
path.lineTo((float) scaleX(x[i]), (float) scaleY(y[i]));
path.closePath();
offscreen.draw(path);
draw();
}
private GeneralPath rightShape(Rectangle2D bounds) {
double[] path1;
if (isVerticalLine) {
path1 = new double[] {
bounds.getX(),
bounds.getY() + bounds.getHeight(),
bounds.getX() + bounds.getWidth(),
bounds.getY() + bounds.getHeight()
};
} else {
path1 = new double[] {
bounds.getX() + bounds.getWidth(),
bounds.getY() + bounds.getHeight(),
bounds.getX() + bounds.getWidth(),
bounds.getY()
};
}
double[] path0 = getCaretPath(characterCount, bounds, true);
return boundingShape(path0, path1);
}
/**
* Repositions this component.
*/
protected void nudge() {
Point topLeft = SwingUtilities.convertPoint(highlightInfo.jc, 0, 0,
layeredPane);
GeneralPath path = new GeneralPath();
path.moveTo(0, 0);
path.lineTo(image.getWidth(), 0);
path.lineTo(image.getWidth(), image.getHeight());
path.lineTo(0, image.getHeight());
path.closePath();
AffineTransform transform = AffineTransform
.getTranslateInstance(-imageCenter.x, -imageCenter.y);
AffineTransform hTransform = (AffineTransform) getClientProperty(
"transform");
if (hTransform != null) {
transform.concatenate(hTransform);
}
path.transform(transform);
Rectangle bounds = path.getBounds();
setBounds(center.x + topLeft.x - bounds.width / 2,
center.y + topLeft.y - bounds.height / 2, bounds.width,
bounds.height);
}
public static void drawWave(Graphics2D g, Rectangle rectangle) {
GraphicsConfig config = GraphicsUtil.setupAAPainting(g);
Stroke oldStroke = g.getStroke();
try {
g.setStroke(new BasicStroke(0.7F));
double cycle = 4;
final double wavedAt = rectangle.y + (double)rectangle.height / 2 - .5;
GeneralPath wavePath = new GeneralPath();
wavePath.moveTo(rectangle.x, wavedAt - Math.cos(rectangle.x * 2 * Math.PI / cycle));
for (int x = rectangle.x + 1; x <= rectangle.x + rectangle.width; x++) {
wavePath.lineTo(x, wavedAt - Math.cos(x * 2 * Math.PI / cycle));
}
g.draw(wavePath);
}
finally {
config.restore();
g.setStroke(oldStroke);
}
}
Rectangle2D getGlyphOutlineBounds(int glyphID, float x, float y) {
Rectangle2D result = null;
if (sgv.invdtx == null) {
result = new Rectangle2D.Float();
result.setRect(strike.getGlyphOutlineBounds(glyphID)); // don't mutate cached rect
} else {
GeneralPath gp = strike.getGlyphOutline(glyphID, 0, 0);
gp.transform(sgv.invdtx);
result = gp.getBounds2D();
}
/* Since x is the logical advance of the glyph to this point.
* Because of the way that Rectangle.union is specified, this
* means that subsequent unioning of a rect including that
* will be affected, even if the glyph is empty. So skip such
* cases. This alone isn't a complete solution since x==0
* may also not be what is wanted. The code that does the
* unioning also needs to be aware to ignore empty glyphs.
*/
if (!result.isEmpty()) {
result.setRect(result.getMinX() + x + dx,
result.getMinY() + y + dy,
result.getWidth(), result.getHeight());
}
return result;
}
private static GeneralPath findShapeToFitRectangle(Shape originalShape,
int w, int h) {
GeneralPath newShape = new GeneralPath();
Rectangle2D rect = new Rectangle2D.Float();
ShapeBounds.getBounds(originalShape, rect);
if (originalShape.contains(rect.getX() + rect.getWidth() / 2,
rect.getY() + rect.getHeight() / 2) == false)
throw new IllegalArgumentException(
"This custom shape is not allowed. The center of this shape must be inside the shape.");
double scale = Math.min((w) / rect.getWidth(), (h) / rect.getHeight());
AffineTransform transform = new AffineTransform();
while (true) {
newShape.reset();
newShape.append(originalShape, true);
transform.setToScale(scale, scale);
newShape.transform(transform);
ShapeBounds.getBounds(newShape, rect);
if (newShape.contains(rect.getX() + rect.getWidth() / 2 - w / 2,
rect.getY() + rect.getHeight() / 2 - h / 2, w, h)) {
return newShape;
}
scale += .01;
}
}
private void drawCheck(PDAnnotationText annotation,
final PDAppearanceContentStream contentStream) throws IOException
{
PDRectangle bbox = adjustRectAndBBox(annotation, 20, 19);
float min = Math.min(bbox.getWidth(), bbox.getHeight());
contentStream.setMiterLimit(4);
contentStream.setLineJoinStyle(1);
contentStream.setLineCapStyle(0);
contentStream.setLineWidth(0.59f); // value from Adobe
contentStream.transform(Matrix.getScaleInstance(0.001f * min / 0.8f, 0.001f * min / 0.8f));
contentStream.transform(Matrix.getTranslateInstance(0, 50));
// we get the shape of a Zapf Dingbats check (0x2714) and use that one.
// Adobe uses a different font (which one?), or created the shape from scratch.
GeneralPath path = PDType1Font.ZAPF_DINGBATS.getPath("a20");
addPath(contentStream, path);
contentStream.fillAndStroke();
}
private void drawRightPointer(PDAnnotationText annotation, final PDAppearanceContentStream contentStream)
throws IOException
{
PDRectangle bbox = adjustRectAndBBox(annotation, 20, 17);
float min = Math.min(bbox.getWidth(), bbox.getHeight());
contentStream.setMiterLimit(4);
contentStream.setLineJoinStyle(1);
contentStream.setLineCapStyle(0);
contentStream.setLineWidth(0.59f); // value from Adobe
contentStream.transform(Matrix.getScaleInstance(0.001f * min / 0.8f, 0.001f * min / 0.8f));
contentStream.transform(Matrix.getTranslateInstance(0, 50));
// we get the shape of a Zapf Dingbats right pointer (0x27A4) and use that one.
// Adobe uses a different font (which one?), or created the shape from scratch.
GeneralPath path = PDType1Font.ZAPF_DINGBATS.getPath("a174");
addPath(contentStream, path);
contentStream.fillAndStroke();
}
private GeneralPath getShape(int index) {
Random r = new Random(index * 100000);
GeneralPath path = new GeneralPath(
r.nextBoolean() ? Path2D.WIND_EVEN_ODD : Path2D.WIND_NON_ZERO);
path.moveTo(r.nextFloat() * 100, r.nextFloat() * 100);
for (int a = 0; a < 3; a++) {
int k;
if (type.getSelectedIndex() == 0) {
k = r.nextInt(3);
} else {
k = type.getSelectedIndex() - 1;
}
if (k == 0) {
path.lineTo(r.nextFloat() * 100, r.nextFloat() * 100);
} else if (k == 1) {
path.quadTo(r.nextFloat() * 100, r.nextFloat() * 100,
r.nextFloat() * 100, r.nextFloat() * 100);
} else {
path.curveTo(r.nextFloat() * 100, r.nextFloat() * 100,
r.nextFloat() * 100, r.nextFloat() * 100,
r.nextFloat() * 100, r.nextFloat() * 100);
}
}
return path;
}
/**
* Creates a shape representing a point.
*
* @param point
* the location of the point
* @return a shape
*/
public Shape createPoint(Point2D point) {
GeneralPath path = new GeneralPath();
path.moveTo((float) (point.getX()), (float) (point.getY() - size * 1/8));
path.lineTo((float) (point.getX() + size * 2/8), (float) (point.getY() - size/2));
path.lineTo((float) (point.getX() + size/2), (float) (point.getY() - size/2));
path.lineTo((float) (point.getX() + size * 1/8), (float) (point.getY()));
path.lineTo((float) (point.getX() + size/2), (float) (point.getY() + size/2));
path.lineTo((float) (point.getX() + size * 2/8), (float) (point.getY() + size/2));
path.lineTo((float) (point.getX()), (float) (point.getY() + size * 1/8));
path.lineTo((float) (point.getX() - size * 2/8), (float) (point.getY() + size/2));
path.lineTo((float) (point.getX() - size/2), (float) (point.getY() + size/2));
path.lineTo((float) (point.getX() - size * 1/8), (float) (point.getY()));
path.lineTo((float) (point.getX() - size/2), (float) (point.getY() - size/2));
path.lineTo((float) (point.getX() - size * 2/8), (float) (point.getY() - size/2));
path.closePath();
return path;
}
private static ShapeInfo BuildDummyShapeSpec() {
ShapeInfo shape = new ShapeInfo(null);
try {
AffineTransform tx = new AffineTransform();
tx.setToIdentity();
GeneralPath gp = new GeneralPath();
shape.setLineColor(Color.WHITE);
shape.setFillColor(null);
shape.setStroke(new BasicStroke());
shape.setTexturePaint(null);
gp.moveTo(-1000, -1000);
gp.lineTo(-1001, -1001);
shape.setShape(gp);
shape.setAffineTransform(tx);
} catch (Exception exc) {
ErrorLogger.LogException(_className, "BuidDummyShapeSpec",
new RendererException("Failed inside BuildDummyShapeSpec", exc));
}
return shape;
}
/**
* Fill polygon
*
* @param points The points array
* @param g Graphics2D
* @param aPGB Polygon break
*/
public static void fillPolygon(PointD[] points, Graphics2D g, PolygonBreak aPGB) {
GeneralPath path = new GeneralPath(GeneralPath.WIND_EVEN_ODD, points.length);
for (int i = 0; i < points.length; i++) {
if (i == 0) {
path.moveTo(points[i].X, points[i].Y);
} else {
path.lineTo(points[i].X, points[i].Y);
}
}
path.closePath();
if (aPGB != null) {
if (aPGB.isUsingHatchStyle()) {
int size = aPGB.getStyleSize();
BufferedImage bi = getHatchImage(aPGB.getStyle(), size, aPGB.getColor(), aPGB.getBackColor());
Rectangle2D rect = new Rectangle2D.Double(0, 0, size, size);
g.setPaint(new TexturePaint(bi, rect));
g.fill(path);
} else {
g.fill(path);
}
} else {
g.fill(path);
}
}
void appendGlyphOutline(int glyphID, GeneralPath result, float x, float y) {
// !!! fontStrike needs a method for this. For that matter, GeneralPath does.
GeneralPath gp = null;
if (sgv.invdtx == null) {
gp = strike.getGlyphOutline(glyphID, x + dx, y + dy);
} else {
gp = strike.getGlyphOutline(glyphID, 0, 0);
gp.transform(sgv.invdtx);
gp.transform(AffineTransform.getTranslateInstance(x + dx, y + dy));
}
PathIterator iterator = gp.getPathIterator(null);
result.append(iterator, false);
}
synchronized GeneralPath getGlyphVectorOutline(
long pScalerContext, int[] glyphs, int numGlyphs,
float x, float y) throws FontScalerException {
if (nativeScaler != 0L) {
return getGlyphVectorOutlineNative(font.get(),
pScalerContext,
nativeScaler,
glyphs,
numGlyphs,
x, y);
}
return FontScaler
.getNullScaler().getGlyphVectorOutline(0L, glyphs, numGlyphs, x, y);
}
public void setVertices(List<Point2D.Float> points) {
if (points.size() < 3)
throw new IllegalArgumentException("the number of vertices must be no less than 3.");
if (vertex == null || points.size() != vertex.length)
path = new GeneralPath();
vertex = new Point2D.Float[points.size()];
for (int i = 0; i < vertex.length; i++) {
Point2D.Float pi = points.get(i);
setVertex(i, pi.x, pi.y);
}
}
/**
* process : m : Begin new subpath.
* @param operator The operator that is being executed.
* @param arguments List
*/
public void process(PDFOperator operator, List arguments)
{
try{
PDFObjectExtractor drawer = (PDFObjectExtractor)context;
COSNumber x = (COSNumber)arguments.get( 0 );
COSNumber y = (COSNumber)arguments.get( 1 );
drawer.getLineSubPaths().add( drawer.getLinePath() );
GeneralPath newPath = new GeneralPath();
Point2D Ppos = drawer.TransformedPoint(x.doubleValue(), y.doubleValue());
//newPath.moveTo( x.floatValue(), (float)drawer.fixY( x.doubleValue(), y.doubleValue()) );
//logger().info("Ready to move to " + Ppos.getX() + ", " + Ppos.getY());
newPath.moveTo((float)Ppos.getX(), (float)Ppos.getY());
drawer.setLinePath( newPath );
//drawer.setNewPath(true);
drawer.newPath();
////drawer.simpleMoveTo((float)Ppos.getX(), (float)Ppos.getY());
drawer.simpleMoveTo(x.floatValue(), y.floatValue());
}catch (Exception E){
//logger().warning( E.toString() + "/n at/n" + FullStackTrace(E));
E.printStackTrace();
}
//// extractor.setCurrentX(x.floatValue());
//// extractor.setCurrentY(y.floatValue());
}
public Shape getOutline(AffineTransform tx) {
GeneralPath dstShape = new GeneralPath(GeneralPath.WIND_NON_ZERO);
for (int i=0, n = 0; i < fComponents.length; i++, n += 2) {
TextLineComponent tlc = fComponents[getComponentLogicalIndex(i)];
dstShape.append(tlc.getOutline(locs[n], locs[n+1]), false);
}
if (tx != null) {
dstShape.transform(tx);
}
return dstShape;
}
public static Area getShape(Rectangle2D.Float r, byte type) {
// the positions and sizes of the circles must ensure that r is the bounding box
Area a = new Area(new Rectangle2D.Float(r.x + r.width * 0.45f, r.y + r.height * 0.5f, r.width * 0.1f, r.height * 0.5f));
switch (type) {
case REGULAR:
float p = Math.min(r.width, r.height) * 0.6f;
float q = p * 0.8f;
a.add(new Area(new Ellipse2D.Float(r.x + (r.width - p) * 0.5f, r.y, p, p)));
a.add(new Area(new Ellipse2D.Float(r.x, r.y + p * 0.8f, q, q)));
a.add(new Area(new Ellipse2D.Float(r.x + r.width - q, r.y + p * 0.8f, q, q)));
break;
case PINE:
GeneralPath path = new GeneralPath();
path.moveTo(r.x + r.width * 0.5f, r.y);
path.lineTo(r.x + r.width * 0.3f, r.y + r.height * 0.3f);
path.lineTo(r.x + r.width * 0.7f, r.y + r.height * 0.3f);
a.add(new Area(path));
path.reset();
path.moveTo(r.x + r.width * 0.5f, r.y + r.height * 0.2f);
path.lineTo(r.x + r.width * 0.2f, r.y + r.height * 0.5f);
path.lineTo(r.x + r.width * 0.8f, r.y + r.height * 0.5f);
a.add(new Area(path));
path.reset();
path.moveTo(r.x + r.width * 0.5f, r.y + r.height * 0.3f);
path.lineTo(r.x, r.y + r.height * 0.8f);
path.lineTo(r.x + r.width, r.y + r.height * 0.8f);
a.add(new Area(path));
break;
}
return a;
}
/** Create a thumb that is centered at (0,0) for a horizontally oriented slider.
*
* @param sliderUI the slider UI this thumb relates to.
* @param x the x-coordinate where this thumb is centered.
* @param y the y-coordinate where this thumb is centered.
* @param width the width of the the thumb (assuming this is a horizontal slider)
* @param height the height of the the thumb (assuming this is a horizontal slider)
* @param leftEdge true if this is the left-most thumb
* @param rightEdge true if this is the right-most thumb.
* @return the shape of this thumb.
*/
public Shape getShape(MultiThumbSliderUI<?> sliderUI,float x,float y,int width,int height,boolean leftEdge,boolean rightEdge) {
// TODO: reinstate leftEdge and rightEdge once bug related to nudging
// adjacent thumbs is resolved.
GeneralPath path = new GeneralPath(getShape(width, height, false, false, !sliderUI.getThumbAntialiasing()));
if(sliderUI.slider.getOrientation()==SwingConstants.VERTICAL) {
path.transform(AffineTransform.getRotateInstance(-Math.PI/2));
}
path.transform( AffineTransform.getTranslateInstance(MathG.roundInt(x), MathG.roundInt(y)) );
return path;
}
/**
* Tests two polygons for equality. If both are <code>null</code> this
* method returns <code>true</code>.
*
* @param p1 path 1 (<code>null</code> permitted).
* @param p2 path 2 (<code>null</code> permitted).
*
* @return A boolean.
*/
public static boolean equal(final GeneralPath p1, final GeneralPath p2) {
if (p1 == null) {
return (p2 == null);
}
if (p2 == null) {
return false;
}
if (p1.getWindingRule() != p2.getWindingRule()) {
return false;
}
PathIterator iterator1 = p1.getPathIterator(null);
PathIterator iterator2 = p2.getPathIterator(null);
double[] d1 = new double[6];
double[] d2 = new double[6];
boolean done = iterator1.isDone() && iterator2.isDone();
while (!done) {
if (iterator1.isDone() != iterator2.isDone()) {
return false;
}
int seg1 = iterator1.currentSegment(d1);
int seg2 = iterator2.currentSegment(d2);
if (seg1 != seg2) {
return false;
}
if (!Arrays.equals(d1, d2)) {
return false;
}
iterator1.next();
iterator2.next();
done = iterator1.isDone() && iterator2.isDone();
}
return true;
}
private static Area getArrow (float length, float bendPercent) {
final int bodyWidth = 10;
final float headSize = 17;
float p1x = 0, p1y = 0;
float p2x = length, p2y = 0;
float cx = length / 2, cy = length / 8f * bendPercent;
float adjSize, ex, ey, abs_e;
adjSize = (float)(bodyWidth / 2 / Math.sqrt(2));
ex = p2x - cx;
ey = p2y - cy;
abs_e = (float)Math.sqrt(ex * ex + ey * ey);
ex /= abs_e;
ey /= abs_e;
GeneralPath bodyPath = new GeneralPath();
bodyPath.moveTo(p2x + (ey - ex) * adjSize, p2y - (ex + ey) * adjSize);
bodyPath.quadTo(cx, cy, p1x, p1y - bodyWidth / 2);
bodyPath.lineTo(p1x, p1y + bodyWidth / 2);
bodyPath.quadTo(cx, cy, p2x - (ey + ex) * adjSize, p2y + (ex - ey) * adjSize);
bodyPath.closePath();
adjSize = (float)(headSize / Math.sqrt(2));
ex = p2x - cx;
ey = p2y - cy;
abs_e = (float)Math.sqrt(ex * ex + ey * ey);
ex /= abs_e;
ey /= abs_e;
GeneralPath headPath = new GeneralPath();
headPath.moveTo(p2x - (ey + ex) * adjSize, p2y + (ex - ey) * adjSize);
headPath.lineTo(p2x, p2y);
headPath.lineTo(p2x + (ey - ex) * adjSize, p2y - (ex + ey) * adjSize);
headPath.closePath();
Area area = new Area(headPath);
area.add(new Area(bodyPath));
return area;
}
/**
* Returns a triangle of the given shape and size. This is a large
* top left triangle if the given shape is BEND, and a small left
* triangle if the given shape is CHEVRON or TRIANGLE.
*
* @param unionShape The shape of the union.
* @param small Whether the shape is limited by decorations.
* @return The triangle shape.
*/
private GeneralPath getTriangle(UnionShape unionShape, boolean small) {
GeneralPath path = new GeneralPath();
double x = 0;
double y = 0;
if (small) {
x = BEND_X;
y = BEND_Y;
}
switch(unionShape) {
case BEND:
path.moveTo(0, HEIGHT - y);
path.lineTo(0, 0);
path.lineTo(WIDTH - x, 0);
break;
case CHEVRON:
path.moveTo(0, y);
path.lineTo(CHEVRON_X - x, HEIGHT / 2);
path.lineTo(0, HEIGHT - y);
break;
case TRIANGLE:
if (unionPosition == UnionPosition.LEFT
|| unionPosition == UnionPosition.RIGHT) {
path.moveTo(0, y);
path.lineTo(WIDTH / 2 - x, HEIGHT / 2);
path.lineTo(0, HEIGHT - y);
} else {
path.moveTo(0, x);
path.lineTo(HEIGHT / 2 - y, WIDTH / 2);
path.lineTo(0, WIDTH - x);
}
break;
default:
break;
}
return path;
}
public Shape getOutline(AffineTransform tx) {
GeneralPath dstShape = new GeneralPath(GeneralPath.WIND_NON_ZERO);
for (int i=0, n = 0; i < fComponents.length; i++, n += 2) {
TextLineComponent tlc = fComponents[getComponentLogicalIndex(i)];
dstShape.append(tlc.getOutline(locs[n], locs[n+1]), false);
}
if (tx != null) {
dstShape.transform(tx);
}
return dstShape;
}
GeneralPath getGlyphOutline(long pScalerContext, int glyphCode, float x, float y) {
try {
return getScaler().getGlyphOutline(pScalerContext, glyphCode, x, y);
} catch (FontScalerException fe) {
scaler = FontScaler.getNullScaler();
return getGlyphOutline(pScalerContext, glyphCode, x, y);
}
}
synchronized GeneralPath getGlyphVectorOutline(
long pScalerContext, int[] glyphs, int numGlyphs,
float x, float y) throws FontScalerException {
if (nativeScaler != 0L) {
return getGlyphVectorOutlineNative(font.get(),
pScalerContext,
nativeScaler,
glyphs,
numGlyphs,
x, y);
}
return FontScaler
.getNullScaler().getGlyphVectorOutline(0L, glyphs, numGlyphs, x, y);
}
private GeneralPath convertToPixelPath(final GeoPos[] geoBoundary) {
final GeneralPath gp = new GeneralPath();
for (int i = 0; i < geoBoundary.length; i++) {
final GeoPos geoPos = geoBoundary[i];
final AffineTransform m2vTransform = layerCanvas.getViewport().getModelToViewTransform();
final Point2D viewPos = m2vTransform.transform(new PixelPos.Double(geoPos.lon, geoPos.lat), null);
if (i == 0) {
gp.moveTo(viewPos.getX(), viewPos.getY());
} else {
gp.lineTo(viewPos.getX(), viewPos.getY());
}
}
gp.closePath();
return gp;
}
/**
* Generates the clip path.
*
* @param dataArea the dataArea that the plot is being draw in.
* @param horizontalAxis the horizontal axis.
* @param verticalAxis the vertical axis.
*
* @return The GeneralPath defining the outline
*/
public GeneralPath generateClipPath(Rectangle2D dataArea,
ValueAxis horizontalAxis,
ValueAxis verticalAxis) {
GeneralPath generalPath = new GeneralPath();
double transX = horizontalAxis.valueToJava2D(
this.xValue[0], dataArea, RectangleEdge.BOTTOM
);
double transY = verticalAxis.valueToJava2D(
this.yValue[0], dataArea, RectangleEdge.LEFT
);
generalPath.moveTo((float) transX, (float) transY);
for (int k = 0; k < this.yValue.length; k++) {
transX = horizontalAxis.valueToJava2D(
this.xValue[k], dataArea, RectangleEdge.BOTTOM
);
transY = verticalAxis.valueToJava2D(
this.yValue[k], dataArea, RectangleEdge.LEFT
);
generalPath.lineTo((float) transX, (float) transY);
}
generalPath.closePath();
return generalPath;
}