Está en la página 1de 3

import

import
import
import
import
import
import
import
import

java.awt.Color;
java.awt.Dimension;
java.awt.Graphics;
java.awt.Graphics2D;
javax.swing.JPanel;
java.awt.Rectangle;
java.awt.Shape;
java.awt.geom.*;
javax.swing.JFrame;

public class Original {


public static void main(String[] args) {
// TODO code application logic here
JFrame f1=new JFrame ("Dibujo");
f1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Dibujo d=new Dibujo();
f1.add(d);
f1.pack();
f1.setVisible(true);
}
}
public class Dibujo extends JPanel{
public Dibujo(){
setPreferredSize(new
Dimension(800,600));
setBackground(Color.white);
}
@Override
public void paintComponent(Graphics g){
super.paintComponent(g);
Graphics2D g2 = (Graphics2D)g;
MyTank tank = new MyTank(50,80,600,300);
g2.draw(tank);
}
}
public class MyTank implements Shape{
private GeneralPath ruta;
public MyTank(double x,double y, double w, double h){
ruta= new GeneralPath();
ruta.moveTo(x+.1*w,y+h);
ruta.lineTo(x+0.6*w,y+h);
ruta.curveTo(x+0.75*w, y+h, x+0.75*w, y+0.6*h, x+0.6*w, y+0.6*h);
ruta.lineTo(x+0.1*w,y+0.6*h);
ruta.curveTo(x, y+0.6*h, x, y+h, x+0.1*w, y+h);
ruta.moveTo(x+0.15*w,y+0.6*h);
ruta.curveTo(x+0.1*w,y+0.6*h,x+0.1*w,y+0.4*h,x+0.15*w,y+0.4*h);
ruta.lineTo(x+0.45*w,y+0.4*h);
ruta.curveTo(x+0.5*w, y+0.4*h, x+0.5*w, y+0.6*h, x+0.45*w, y+0.6*h);
ruta.moveTo(x+0.2*w,y+0.4*h);
ruta.curveTo(x+0.15*w, y+0.4*h, x+0.15*w, y+0.2*h, x+0.2*w, y+0.2*h);
ruta.lineTo(x+0.4*w, y+0.2*h);

ruta.curveTo(x+0.45*w, y+0.2*h, x+0.45*w, y+0.4*h, x+0.4*w, y+0.4*h);


ruta.moveTo(x+0.2*w,y+0.2*h);
ruta.lineTo(x+0.3*w, y+0.1*h);
ruta.quadTo(x+0.35*w, y+0.05*h, x+0.4*w, y+0.05*h);
ruta.lineTo(x+0.47*w,y+0.06*h);
ruta.quadTo(x+0.54*w,y+0.062*h,x+0.5*w,y+0.11*h);
ruta.lineTo(x+0.4*w,y+0.2*h);
ruta.moveTo(x+0.7*w,y+0.89*h);
ruta.lineTo(x+0.77*w,y+0.75*h);
ruta.quadTo(x+0.8*w,y+0.7*h,x+0.8*w,y+0.6*h);
ruta.quadTo(x+0.8*w,y+0.4*h,x+0.7*w,y+0.4*h);
ruta.lineTo(x+0.57*w, y+0.4*h);
ruta.curveTo(x+0.62*w, y+0.4*h, x+0.62*w, y+0.25*h,x+0.57*w,y+0.25*h);
ruta.lineTo(x+0.52*w,y+0.25*h);
ruta.curveTo(x+0.57*w,y+0.25*h,x+0.57*w,y+0.09*h,x+0.513*w,y+0.09*h);
ruta.moveTo(x+0.48*w,y+0.57*h);
ruta.lineTo(x+0.58*w,y+0.4*h);
ruta.moveTo(x+0.43*w,y+0.37*h);
ruta.lineTo(x+0.53*w,y+0.25*h);
ruta.moveTo(x+0.48*w,y+0.27*h);
ruta.lineTo(x+0.95*w,y+0.1*h);
ruta.curveTo(x+0.97*w, y+0.07*h, x+0.93*w, y+0.04*h, x+0.93*w, y+0.05*h)
;
ruta.lineTo(x+0.48*w, y+0.25*h);
ruta.moveTo(x+0.15*w,y+0.95*h);
ruta.curveTo(x+0.25*w,y+0.95*h,x+0.25*w,y+0.65*h,x+0.15*w,y+0.65*h);
ruta.curveTo(x+0.05*w,y+0.65*h,x+0.05*w,y+0.95*h,x+0.15*w,y+0.95*h);
ruta.moveTo(x+0.3*w,y+0.95*h);
ruta.curveTo(x+0.4*w,y+0.95*h,x+0.4*w,y+0.65*h,x+0.3*w,y+0.65*h);
ruta.curveTo(x+0.2*w,y+0.65*h,x+0.2*w,y+0.95*h,x+0.3*w,y+0.95*h);
ruta.moveTo(x+0.45*w,y+0.95*h);
ruta.curveTo(x+0.55*w,y+0.95*h,x+0.55*w,y+0.65*h,x+0.45*w,y+0.65*h);
ruta.curveTo(x+0.35*w,y+0.65*h,x+0.35*w,y+0.95*h,x+0.45*w,y+0.95*h);
ruta.moveTo(x+0.6*w,y+0.95*h);
ruta.curveTo(x+0.7*w,y+0.95*h,x+0.7*w,y+0.65*h,x+0.6*w,y+0.65*h);
ruta.curveTo(x+0.5*w,y+0.65*h,x+0.5*w,y+0.95*h,x+0.6*w,y+0.95*h);
}
@Override
public Rectangle getBounds() {
return ruta.getBounds();
}
@Override
public Rectangle2D getBounds2D() {
return ruta.getBounds2D();
}
@Override
public boolean contains(double d, double d1) {
return ruta.contains(d, d1);
}
@Override
public boolean contains(Point2D pd) {
return ruta.contains(pd);
}
@Override

public boolean intersects(double d, double d1, double d2, double d3) {


return ruta.intersects(d, d1, d2, d3);
}
@Override
public boolean intersects(Rectangle2D rd) {
return ruta.contains(rd);
}
@Override
public boolean contains(double d, double d1, double d2, double d3) {
return ruta.contains(d, d1, d2, d3);
}
@Override
public boolean contains(Rectangle2D rd) {
return ruta.contains(rd);
}
@Override
public PathIterator getPathIterator(AffineTransform at) {
return ruta.getPathIterator(at);
}
@Override
public PathIterator getPathIterator(AffineTransform at, double d) {
return ruta.getPathIterator(at, d);
}
}

También podría gustarte