本文整理汇总了Java中java.awt.geom.GeneralPath.moveTo方法的典型用法代码示例。如果您正苦于以下问题:Java GeneralPath.moveTo方法的具体用法?Java GeneralPath.moveTo怎么用?Java GeneralPath.moveTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.geom.GeneralPath
的用法示例。
在下文中一共展示了GeneralPath.moveTo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: polygon
import java.awt.geom.GeneralPath; //导入方法依赖的package包/类
/**
* 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
*/
public static void polygon(double[] x, double[] y) {
if (x == null) throw new IllegalArgumentException("x-coordinate array is null");
if (y == null) throw new IllegalArgumentException("y-coordinate array is null");
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();
}
示例2: plotXY
import java.awt.geom.GeneralPath; //导入方法依赖的package包/类
public void plotXY( Graphics2D g,
Rectangle2D bounds,
double xScale, double yScale,
int k) {
GeneralPath path = new GeneralPath();
boolean start = true;
for( int i=0 ; i<rows.size() ; i++) {
if( !plot[k][i] )continue;
double[] row = (double[])rows.get(i);
float x = (float)((row[k+1]-bounds.getX())*xScale);
float y = (float)((row[0]-bounds.getY())*yScale);
if( start ) {
path.moveTo(x,y);
start = false;
} else path.lineTo(x,y);
}
g.setColor( Color.white );
g.setStroke( new BasicStroke(3f) );
g.draw(path);
g.setColor( Color.black );
g.setStroke( new BasicStroke(1f) );
g.draw(path);
}
示例3: getRegiaoDocumento
import java.awt.geom.GeneralPath; //导入方法依赖的package包/类
public Shape getRegiaoDocumento() {
if (Regiao == null) {
final int v1 = getHeight() / 3;
final int h1 = getWidth() / 2;
final int repo = v1 / 3;
final int L = getLeft();
final int T = getTop();
final int TH = T + getHeight() - repo;
final int LW = L + getWidth();
CubicCurve2D c = new CubicCurve2D.Double();
c.setCurve(L, TH, L + h1, TH + v1, LW - h1, TH - v1, LW, TH);
GeneralPath pa = new GeneralPath();
pa.moveTo(LW, TH);
pa.lineTo(LW, T);
pa.lineTo(L, T);
pa.lineTo(L, TH);
pa.append(c, true);
Regiao = pa;
final int ptToMove = 3;
this.reposicionePonto[ptToMove] = new Point(0, -repo);
ptsToMove[ptToMove] = 1;
}
return Regiao;
}
示例4: getOuterWindow
import java.awt.geom.GeneralPath; //导入方法依赖的package包/类
protected Shape getOuterWindow(Rectangle2D frame) {
double radiusMargin = 0.02;
double angleMargin = 1.5;
Rectangle2D innerFrame = DialPlot.rectangleByRadius(frame,
this.innerRadius - radiusMargin, this.innerRadius
- radiusMargin);
Rectangle2D outerFrame = DialPlot.rectangleByRadius(frame,
this.outerRadius + radiusMargin, this.outerRadius
+ radiusMargin);
Arc2D inner = new Arc2D.Double(innerFrame, this.startAngle
- angleMargin, this.extent + 2 * angleMargin, Arc2D.OPEN);
Arc2D outer = new Arc2D.Double(outerFrame, this.startAngle
+ angleMargin + this.extent, - this.extent - 2 * angleMargin,
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;
}
示例5: plotXY
import java.awt.geom.GeneralPath; //导入方法依赖的package包/类
public void plotXY( Graphics2D g,
Rectangle2D bounds,
double xScale, double yScale,
int dataIndex) {
doLookup();
GeneralPath path = new GeneralPath();
float x0 = (float)bounds.getX();
float y0 = (float)(bounds.getY()+bounds.getHeight());
path.moveTo( x0, y0 );
for(int k=0 ; k<=255 ; k++) {
if( k==0 ) {
path.moveTo( (float)(xScale*(k - bounds.getX())),
(float)(yScale*(lookup[k] -bounds.getY())) );
} else {
path.lineTo( (float)(xScale*(k - bounds.getX())),
(float)(yScale*(lookup[k] -bounds.getY())) );
}
}
g.setColor( Color.black );
g.draw( path );
}
示例6: generateClipPath
import java.awt.geom.GeneralPath; //导入方法依赖的package包/类
/**
* 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;
}
示例7: paintGraph
import java.awt.geom.GeneralPath; //导入方法依赖的package包/类
@Override
public void paintGraph(Graphics2D g, int width, int height) {
g.setColor(new Color(0, 0, 0, 127));
g.drawString("1.0", 2, g.getFontMetrics().getHeight());
g.drawString("0.0", 2, height-g.getFontMetrics().getDescent());
g.setColor(new Color(0, 0, 0, 200));
g.setStroke(new BasicStroke(3f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_ROUND));
ArrayList<Keyframe<Float>> copy = new ArrayList<>(keyframes);
if(dragFrame != null)
copy.add(dragFrame);
Collections.sort(copy);
if(copy.get(0).getTime() != 0f)
copy.add(0, new Keyframe<Float>(0f, copy.get(0).getValue()));
if(copy.get(copy.size()-1).getTime() != 1f)
copy.add(new Keyframe<Float>(1f, copy.get(copy.size()-1).getValue()));
GeneralPath path = new GeneralPath();
path.moveTo(copy.get(0).getTime() * width, (1f - copy.get(0).getValue()) * height);
for(int i = 1; i < copy.size(); i++)
path.lineTo(copy.get(i).getTime() * width, ((1f - copy.get(i).getValue()) * height-.5f));
g.draw(path);
g.setStroke(new BasicStroke(3)); //Draw red bar at each keyframe
g.setColor(new Color(255, 0, 0, 32));
for(int i = 1; i < copy.size()-1; i++)
g.drawLine((int) (copy.get(i).getTime() * width), 0, (int) (copy.get(i).getTime() * width), height);
}
示例8: PaintGradiente
import java.awt.geom.GeneralPath; //导入方法依赖的package包/类
protected void PaintGradiente(Graphics2D g, boolean round) {
int dist = 0;
int w = getWidth() - dist;
int h = getHeight() - dist;
int L = getLeft();
int T = getTop();
boolean dv = getGDirecao() == VERTICAL;
//Composite originalComposite = g.getComposite();
//g.setComposite(AlphaComposite.getInstance(AlphaComposite.DST_OVER, alfa));
GradientPaint GP = new GradientPaint(L, T, getGradienteStartColor(), dv ? L : L + w, dv ? T + h : T, getGradienteEndColor(), true);
//g.setPaint(GP);
g.setPaint(getForeColor());
if (round) {
g.drawRoundRect(L, T, w - 1, h - 1, roundRectSize, roundRectSize);
g.setPaint(GP);
g.fillRoundRect(L + 1, T + 1, w - 2, h - 2, roundRectSize, roundRectSize);
g.setPaint(isDisablePainted()? disabledColor : Color.WHITE);
g.drawRoundRect(L + 1, T + 1, w - 3, h - 3, roundRectSize, roundRectSize);
} else {
g.drawRect(L, T, w - 1, h - 1);
g.setPaint(GP);
g.fillRect(L + 1, T + 1, w - 2, h - 2);
g.setPaint(isDisablePainted()? disabledColor : Color.WHITE);
g.drawRect(L + 1, T + 1, w - 3, h - 3);
}
if (isGradientePinteDetalhe()) {
g.setPaint(getGradienteCorDetalhe());
GeneralPath path = new GeneralPath();
path.moveTo(L + 2, T + 2);
path.quadTo(L + w / 2 + 1, T + h / 2 + 1, L + w - 1, T + 2);
path.closePath();
g.fill(path);
}
//g.setComposite(originalComposite);
}
示例9: XYAreaRenderer
import java.awt.geom.GeneralPath; //导入方法依赖的package包/类
/**
* Constructs a new renderer. To specify the type of renderer, use one of
* the constants: <code>SHAPES</code>, <code>LINES</code>,
* <code>SHAPES_AND_LINES</code>, <code>AREA</code> or
* <code>AREA_AND_SHAPES</code>.
*
* @param type the type of renderer.
* @param toolTipGenerator the tool tip generator to use
* (<code>null</code> permitted).
* @param urlGenerator the URL generator (<code>null</code> permitted).
*/
public XYAreaRenderer(int type, XYToolTipGenerator toolTipGenerator,
XYURLGenerator urlGenerator) {
super();
setBaseToolTipGenerator(toolTipGenerator);
setURLGenerator(urlGenerator);
if (type == SHAPES) {
this.plotShapes = true;
}
if (type == LINES) {
this.plotLines = true;
}
if (type == SHAPES_AND_LINES) {
this.plotShapes = true;
this.plotLines = true;
}
if (type == AREA) {
this.plotArea = true;
}
if (type == AREA_AND_SHAPES) {
this.plotArea = true;
this.plotShapes = true;
}
this.showOutline = false;
GeneralPath area = new GeneralPath();
area.moveTo(0.0f, -4.0f);
area.lineTo(3.0f, -2.0f);
area.lineTo(4.0f, 4.0f);
area.lineTo(-4.0f, 4.0f);
area.lineTo(-3.0f, -2.0f);
area.closePath();
this.legendArea = area;
}
示例10: drawOutline
import java.awt.geom.GeneralPath; //导入方法依赖的package包/类
/**
* Draws the outline for the plot.
*
* @param g2 the graphics device.
* @param plot the plot.
* @param dataArea the area inside the axes.
*/
public void drawOutline(Graphics2D g2, CategoryPlot plot,
Rectangle2D dataArea) {
float x0 = (float) dataArea.getX();
float x1 = x0 + (float) Math.abs(this.xOffset);
float x3 = (float) dataArea.getMaxX();
float x2 = x3 - (float) Math.abs(this.xOffset);
float y0 = (float) dataArea.getMaxY();
float y1 = y0 - (float) Math.abs(this.yOffset);
float y3 = (float) dataArea.getMinY();
float y2 = y3 + (float) Math.abs(this.yOffset);
GeneralPath clip = new GeneralPath();
clip.moveTo(x0, y0);
clip.lineTo(x0, y2);
clip.lineTo(x1, y3);
clip.lineTo(x3, y3);
clip.lineTo(x3, y1);
clip.lineTo(x2, y0);
clip.closePath();
// put an outline around the data area...
Stroke outlineStroke = plot.getOutlineStroke();
Paint outlinePaint = plot.getOutlinePaint();
if ((outlineStroke != null) && (outlinePaint != null)) {
g2.setStroke(outlineStroke);
g2.setPaint(outlinePaint);
g2.draw(clip);
}
}
示例11: createBarShape
import java.awt.geom.GeneralPath; //导入方法依赖的package包/类
private static GeneralPath createBarShape() {
GeneralPath barShape = new GeneralPath();
barShape.moveTo(0, 0);
barShape.lineTo(0, -5);
barShape.lineTo(5, -5);
barShape.lineTo(5, 0);
barShape.lineTo(5, -15);
barShape.lineTo(10, -15);
barShape.lineTo(10, 0);
barShape.lineTo(10, -10);
barShape.lineTo(15, -10);
barShape.lineTo(15, 0);
barShape.closePath();
return barShape;
}
示例12: selectLasso
import java.awt.geom.GeneralPath; //导入方法依赖的package包/类
/**
Selects the area represented by poly
*/
void selectLasso(XYGraph xyg) {
GeneralPath path = new GeneralPath();
for (int i=0; i<poly.npoints; i++){
Point2D p2 = new Point2D.Float (poly.xpoints[i], poly.ypoints[i]);
Point2D point = new Point2D.Double (xyg.getXAt(p2), xyg.getYAt(p2));
if (i==0) path.moveTo((float)point.getX(), (float) point.getY());
else path.lineTo((float)point.getX(), (float) point.getY());
}
path.closePath();
Rectangle2D r = path.getBounds();
ds.dataT.getSelectionModel().setValueIsAdjusting(true);
if (scatter) {
int n = 0;
while (n<x.length&&(Float.isNaN(x[n])||Float.isNaN(y[n]))) {
n++;
}
if (n>=x.length) return;
for (int i = n; i < x.length; i++) {
if (Float.isNaN(x[i])||Float.isNaN(y[i])) continue;
if (r.contains(x[i], y[i]) && path.contains(x[i], y[i])) {
ds.dataT.getSelectionModel().addSelectionInterval(i, i);
}
}
}
unDrawLasso(xyg);
// selectionChangedRedraw(ds.selected);
ds.dataT.getSelectionModel().setValueIsAdjusting(false);
if (ds.dataT.getSelectedRow() != -1)
ds.dataT.ensureIndexIsVisible(ds.dataT.getSelectedRow());
}
示例13: createArrow
import java.awt.geom.GeneralPath; //导入方法依赖的package包/类
protected Shape createArrow(float fx, float fy, float tx, float ty) {
float dx = tx - fx;
float dy = ty - fy;
float D = (float) Math.sqrt(dx * dx + dy * dy);
float z = (dx <= 0) ? fx - D : fx + D;
double alpha = (dx > 0) ? Math.asin(dy / D) : -Math.asin(dy / D);
float h = arrowWidth * 2;
int n = (int) (D / h);
h = D / (float) (n + 1);
if (n < 0)
n = 0;
float dec = (dx <= 0) ? h : -h;
GeneralPath gp = new GeneralPath();
for (int i = 0; i <= n; i++) {
gp.moveTo(z + dec, fy - arrowWidth);
gp.lineTo(z + dec / 2f, fy - arrowWidth);
gp.lineTo(z, fy);
gp.lineTo(z + dec / 2f, fy + arrowWidth);
gp.lineTo(z + dec, fy + arrowWidth);
gp.lineTo(z + dec / 2f, fy);
z += dec;
}
gp.closePath();
AffineTransform affineTransform = new AffineTransform();
affineTransform.rotate(alpha, fx, fy);
return gp.createTransformedShape(affineTransform);
}
示例14: createStrokedShape
import java.awt.geom.GeneralPath; //导入方法依赖的package包/类
/**
* @see java.awt.Stroke#createStrokedShape(java.awt.Shape)
*/
public Shape createStrokedShape (Shape shape) {
GeneralPath result = new GeneralPath();
shape = new BasicStroke(getWidth(), BasicStroke.CAP_SQUARE, getJoin()).createStrokedShape(shape);
PathIterator it = new FlatteningPathIterator(shape.getPathIterator(null), FLATNESS);
float points[] = new float[6];
float moveX = 0, moveY = 0;
float lastX = 0, lastY = 0;
float thisX = 0, thisY = 0;
int type = 0;
float next = 0;
while (!it.isDone()) {
type = it.currentSegment(points);
switch (type) {
case PathIterator.SEG_MOVETO:
moveX = lastX = randomize(points[0]);
moveY = lastY = randomize(points[1]);
result.moveTo(moveX, moveY);
next = 0;
break;
case PathIterator.SEG_CLOSE:
points[0] = moveX;
points[1] = moveY;
// Fall into....
case PathIterator.SEG_LINETO:
thisX = randomize(points[0]);
thisY = randomize(points[1]);
float dx = thisX - lastX;
float dy = thisY - lastY;
float distance = (float)Math.sqrt(dx * dx + dy * dy);
if (distance >= next) {
float r = 1.0f / distance;
while (distance >= next) {
float x = lastX + next * dx * r;
float y = lastY + next * dy * r;
result.lineTo(randomize(x), randomize(y));
next += detail;
}
}
next -= distance;
lastX = thisX;
lastY = thisY;
break;
}
it.next();
}
return result;
}
示例15: selectLasso
import java.awt.geom.GeneralPath; //导入方法依赖的package包/类
public void selectLasso() {
GeneralPath path = new GeneralPath();
for (int i=0; i<poly.npoints; i++){
Point2D point = map.getScaledPoint(new Point(poly.xpoints[i],poly.ypoints[i]));
if (i==0) path.moveTo((float)point.getX(), (float) point.getY());
else path.lineTo((float)point.getX(), (float) point.getY());
}
path.closePath();
r=path.getBounds();
// Point2D p = map.getScaledPoint(new Point(r.x,r.y));
// Rectangle2D.Double r = new Rectangle2D.Double(p.getX(),p.getY(),
// this.r.width/map.getZoom(),this.r.height/map.getZoom());
Rectangle2D rect = map.getClipRect2D();
float yMin = (float)rect.getY();
float yMax = (float)(rect.getY() + rect.getHeight());
float xMin = (float)rect.getX();
float xMax = (float)(rect.getX() + rect.getWidth());
float wrap = (float)map.getWrap();
//System.out.println(xMin+"\t"+xMax+"\t"+yMin+"\t"+yMax);
dataT.getSelectionModel().setValueIsAdjusting(true);
if (station){
for( int k=0 ; k<tm.displayToDataIndex.size() ; k++) {
int z = tm.displayToDataIndex.get(k);
UnknownData d = data.get(z);
if (f!=null&&k<f.length&&Float.isNaN(f[k])) continue;
if (f2!=null&&k<f2.length&&Float.isNaN(f2[k])) continue;
if (dataT.isRowSelected(k)){ continue; }
//Symbol s = new Symbol(Symbol.CIRCLE, (float) (3./zoom), b, a);
float x = d.x;
float y = d.y;
//System.out.println(d+"\t"+yMin+"\t"+yMax);
if( y<yMin || y>yMax ) continue;
if (Float.isNaN(d.x) || Float.isNaN(d.y)) continue;
if( wrap>0f ) {
while( x>xMin+wrap ) x -= wrap;
while( x<xMin ) x += wrap;
while( x<xMax ) {
if (r.contains(x, y)&&path.contains(x, y))
dataT.getSelectionModel().addSelectionInterval(k, k);
x += wrap;
}
} else {
if( x>xMin && x<xMax ) {
if (r.contains(x, y)&&path.contains(x, y))
dataT.getSelectionModel().addSelectionInterval(k, k);
}
}
}
}
dataT.getSelectionModel().setValueIsAdjusting(false);
unDrawLasso();
// selectionChangedRedraw(os);
if (dataT.getSelectedRow() != -1)
dataT.ensureIndexIsVisible(dataT.getSelectedRow());
}