An excellent platform independent vector drawing gift for you!
Home | Products | Download | Documentations | Order Now | Contact |  
 
FAQs
Quick Install
Developer Guide
ScreenShots
Award
 
    Java.net
    AbleStable
    Softpedia
    FreeTrialSoft
    FreshMeat
    Download32
    More...
  Developer Guide(Create Shapes) - JFImagine.com

[Prior]   [Top]   [Next]

8. Create Shapes Programmatically


        Create Shapes by codes.

    Sometimes you may want to generate shapes by codes only, then let your clients to modify/output those shapes in their ways. In those cases, you can try to use our latest class constructors to create shapes dynamically.

        Sample codes of shape creating.

.......

//get current layer
JFLayer layer =page.getCurrentLayer();
//get the shape list of current layer
ObjectList list =layer.getShapeList();

//create a polygon
int xpoints[] =new int[]{50,150,250,250,50};
int ypoints[] =new int[]{50,100,50,250,250};
list.add(new JFPolygon(xpoints,ypoints,5));

//create a horizontal label line.
list.add(new JFVHLabelLine(50,35,250,35,JFVHLabelLine.LINETYPE_HORIZONTAL));

//create a vertical label line.
list.add(new JFVHLabelLine(265,50,265,250,JFVHLabelLine.LINETYPE_VERTICAL));

//create an ellise
list.add(new JFEllipse(50,100,200,150));

//create an diamond
list.add(new JFDiamond(50,100,200,150));

//create an arc
list.add(new JFArc(100,212.5,200,212.5));

.......

 

         Screenshot of this sample..

   

 

 

        To get full source code of this sample.

    You can download the full sample source code package here. Then open the file at sample6/Sample6.java for detail informations.

[Prior]   [Top]   [Next]