[code]package br.com.maxlider.base;
import java.awt.Color;
import java.awt.Point;
/**
*
-
@author Max Lider Classe responsavel pelas Elipses (Circulos)
*/
public class Elipse implements Shape {
private Point initialPoint;
private Point finalPoint;
private Integer width;
private Integer heigth;
private Integer pointx;
private Integer pointy;
private Color color;/**
- @param initialPoint
-
Ponto Inicial da Elipse
- @param finalPoint
-
Ponto Final da Elipse
- @param color
-
Cor da Elipse
*/
public Elipse(Point initialPoint, Point finalPoint, Color color) {
this.initialPoint = initialPoint;
this.finalPoint = finalPoint;
this.color = color;
}/**
- Retorna a largura da elipse, de acordo com seu ponto inicial, e final.
-
@return
*/
public int getWidth() {
if (getInitialPoint().x > getFinalPoint().x) {
this.width = getInitialPoint().x - getFinalPoint().x;
return this.width;
} else {
this.width = getFinalPoint().x - getInitialPoint().x;
return this.width;
}
}
/**
- Retorna a Altura da Elipse, de acordo com seu ponto inicial, e final.
-
@return
*/
public int getHeight() {
if (getInitialPoint().y > getFinalPoint().y) {
this.heigth = getInitialPoint().y - getFinalPoint().y;
return this.heigth;
} else {
this.heigth = getFinalPoint().y - getInitialPoint().y;
return this.heigth;
}
}
public Point getInitialPoint() {
return initialPoint;
}public Point getFinalPoint() {
return finalPoint;
}public Integer getPointx() {
return pointx;
}public Integer getPointy() {
return pointy;
}public Color getColor() {
return color;
}/**
- Metodo organiza as coordenadas dos eixos X e Y para direcionar
- corretamente a rendenizacao.
*/
public void draw() {
pointx = getInitialPoint().x;
pointy = getInitialPoint().y;
if (getInitialPoint().x > getFinalPoint().x && getInitialPoint().y > getFinalPoint().y) {
pointx = getFinalPoint().x;
pointy = getFinalPoint().y;
} else if (getInitialPoint().x > getFinalPoint().x && getInitialPoint().y < getFinalPoint().y) {
pointx = getFinalPoint().x;
pointy = getInitialPoint().y;
} else if (getInitialPoint().x < getFinalPoint().x && getInitialPoint().y > getFinalPoint().y) {
pointy = getFinalPoint().y;
}
}
}[/code]
ESTA SEGUNDA PARTE PINTA, POR QUE MEU CIRCULO ESTA COM PROBLEMAS???..
Ele não está desenhando corretamente.
Elipse elipse = new Elipse(new Point(line.getPoint1().x, line.getPoint1().y), new Point(line.getPoint2().x, line.getPoint2().y), lineColor);
elipse.draw();
draws.push(elipse);
for (Shape e : draws) {
g.setColor(((Elipse) e).getColor());
g.drawOval(((Elipse) e).getPointx(), ((Elipse) e).getPointy(), ((Elipse) e).getWidth(), ((Elipse) e).getWidth());
}