-
1 Attachment(s)
create own shape
Hi, every body
I created a simple application in netbeans which uses wu algorithm for drawing antialiased lines. The application is made from a JFrame and JPanel. I can choose the color of the line etc. The problem is that I want to be able to use the algorithm in other applications and I dont want to copy it everytime to new project. I would like to know if there is possibility to create similar class to Line2D from Graphics2D so I could draw the line like this:
Code:
protected void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2d = (Graphics2D) g;
g2d.setColor(lineColor);
Shape s = new WuLine(x1, y1, x2, y2);
g2d.draw(s);
}
I thougt that I would copy the line2D class and recreate it to suit my needs but it seems that there is no drawing process at all in this class. Could you please tell me if there is any way to create a class similar to line2D?
Thanks.
-
Hi,
im kinda new to Java too, but i cant see any assigment from RHS...
Havent you forgot return shape object from the contructor?
Regards RL
-
Sure. You can simply extend the Line2D class and change it to do what you want, or if that won't get you what you need, you can start from scratch and implement the Shape interface directly.