Drawing like ball shapes

hi all,
it is possible to draw Like ball shapes using java2D(it looks like ball)?plz help me.
thanks in advance
bye
kishore naidu

(it looks like ball)?for a flat circle you can usepublic void paintComponent(Graphics g) {
   g.setColor(Color.red);
   g.fillOval(x,y,r,r);
}is this what you mean?
asjf

Similar Messages

  • Draw a smooth shape out of point array where points are in arbitrary order

    hi folks,
    I got a little problem I just can't get figured out:
    - there's an array of points (x,y)
    - the points inside this array are arbitrary
    - now I need to find out which points define the outermost shape
    - all other points that are inside this outermost shape may not be used
    - and finally the shape should be smooth...
    a picture of what I mean is to see here:
    http://www.student-zw.fh-kl.de/~chgr0001/tmp/shape.htm
    I wonder if there's a method in Java2D to do this?!
    thanks for your help!

    well,
    it's about a class that draws an area based on coordinates out of a database.
    These coordinates are originally from a GPS device and hold information about public WLANs. If someone walked around with his GPS and found WLAN data, this data together with the according GPS coordinates is stored in certain fractions of time.
    Now my problem is that I want to present the areas, where you can get a WLAN link, on a map. To do so, I want to draw the outermost shape of a "walkaround with my GPS" session and colorize it with the average link quality.
    Furthermore I like to have that shape smooth.
    I would appreciate any hints on how to proceed and which methods of which classes are useful to do so.

  • Trying to draw a diamond shape from a shape - Please help !!!

    Hi,
    I am trying to draw a diamond shape from a custom shapes library but having a hard time getting it to shape accurately, the shape I am trying to draw should look like this :
    If someone can teach me some photoshop techniques as to how to get all the angles reshaped accurately using some photoshop tools that will be great or if you can do it in my project file that will help too, the project psd file can be downloaded from here : http://tonyalepski.heliohost.org/Diamond.psd
    Your help would be really really appreciated.
    Thank you very much !!
    Tonya.

    Your diamond looked like it was square to me. So I centered your diamond over your canvas add a vertical  guide at 50%. Measured your square to be 190 PX  Dragged out a 190 PX square shape no fill 1 px red stroke.  Transformed the shape rotating it 45 degrees and moved it up to align with your diamond.   Dragged out a horizontal guide to match your diamond cut. Used the Pen tool to add two control points the square shape. and then use the pen tool to delete the top control point then convert control point tool to convert the two added control points.
    http://www.mouseprints.net/old/dpr/Diamond.psd

  • Drawing different geometric shapes in flex

    Hi
    Can I know how to draw different geometric shapes(like square, polygon,rhombus) in flex and I should be able to calculate its x,y co-ordinates...
    Let me know if any examples are there...
    Thanks n Regards
    Aruna.S.N.

    Rob
    1. The Shapes menu is on the toolbar.
    Pull down the menu and choose the pentagon shape. That has a sliding controller that lets you choose the number of sides.
    2. 30°? which is +option shift 8+
    Peter

  • How can I create a drawing like the one pictured from a photo?

    How can I create a drawing like the one pictured from a photo?

    OK, you are getting closer. Now, use your result, and place a Layer above that. Use the Pen Tool to create the "pen strokes" basically tracing over your background image. Then, when you have created each Path (or Sub-Path), choose Stroke Path, with probably the Pencil Tool and a Brush size that is small enough.
    Not sure which versions of PS these are good for, but here are some plug-ins, that might be helpful.
    AKVIS Sketch
    EdgeLine
    Sketch Effects
    Sketch Master
    I see that one of my old favorites, Flaming Pear's India Ink is not around any more.
    Good luck,
    Hunt

  • Using pen tool to draw a particular shape...

    Hi all,
    I'm pretty new to Illustrator and just wanted some advice.
    I'm using the pen tool to try and draw a specific shape () but finding it hard trying to 'smooth' out the points where I connect my lines.
    The pen tool can't draw this all in one go, so when I try to do it in several stages, the lines don't connect up smoothly so it looks a bit... rubbish.
    Anyone got any tips or how to do this simply? Sorry if this is a total idiotic question but, I'm trying...!
    Cheers

    Somehow your picture won't show.

  • Drawing Custom Curves, Shapes, S Shapes, etc.?

    How do I draw symmetric curves, custom shapes, S shapes, etc?
    I am a beginner, and I have PSE 6.  I can upgrade to version 8 or use plugins if necessary.  I’ve been googling this, but is the pencil the same as the pen?  Where are the Paths options?
    -->  My question is I am wanting to create custom shapes.  For example, a half circle curve, or an S shape.  How do I do that? I’d rather not use the Marquee tool. 
    Attached is an example of a curve that I want to reproduce.
              Thanks for any help.

    multiplexed2 wrote:
    How do I draw symmetric curves, custom shapes, S shapes, etc?
    I am a beginner, and I have PSE 6.  I can upgrade to version 8 or use plugins if necessary.  I’ve been googling this, but is the pencil the same as the pen?  Where are the Paths options?
    -->  My question is I am wanting to create custom shapes.  For example, a half circle curve, or an S shape.  How do I do that? I’d rather not use the Marquee tool. 
    Attached is an example of a curve that I want to reproduce.
              Thanks for any help.
    No, the pen tool is only in Photoshop. The best you can do in Elements is download shapes that have been made in Photoshop or draw out a shape and either add or subtract from the shape. You don't have a paths palette either although they exist just not accessible as in Photoshop.  You'd have to save the shape file for reuse as you can't define custom shapes in Elements.
    Type  custom shapes Photoshop and you will probably find the shape you need in one of the many freeware sets out there. They'll say for Photoshop but you can install and use them in Elements.
    For the shape of the .bmp file you posted, you can cut a rectangle shape with a circle.
    1. Draw out a rectangle with the rectangle shape tool.
    2. Press the subtract icon in the options bar.
    3. Draw out a circle to remove the unwanted area.
    4. Save the file as a PSD with a name you can remember so you can use it whenever needed.
    Note: The shape will be still be vector provided you saved as a PSD so it can be resized without degrading it.
    If you hover over the icons, tool tips will display telling what each one does. Here's an image of the icons you're looking for in the options bar in step #2.
    Example of shape cutting...path lines are present because I haven't clicked away from the layer before taking the screen shot but useful as it shows how I cut the shape. To get the curve centered, it would be helpful to add some grids. I didn't use them in the image below and you can see I'm a little off center.

  • Draw a strokeless shape with pen tool?

    Is it possible to draw a strokeless shape with the pen tool (as in Illustrator)?
    It is quite tedious to have to go back and remove strokes from my shapes.... especially since I can't see how to do it without clicking on each segment and hitting "delete"!
    Thanks!

    Select the entire shape with the strokes and go to the Properties Inspector or Tools Panel and select no stroke.
    Hope this helps!
    Quynh
    Flash Pro QA

  • How to draw draggable dimaont shape

    Hello all as part of a flowchart editor program i wand to be able to draw a diamont shape to the screen i have done that with code i found on line this is the code:
    GeneralPath shape = new GeneralPath(GeneralPath.WIND_EVEN_ODD);
                shape.moveTo(pref.width / 2, 0);
                shape.lineTo(pref.width, pref.height / 2);
                shape.lineTo(pref.width / 2, pref.height);
                shape.lineTo(0, pref.height / 2);
                shape.lineTo(pref.width / 2, 0);
                RomvusHolder.addElement(shape);
                g2.draw(shape);the problem is that i want to draw the shape at the position the user presses the mouse and not at the upper left corner (as it does know), also i want to be able to fill the shape with color and to be able to drag it with the mouse. Any suggestion? thanks in advanced maxsap

    You can get the mouse poition with MouseInfo.

  • Draw line and shapes

    I have a small problem...cos i have like one class that extends JFrame but i have one JPanel on which i would like to draw some shapes...but i dont know how...cos i tried to rewrite paint method but it does not work...if someone would please post me a simple example...on how to do that...thnx

    This is slightly barebones, but it should do. It also has some less relevant code. Here's my JFrame (or the interesting parts):
    public class MainWindow
         extends JFrame
         private PaintLayout layout;//My custom Layout, not required
         private Container c;
         public MainWindow()
              //Bind the layout and Container c for future use
         layout = new PaintLayout();
         c = getContentPane();
         c.setLayout(layout);
    //These are useful if you want to know what space is getting chopped out
         it = c.getInsets().top;
         ib = c.getInsets().bottom;
              il = c.getInsets().left;
              ir = c.getInsets().right;
         GameBoard board = new GameBoard();
    layout.addLayoutComponent(board, 0+il, 0+it, 720, 480);//Custom add function for my custom Layout
    c.add(board);//Very useful and important
    Followed by the code of interest in my JPanel:
    public class GameBoard
         extends JPanel
         implements MouseListener, MouseMotionListener
         public GameBoard()
              this.addMouseListener(this);
              this.addMouseMotionListener(this);
         public void paint(Graphics g)
    g.setColor(new Color(0, 127, 0));
    g.fillRect(0,0,this.getWidth(),this.getHeight());
         public void mouseClicked(MouseEvent arg0)
              int x = arg0.getX(), y = arg0.getY();
              System.out.print("X: "+x+" Y: "+y+"; X: "+x/10/12+"'"+(x/10)%12+"\" Y: "+y/10/12+"'"+(y/10)%12+"\";\n");
    Have fun with that.

  • Trying to draw a 2D shape, but Graphics2D is null, what am I doing wrong?

    At this point, I just want a shape to appear. But when I call draw(...), I get a NullPointer. Turns out when I call getGraphics() on the input JFrame (which does show up properly when the rest is commented out), I get nothing. Maybe it's the casting, I don't know enough about this issue to really say. If anyone out there has worked with 2D primitives and can shed some light on the problem, I would appreciate it.
    Thanks for any help.
    public class BatteryDisplay extends JPanel {
         Graphics2D g2d;
         Rectangle2D.Double rect1;
         JFrame jf;
         public BatteryDisplay(JFrame jf)
              this.jf = jf;
                    // Is there another way to get the graphics object?
              g2d = (Graphics2D) jf.getGraphics();
              createRectangle();
              drawRectangle();
         public void createRectangle()
              rect1 = new Rectangle2D.Double(100,100,200,50);
              System.out.println(rect1.height);
                    // The next line returns the NullPointer, so g2d is NOT initalized
              System.out.println(g2d);
         public void drawRectangle()
              this.g2d.draw(rect1);
    }

    Your painting functions should be initiated from an overridden paintComponent, not from the constructor. A graphics object will be provided to you there.
    [http://java.sun.com/docs/books/tutorial/uiswing/painting/index.html]

  • It seems a bug of as3 when using BitmapData.draw for a shape which is masked with another shape

    This is the code of my document class:
    public class FirstMask extends Sprite
      private var maskedShape:Shape;
      public function FirstMask() {
       init();
      private function init():void {
       maskedShape = new Shape();
       addChild(maskedShape);
       maskedShape.graphics.beginFill(0xff0000);
       maskedShape.graphics.drawRect(0,0,80,80);
       maskedShape.graphics.endFill();
       var maskShape:Sprite=new Sprite();
       maskShape.graphics.beginFill(0x000000);
       maskShape.graphics.drawRect(0, 0, 20,20);
       maskShape.graphics.endFill();
       maskedShape.mask=maskShape;
       var bmd:BitmapData=new BitmapData(80,80);
       bmd.draw(maskedShape);
    When I do not use the bmd to draw the maskedShape,everything is ok.When I do that,it seems the maskShape is auto-transformed including its position and size.As a result,I can not see the maskedShape unless I adjusted the IE size.Can anybody tell me why?
    ps:If I set this.stage.align=StageAlign.TOP_LEFT; I can see the small scaled maskedShape.If I add the maskedShape to the displaylist ,everythis is ok.But Why drawing has the effect on the drawn shape?

    Thanks again.But the "draw" itself is all right.
    After " bmd.draw(maskedShape);",I code:
       var bm:Bitmap=new Bitmap(bmd);
       bm.x=100;
       bm.y=0;
       addChild(bm);
    The bm can be shown.
    So to make it clear,I print the screen:
    1.No"mask" No "draw" at all.
    2."mask" without "draw"
    3."mask"and then "draw"---the IE shows nothing
    4.If I drag the IE,adjust its size,then I can see a little thing on the top-left.
    confusing...
    PS:If I run the code as "air application",it seems all right.

  • When drawing with the shape tool in Flash how can I vary the stroke width?

    I created an oval shape and I'd like to vary the stroke width so it's not all just one uniform thickness. However in the Properties window I can only find the uniform stroke width and style options (solid, dotted, hashed, etc...). How can I add some tapering?
    Thank you for your help.
    Sarah

    You probably need to convert the line to a fill and then change the shape of it. .. Modify -> Shape -> Convert Lines to Fills

  • Drawing the same shape different times.

    Hey, I'm trying to paint a mini map to the screen
    using following code:
      protected void paintComponent(Graphics g) {
        super.paintComponent(g);   
        Graphics2D g2 = (Graphics2D) g;
        int row = 0, col = 0;
        for (Tile t : map.getAllTiles()) {
          if(col == map.getCols()) {
            col=0;
            row +=1;
          g2.translate(col * boxSize, row * boxSize);
          paintTerrain(g2, t.getTerrain());
          paintBuilding(g2, t.getBuilding());
          //paintUnit(g2, (Unit) t.getLocatable());
          col++;
      private void paintTerrain(Graphics2D g, Terrain terrain) {
        if (terrain == null) {
          g.setColor(Color.BLACK);
          g.fill(terrainShape);
          return;
        Color c = terrainColors.get(terrain);
        g.setColor(c);
        //g.fillRect(x, y, boxSize, boxSize);
        g.fill(terrainShape);
      }This paints to the screen but not the way i intended.
    a picture of how it looks:
    http://www.kwbbz.be/Downloads/miniMapBad.png
    If I change it to g.fillRect(x, y, boxSize, boxSize);
    then the map shows up the way i had in my mind.
    Like this:
    http://www.kwbbz.be/Downloads/miniMapLookingGood.png
    Changes in paintComponent:
          //g2.translate(col * boxSize, row * boxSize);
          paintTerrain(g2, t.getTerrain(),col * boxSize,row * boxSize);
      private void paintTerrain(Graphics2D g, Terrain terrain, int x, int y) {
        if (terrain == null) {
          g.setColor(Color.BLACK);
         // g.fill(terrainShape);
          return;
        Color c = terrainColors.get(terrain);
        g.setColor(c);
        g.fillRect(x, y, boxSize, boxSize);
        //g.fill(terrainShape);
      }What's wrong with g2.translate(col * boxSize, row * boxSize); doesn't it move the axis to the right and down?
    added pictures
    tried inserting links to images... failed

    import java.awt.*;
    import java.awt.geom.AffineTransform;
    import javax.swing.*;
    public class TranslateTest extends JPanel {
        Rectangle rect = new Rectangle(50, 50);
        int rows = 4;
        int cols = 3;
        protected void paintComponent(Graphics g) {
            super.paintComponent(g);
            Graphics2D g2 = (Graphics2D)g;
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                                RenderingHints.VALUE_ANTIALIAS_ON);
            int w = getWidth();
            int h = getHeight();
            int dx = (w - cols*rect.width )/(cols+1);
            int dy = (h - rows*rect.height)/(rows+1);
            // Undo each translation before applying the next.
            g2.setPaint(Color.red);
            int x = dx;
            for(int j = 0; j < rows; j++) {
                int y = dy + j*(rect.height + dy);
                g2.translate(x, y);
                g2.draw(rect);
                g2.translate(-x, -y);
            // Use a copy of the graphics context for translation.
            g2.setPaint(Color.green.darker());
            Graphics2D copy = (Graphics2D)g.create();
            x = rect.width + 2*dx;
            int y = dy;
            copy.translate(x, y);
            for(int j = 0; j < rows; j++) {
                copy.draw(rect);
                y = rect.height + dy;
                copy.translate(0, y);
            copy.dispose();
            // Use AffineTransform for the translation.
            // This avoids altering the graphics context.
            g2.setPaint(Color.blue);
            x = dx + 2*(rect.width + dx);
            for(int j = 0; j < rows; j++) {
                y = dy + j*(rect.height + dy);
                AffineTransform at =
                    AffineTransform.getTranslateInstance(x, y);
                g2.draw(at.createTransformedShape(rect));
        public static void main(String[] args) {
            JPanel panel = new TranslateTest();
            panel.setPreferredSize(new Dimension(400,400));
            JOptionPane.showMessageDialog(null, panel, "", -1);
    }

  • Drawing thousands of shapes performance

    Hi
    I'm developing an applet which opens a JFrame to show a map made of thousands of shapes (rectangles and arcs).
    I need to scroll and zoom that map and because of this I need to redraw it every time the user do something.
    I tried different kind of optimization but the paint process remains very slow.
    At the moment I'm drawing inside the paint method of my JViewport subclass and cycling through a Vector containing my shapes.
    What can I do to speed it up?

    Try setting rendering hints as follows:
    KEY_ALPHA_INTERPOLATION=VALUE_ALPHA_INTERPOLATION_SPEED
    KEY_ANTIALIASING=VALUE_ANTIALIAS_OFF
    KEY_TEXT_ANTIALIASING=VALUE_TEXT_ANTIALIAS_OFF
    KEY_COLOR_RENDERING=VALUE_COLOR_RENDER_SPEED
    KEY_RENDERING=VALUE_RENDER_SPEED
    This can be done by calling
    ((Graphics2D) g).setRenderingHint( hintKey, hintValue )
    inside your paint method.
    I've been working on a similar problem and setting the Antialiasing rendering hint to off noticably sped things up.
    Unfortunately I've run into issues with it (see http://forum.java.sun.com/thread.jspa?threadID=5256286&tstart=0)
    -Ben

Maybe you are looking for