Results 1 to 3 of 3
  1. #1
    kepep is offline Member
    Join Date
    Dec 2010
    Rep Power

    Default 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:

    Java Code:
    protected void paintComponent(Graphics g) {
       Graphics2D g2d = (Graphics2D) g;
       Shape s = new WuLine(x1, y1, x2, y2);
    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?

    Attached Files Attached Files
    Last edited by kepep; 12-10-2010 at 07:03 PM. Reason: Im sorry I forgot to remove non english comments from the source code.

  2. #2
    Join Date
    Dec 2010
    Rep Power


    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

  3. #3
    toadaly is offline Senior Member
    Join Date
    Jan 2009
    Rep Power


    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.

Similar Threads

  1. Help with Move Shape
    By romina in forum AWT / Swing
    Replies: 2
    Last Post: 12-09-2010, 04:25 AM
  2. Replies: 1
    Last Post: 04-02-2010, 01:48 PM
  3. rezise shape
    By frankenstein in forum Java 2D
    Replies: 5
    Last Post: 07-30-2009, 01:44 AM
  4. implementing shape
    By sidkdbl07 in forum Java 2D
    Replies: 1
    Last Post: 01-12-2008, 07:42 PM
  5. tool to create shape frame
    By boy22 in forum AWT / Swing
    Replies: 1
    Last Post: 08-05-2007, 05:10 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts