本文整理汇总了Java中java.awt.geom.GeneralPath.lineTo方法的典型用法代码示例。如果您正苦于以下问题:Java GeneralPath.lineTo方法的具体用法?Java GeneralPath.lineTo怎么用?Java GeneralPath.lineTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.geom.GeneralPath
的用法示例。
在下文中一共展示了GeneralPath.lineTo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: drawLine
import java.awt.geom.GeneralPath; //导入方法依赖的package包/类
private void drawLine(Graphics g, LinePlot line, int width, int height) {
double[] data = line.lineData;
float columnDistance = (float) width / (float) (data.length - 1);
GeneralPath path = new GeneralPath();
float xPos = 0.0f;
path.moveTo(xPos, normY(data[0]) * height);
for (int d = 1; d < data.length; d++) {
xPos += columnDistance;
path.lineTo(xPos, normY(data[d]) * height);
}
Color color = Color.RED;
if (colorColumn != -1) {
color = getColorProvider().getPointColor(line.color);
}
g.setColor(color);
((Graphics2D) g).draw(path);
}
示例2: createDiamondShape
import java.awt.geom.GeneralPath; //导入方法依赖的package包/类
/** Creates a diamond shape inscribed in the bounds given in the parameters. */
private Shape createDiamondShape(double x, double y, double width, double height) {
GeneralPath result = new GeneralPath(Path2D.WIND_NON_ZERO, 5);
result.moveTo(x + width / 2, y);
result.lineTo(x + width, y + height / 2);
result.lineTo(x + width / 2, y + height);
result.lineTo(x, y + height / 2);
result.closePath();
return result;
}
示例3: drawGlassEffect
import java.awt.geom.GeneralPath; //导入方法依赖的package包/类
/**
* Draws the glass effect
*/
public static void drawGlassEffect(mxGraphics2DCanvas canvas, mxCellState state) {
double size = 0.4;
canvas.getGraphics()
.setPaint(new GradientPaint((float) state.getX(), (float) state.getY(),
new Color(1, 1, 1, 0.9f), (float) (state.getX()),
(float) (state.getY() + state.getHeight() * size), new Color(1, 1, 1, 0.3f)));
float sw = (float) (mxUtils.getFloat(state.getStyle(), mxConstants.STYLE_STROKEWIDTH, 1)
* canvas.getScale() / 2);
GeneralPath path = new GeneralPath();
path.moveTo((float) state.getX() - sw, (float) state.getY() - sw);
path.lineTo((float) state.getX() - sw, (float) (state.getY() + state.getHeight() * size));
path.quadTo((float) (state.getX() + state.getWidth() * 0.5),
(float) (state.getY() + state.getHeight() * 0.7),
(float) (state.getX() + state.getWidth() + sw),
(float) (state.getY() + state.getHeight() * size));
path.lineTo((float) (state.getX() + state.getWidth() + sw), (float) state.getY() - sw);
path.closePath();
canvas.getGraphics().fill(path);
}
示例4: getStar
import java.awt.geom.GeneralPath; //导入方法依赖的package包/类
/**
* Return the basic five-point star.
*
* @return the basic star shape
*/
private static GeneralPath getStar() {
GeneralPath star = new GeneralPath(GeneralPath.WIND_NON_ZERO);
double angle = 2 * Math.PI / 5;
double radius = STAR_SIZE / 2;
double x = 0;
double y = -radius;
star.moveTo(x, y);
int[] vertex = { 2, 4, 1, 3 };
for (int i : vertex) {
double phi = i * angle;
x = radius * Math.sin(phi);
y = -radius * Math.cos(phi);
star.lineTo(x, y);
}
star.closePath();
return star;
}
示例5: 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());
}
示例6: getGeneralPath
import java.awt.geom.GeneralPath; //导入方法依赖的package包/类
GeneralPath getGeneralPath(Point2D[] pts) {
Projection proj = map.getProjection();
GeneralPath path = new GeneralPath();
float[] lastP = null;
float wrap = (float)map.getWrap()/2f;
boolean tf = profileTypes != null && straightLine.isSelected();
for( int k=0 ; k<pts.length ; k++) {
Point2D p = proj.getMapXY( pts[k] );
float x = (float)p.getX();
float y = (float)p.getY();
//System.out.println("wrap " + wrap);
//System.out.println("" + (lastP!=null));
if( lastP!=null && wrap>0f ) {
while( x-lastP[0] <-wrap ){x+=wrap*2f;}
while( x-lastP[0] > wrap ){x-=wrap*2f;}
}
lastP = new float[] {x, y};
if( k==0 ) path.moveTo( x, y );
else path.lineTo( x, y );
}
return path;
}
示例7: getRhombus
import java.awt.geom.GeneralPath; //导入方法依赖的package包/类
private GeneralPath getRhombus() {
GeneralPath rhombus = new GeneralPath();
rhombus.moveTo(WIDTH / 2, BEND_Y);
rhombus.lineTo(WIDTH - BEND_X, HEIGHT / 2);
rhombus.lineTo(WIDTH / 2, HEIGHT - BEND_Y);
rhombus.lineTo(BEND_X, HEIGHT / 2);
return rhombus;
}
示例8: drawGlassEffect
import java.awt.geom.GeneralPath; //导入方法依赖的package包/类
/**
* Draws the glass effect
*/
public static void drawGlassEffect(mxGraphics2DCanvas canvas,
mxCellState state)
{
double size = 0.4;
canvas.getGraphics().setPaint(
new GradientPaint((float) state.getX(), (float) state.getY(),
new Color(1, 1, 1, 0.9f), (float) (state.getX()),
(float) (state.getY() + state.getHeight() * size),
new Color(1, 1, 1, 0.3f)));
float sw = (float) (mxUtils.getFloat(state.getStyle(),
mxConstants.STYLE_STROKEWIDTH, 1) * canvas.getScale() / 2);
GeneralPath path = new GeneralPath();
path.moveTo((float) state.getX() - sw, (float) state.getY() - sw);
path.lineTo((float) state.getX() - sw,
(float) (state.getY() + state.getHeight() * size));
path.quadTo((float) (state.getX() + state.getWidth() * 0.5),
(float) (state.getY() + state.getHeight() * 0.7),
(float) (state.getX() + state.getWidth() + sw),
(float) (state.getY() + state.getHeight() * size));
path.lineTo((float) (state.getX() + state.getWidth() + sw),
(float) state.getY() - sw);
path.closePath();
canvas.getGraphics().fill(path);
}
示例9: draw
import java.awt.geom.GeneralPath; //导入方法依赖的package包/类
public void draw( Graphics2D g ) {
Rectangle area = g.getClipBounds();
currentPoint = null;
if( !intersects(area) ) return;
Color color = g.getColor();
g.setColor( offColor);
GeneralPath path = new GeneralPath();
float offset = (float)this.offset;
for( int seg=0 ; seg<cptIndex.length ; seg++ ) {
path.moveTo( offset+cptX[seg][0], cptY[seg][0] );
for( int i=0 ; i<cptIndex[seg].length ; i++ ) {
path.lineTo( offset+cptX[seg][i], cptY[seg][i] );
}
}
g.draw(path);
double wrap = map.getWrap();
if(wrap>0) {
AffineTransform xform = g.getTransform();
offset += (float)wrap;
while( mapBounds.getX()+(double)offset < area.getX()+area.getWidth() ) {
g.translate( (double)wrap, 0.d );
g.draw(path);
offset += (float)wrap;
}
g.setTransform( xform );
}
g.setColor( onColor );
drawCurrentSeg(g, true);
g.setColor( color );
}
示例10: drawCoOrdinates
import java.awt.geom.GeneralPath; //导入方法依赖的package包/类
public static void drawCoOrdinates(double[]x,double[]y,int size, Graphics2D g){
GeneralPath path = new GeneralPath();
path.moveTo(x[0],-y[0]);
for(int j=1;j<(size+1);j++){
path.lineTo(x[j], -y[j]);
}
path.closePath();
g.setColor(Color.BLACK);
g.fill(path);
}
示例11: paintGraph
import java.awt.geom.GeneralPath; //导入方法依赖的package包/类
@Override
public void paintGraph(Graphics2D g, int width, int height) {
FontMetrics fm = g.getFontMetrics();
float min = (Integer) minSpinner.getValue();
float max = (Integer) maxSpinner.getValue();
float range = max - min;
g.setColor(scaleTextColor);
g.drawString(String.format("%.1f", range/2f+min), scaleTextInset, (height+fm.getHeight())/2 - fm.getDescent());
g.setColor(lineColor);
g.setStroke(new BasicStroke(3f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_ROUND));
ArrayList<Keyframe<Integer>> copy = new ArrayList<>(keyframes);
if(dragFrame != null)
copy.add(dragFrame);
Collections.sort(copy);
if(copy.get(0).getTime() != 0f)
copy.add(0, new Keyframe<Integer>(0f, copy.get(0).getValue()));
if(copy.get(copy.size()-1).getTime() != 1f)
copy.add(new Keyframe<Integer>(1f, copy.get(copy.size()-1).getValue()));
GeneralPath path = new GeneralPath();
path.moveTo(copy.get(0).getTime() * width, Math.round(((1f - (copy.get(0).getValue()-min)/range) * height)));
for(int i = 1; i < copy.size(); i++)
path.lineTo(copy.get(i).getTime() * width, Math.round((1f - (copy.get(i).getValue()-min)/range) * height)-.5f);
g.draw(path);
g.setStroke(new BasicStroke(3)); //Draw red bar at each keyframe
g.setColor(keyframeIndicatorColor);
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);
if(min < 0 && max > 0) {
g.setColor(zeroLineColor);
g.drawLine(0, (int) ((1-(-min/range))*height), width, (int) ((1-(-min/range))*height));
}
}
示例12: drawCosx
import java.awt.geom.GeneralPath; //导入方法依赖的package包/类
@SuppressWarnings("unused")
private void drawCosx(GeneralPath gp, Graphics2D g2d) {
for (double i = 0.000001; i <= 8 * Math.PI; i += 0.0001 * Math.PI) {
gp.lineTo(20 * i, 100 * -Math.cos(i));
}
g2d.draw(gp);
// 将当前画笔以Y中为对称轴,画偶函数(关于Y轴对称)
g2d.scale(-1, 1);
g2d.draw(gp);
}
示例13: 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();
int n = 0;
while (n<x.length&&(Float.isNaN(x[n])||Float.isNaN(y[n]))) {
n++;
}
if (n>=x.length) return;
table.getSelectionModel().setValueIsAdjusting(true);
table.clearSelection();
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])) {
table.getSelectionModel().addSelectionInterval(i, i);
}
}
table.getSelectionModel().setValueIsAdjusting(false);
unDrawLasso(xyg);
if (table.getSelectedRow() != -1)
table.ensureIndexIsVisible(table.getSelectedRow());
}
示例14: paintComponent
import java.awt.geom.GeneralPath; //导入方法依赖的package包/类
@Override
public void paintComponent(Graphics g) {
if (mainButton != null && mainButton.getModel().isArmed() || getModel().isArmed()) {
((Graphics2D) g).translate(1.1, 1.1);
}
((Graphics2D) g).setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
super.paintComponent(g);
Graphics2D g2 = (Graphics2D) g.create();
// fill background white
g2.setColor(BACKGROUND_COLOR);
g2.fillRect(3, 0, getWidth() - 9, getHeight() - 6);
// draw border which complements the DropShadow
g2.setColor(BORDER_LIGHTEST_GRAY);
g2.drawLine(3, 0, 3, getHeight() - 6);
g2.drawLine(getWidth() - 6, 0, getWidth() - 6, getHeight() - 6);
g2.drawLine(3, getHeight() - 6, getWidth() - 6, getHeight() - 6);
g2.drawLine(3, 0, getWidth() - 6, 0);
// draw arrow
GeneralPath arrow = new GeneralPath();
int w, h;
h = (int) (2 * sizeFactor);
w = (int) (4 * sizeFactor);
arrow.moveTo(getWidth() / 2 - w, getHeight() / 2);
arrow.lineTo(getWidth() / 2 + w, getHeight() / 2);
arrow.lineTo(getWidth() / 2, getHeight() / 2 + 2 * h);
arrow.closePath();
if (isEnabled()) {
g2.setColor(HOVERED_TEXTCOLOR);
} else {
g2.setColor(BORDER_LIGHTEST_GRAY);
}
g2.fill(arrow);
g2.dispose();
}
示例15: 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;
}