Drawing arcs and lines

Hi! I am having problem in drawing arc and line. We have function
Graphics.drawArc(int x, int y, int startAngle, int endAngle)
I need to get the last point where the arc ends. Because I want to draw a line touching the last point of this arc. I request you to provide me some solution.
BR
Omer Amin

Graphics.drawArc requires 6 parameters (not 4). Pass all 6 parameters to the Arc2D.Double() constructor and call it's getEndPoint() method.

Similar Messages

  • How do I join together arcs and lines in a single Shape???

    I am out of my depth, I am probably missing something spectacular .... I need to construct a shape from arcs and lines to get something like this, only closed:
    Like a winding river sort of thing... I do not need to draw this I need to have this shape and its area available to me.... How do I join these two arcs and two lines into a shape from which I can find - area.contains(xy.getX(), xy.getY()); , preatty please?
    here is the code that causes numerous errors:
    import java.awt.*;
    import java.awt.Graphics.*;
    import java.awt.Graphics2D.*;
    import java.awt.geom.RectangularShape.*;
    import java.awt.geom.Arc2D;
    import java.awt.geom.Line2D;
    import java.awt.geom.Rectangle2D;
    import java.awt.geom.Area;
    import java.awt.geom.GeneralPath;
    class MyShapes //extends Arc2D
    public static Arc2D outerOne;
    public static Arc2D innerOne;
    public static Line2D upLine, bottomLine;
    public static Area area = new Area();
    public MyShapes(double[] upper, double [] lower)
    outerOne.setArc(upper[0], upper[1], upper[2], upper[3], upper[4], upper[5], (int)upper[6]);
    //                         x,          y,               w,          h,               OA,      AA, int OPEN =1
    innerOne.setArc(lower[0], lower[1], lower[2], lower[3], lower[4], lower[5], (int)lower[6]);
    //outerTR=this.makeClosedShape(outerTopRightArc,middleTopRightArc);
    upLine     = new Line2D.Double(outerOne.getX(),outerOne.getY(),innerOne.getX(),innerOne.getY());
    bottomLine = new Line2D.Double(outerOne.getX()+outerOne.getWidth(),outerOne.getY()+outerOne.getHeight(),innerOne.getX()+innerOne.getWidth(),innerOne.getY()+innerOne.getHeight());
    area = this.joinAll(outerOne,innerOne, upLine, bottomLine);     
    private Area joinAll(Arc2D out, Arc2D in, Line2D one, Line2D two)
    GeneralPath joiner = new GeneralPath(out);
    joiner.append(in, true);
    joiner.append(one, true);
    joiner.append(two, true);      
    Area temp = new Area(joiner);
    return temp;     
    public boolean isInArea(Point xy)
    return area.contains(xy.getX(), xy.getY());     
    public boolean isItClosed()
    return area.isSingular();     
    Thanks

    Glad to hear you find what was wrong. Still, it doesn't the main problem : why is that method crashing?
    Here is what I've done in the mean time. See if it fits your purpose.import javax.swing.*;
    import java.awt.*;
    import java.awt.event.WindowAdapter;
    import java.awt.event.WindowEvent;
    import java.awt.geom.*;
    public class MyShapes {
         private Arc2D outerOne;
         private Arc2D innerOne;
         private Shape line1;
         private Shape line2;
         public MyShapes(double[] upper, double[] lower) {
              outerOne = new Arc2D.Double(upper[0],
                                                 upper[1],
                                                 upper[2],
                                                 upper[3],
                                                 upper[4],
                                                 upper[5],
                                                 0);
              innerOne = new Arc2D.Double(lower[0],
                                                 lower[1],
                                                 lower[2],
                                                 lower[3],
                                                 lower[4],
                                                 lower[5],
                                                 0);
              line1 = new Line2D.Double(outerOne.getStartPoint().getX(),
                                              outerOne.getStartPoint().getY(),
                                              innerOne.getStartPoint().getX(),
                                              innerOne.getStartPoint().getY());
              line2 = new Line2D.Double(outerOne.getEndPoint().getX(),
                                              outerOne.getEndPoint().getY(),
                                              innerOne.getEndPoint().getX(),
                                              innerOne.getEndPoint().getY());
         public void paint(Graphics2D aGraphics2D) {
              aGraphics2D.draw(outerOne);
              aGraphics2D.draw(innerOne);
              aGraphics2D.draw(line1);
              aGraphics2D.draw(line2);
         public static void main(String[] args) {
              double [] XO= {56, 58, 400, 280, 90, 90};// outter arc
              double [] XI={114, 105, 300, 200, 90, 90}; // inner arc
              final MyShapes myShapes = new MyShapes(XO, XI);
              JPanel panel = new JPanel() {
                   protected void paintComponent(Graphics g) {
                        super.paintComponent(g);
                        Graphics2D g2 = (Graphics2D)g;
                        myShapes.paint(g2);
              final JFrame frame = new JFrame("Test shape");
              frame.addWindowListener(new WindowAdapter() {
                   public void windowClosing(WindowEvent e) {
                        System.exit(0);
              frame.setContentPane(panel);
              SwingUtilities.invokeLater(new Runnable() {
                   public void run() {
                        frame.show();
    }

  • Can 3D picture control be used to draw point and line as 2D picture control?

    I want to draw a 3D mesh using point coordination. I don't want to use Create Mesh.vi, because it is not allowed to edit line style.

    The 3d graph will let you do that. See this thread for an example that did this.
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • Looking for some good Arc and Circle drawing pdf code.

    Hi I am looking for some suggestions on how to draw circles and arcs using PDF. My arcs have recently started to be drawn as chords in Adobe Reader 9.1.1. I am looking for example code o this nature (I know this is not circle or arc code this is just an example):
    b
    0 0 0 RG 0 0 0 rg
    1 w 98 -156 m 104 -154 l 104 -158 l 0 0 0 RG 0 0 0 rg
    b
    0 0 0 RG 0 0 0 rg
    1 w 398 -156 m 392 -154 l 392 -158 l 0 0 0 RG 0 0 0 rg
    b
    0 0 0 RG 0 0 0 rg
    1 w 98 -156 m 396 -156 l S
    BT /F1 10 Tf 243 -151 Td (1.5") Tj ET
    1 w 398 -196 m 392 -194 l 392 -198 l 0 0 0 RG 0 0 0 rg
    b
    i.e. actual PDF tokens.
    If you know of a website that feature such examples I would appreciate the URL too.
    Thanks

    Jem,
    Pardon me if I sound rude by suggesting that before you launch into an expensive printing job (which could result in disastrous consequences if you don't do it right) that you actually learn how to use the program first. You may also want to learn something about the offset printing process and how to prepare print jobs.
    Even many Illustrator novices know that there is no such thing as a background in Illustrator, in the sense that there is in Photoshop. You will need to PLACE your Photoshop background as a high resolution CMYK tiff in the provided template. That's the answer to your second question. I don't really understand your first question. Maybe someone else will. Are you simply asking, "where do I begin?" If so, then you REALLY REALLY need to read a book on how to use Illustrator. The Adobe Illustrator Classroom in a Book might be the place to start.
    "I'm pretty good with CPR. I'm helping a friend do his vasectomy and I already have all the equipment (scalpels, thread, etc.) I'm just having trouble figuring out where to cut."

  • Drag and Drop inside JTable: what draws the 'insert' line during the drag?

    I'm trying to reconfigure a rather complex table with a fair number of custom renderers to include drag & drop of rows for resorting the table. Everything is working great, except that as I drag the rows there is no indication of the current insert point (i.e. the line that appears between rows). When I make a simpler table I see the line... I'm not sure what aspect of my current table is blocking this function. I'm writing in the hope that can someone can direct me to the method(s) responsible for drawing this line.
    Thanks!

    To elaborate a bit for anyone who might read this. I inquired with the Substance developers and they hope to support this feature in v5.1 (which requires SE6), but have no plans to update v4.3 (the last release before a switch to SE6).
    Also, I'd still be grateful for any info pointing me to the Swing methods that draw the drag line.

  • How to draw a graph of tree structure (using shapes and lines)?

    Hello,
    I tried to search this solution in the forum, and I see people asking and replying with solutions to similar situation, but I don't get what I am looking for. Also because I have never tried with graphs before.
    So, my problem is, I need a function that takes a string with tree structure, as in automata or tree graph, and displays the nodes in tree form. "Tree" is not important, but important is that each object should be displayed as a node and lines connecting them. Please see the image below (with three possible options):
    So, basically, the tree structure could be like X(a, X(a,b), c) where X(a,b) is a sub-tree of higher level X. The program knows the parent-child relationship, so this function only needs to display those elements in a graphical fashion.
    I pass the string in the form of a 2D array showing the hierarchy (to simplify).
    In the image, I am showing three possible options for showing the tree. The third option eliminates those circles and rectangles, if that simplifies.
    I hope I explained clearly.
    Thanks ahead!
    Vaibhav

    I would start drawing from the top. The nodes will be the easy part.
    Begin with the root node centered in the drawing area horizontally and against the top of the drawing area. The second row of nodes would be located vertically (as in my example) 1.5x pixels below the first one, and either distributed horizontally across the available drawing area or at a fixed distance - like 1.5x again, or someother distance you define.
    The tricky part will be drawing the lines since they need run between the edges of nodes. This is where the high-school geometry might come in.
    Keep us posted on what you come up with. Extra points for coming up with a solution that will automatically resize itself to fit the available drawing area! (I've already given you all the clues for how to do that too.)
    Mike...
    Certified Professional Instructor
    Certified LabVIEW Architect
    LabVIEW Champion
    "... after all, He's not a tame lion..."
    Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps

  • Drawing a curved line using the pen tool, dragging the text cursor over the line but will only give me a small area to write in, in-between a circle and a circle with a cross in?

    Drawing a curved line using the pen tool, dragging the text cursor over the line but will only give me a small area to write in, in-between a circle and a circle with a cross in?

    If you change your tool to the "Direct Selection Tool" (A) then you should be able to adjust the area for you to type in...

  • Can a Lightroom adjustment brush draw a straight line by clicking the start and stop points?

    Can a Lightroom adjustment brush draw a straight line by clicking the start and stop points?

    studioMac wrote:
    I'm trying to selectively adust areas of an image in Lighroom. eg: a window frame in an architectural photo, and so being able to make straight lines with the adjustment brush would be very useful.
    I agree it would be useful. It's something that's been asked for. The best thing is to keep requesting at the Lightroom feature request forum

  • How to draw vertical and horizontal lines on chart as shown in image below%3F

    Hi,
    Is it possible to draw a horizontal line (63% as shown in image or 15.75 and vertical line at intersection to X axis) in chart.
    please suggest code
    Regards
    mms79

    Have you tried using cursors?  Right click on the chart and show the cursor legend.  Then right click the legend and add a cursor. 

  • Real circles, arcs and bigger art board

    1.) I work with large format graphics and CS3 AI's limitation of around 120" x 120" makes my work difficult. Other graphic applications that are much less mature than AI have almost infinite art boards to work with. I would also be nice to be able to work in scales, too. It is laborious to have to constantly be working at half-, quarter-, or eighth-scale. I wear out a calculator and the possibility for errors shoots through the roof. Lastly, some things just don't scale well. In short, AI is biased toward those whose output is magazine sized. Since it is essentially the only graphics application left standing it should realize that many of its customers need to work is something larger than ledger. At the very least they should have the same limitation for both ID and AI. At present an 120" AI file cannot be placed in ID which has a limit of around 111". Some "suite."
    2.) Make text compatible between AI and ID. As I recall, at present (CS3) the text from one does not conserve its formatting when placed into another. I'd like to have the option.I have to use MSWord as a go-between. Again, some "suite."
    3.) If AI is going to be a complete vector art application perhaps it should start with the ability to draw simple shapes. At present, it can only draw X,Y defined vector paths. The "circle" tool only draws circle-shaped paths. Its size is controlled by changing the X and Y dimensions of an imaginary square into which it is inscribed. A true circle is drawn and manipulated via its center placement, its radius and its diameter---at a minimum! In AI none of these controls are available. Remember compasses from the old drawing board days? At the very least AI should emulate this ancient tool. I don't remember anyone ever trying to draw a circle by drawing a square first and trying to place four arcs in the corners. It is crazy.
    The same is true for arcs. AI only draws crude arc-like paths. In fact, it is even less accurate for arcs than it is for circles. Going back to simple definitions, an arc is a series of points equidistant from a single point. AI's "arc" tool does not draw anything close to this unless you hold down the shift key. Then it draws the arc from one of the end points. This may be helpful sometimes, but 99 percent of the time if you want to draw an arc you are going to want to start at the center and draw from end point to end point. AI acts as if the center does not exist! It is not even indicated; these are not arcs! Lastly, much like a true circle, an arc is manipulated by its center point placement, its radius and its included angle, and/or the location of its end points. None of these are available in CS3. As I said, it only draws X,Y vector paths--very, very primitive.
    The ability to draw fundamental shapes correctly and easily should be the first thing a vector illustration program tackles. It is absurd that it is still missing after 13 versions. Let's hope version 14 finally gets it right. And please don't mention CAD tools. The tools I'm taking about are basic, basic, basic tools.
    MGuilfoile

    I absolutely agree.
    I don't ever recall using a program that created arcs and circles like AI. A circle appears simply to be 4 arcs of 90 degrees. You cannot change the start and end angles, either by dragging the points or by dialog input. I'm not an illustrator by training - I'm a technical writer but I've been doing line illustrations, exploded views, etc. for almost 20 years using various vector-graphics programs. Every program I've used allows you to alter an arc, elipse or both, NOT just size and move!!
    I'm only evaluating AiCS4 for possibly migrating from FreeHand. In Freehand, you cannot change the angle of an arc but you can with elipse. Even the limited graphics package in FrameMaker allows you to define the start/end angles of an arc (not an elipse) via the properties dialog.
    I'm new to AI and I'm just astonished that the arc and elipse tools have been so neglected over the long life-cycle of the program.

  • New To Illustrator CS4  - How do you select the Arc Tool to Draw Arcs?

    PDF on Illustrator doesn't indicate how to select the Arc tool. Extract from toe pdf follows:
    Draw arcs
    1 Select the Arc tool .  (HELP -- I CAN'T LOCATE THE ARC TOOL).
    2 Do one of the following:
    • Position the pointer where you want the arc to begin, and drag to where you want the arc to end.
    • Click where you want the arc to begin. In the dialog box, click a square on the reference point locator to determine the point from which the arc is drawn. Then set any of the following options, and click OK.
    Length X-Axis
    Specifies the width of the arc.
    Length Y-Axis
    Specifies the height of the arc.
    Type
    Specifies whether you want the object to be an open path or a closed path.
    Base Along
    Specifies the direction of the arc. Choose X Axis or Y Axis depending on whether you want to draw the base of the arc along the horizontal (x) axis or vertical (y) axis.
    Slope
    Specifies the direction of the arc’s slope. Enter a negative value for a concave (inward) slope. Enter a positive value for a convex (outward) slope. A slope of 0 creates a straight line.
    Fill Arc
    Fills the arc with the current fill color.
    Note: To see a dynamic preview of the arc as you set options, double-click the arc tool in the Tools panel.

    You're welcome.
    Can i suggest that you explore al the tools there are drop down menus and on the panels as well in the upper right hand corner there is a drop down with useful functions and options. Also look at the control panel under the menu bar as you change tools to see the option each tool has and also some tools have further settings if you double click the icon in the tool bar other have option if you click in the document window once you have selected them.
    But the best advice I can give you is to buy Mordy Goldings book Real World Illustrator CS 4 he also has one for  the suites, it is a worthwhile investment.

  • When did Draw Arc .vi Change Format?

    In LabView 6.1, Draw Arc .vi had different wiring than in LabView 2010.  I ran into a problem with a VI that I was using as a small subVi that is part of a much bigger Vi and now won't work because the Draw Arc.vi has incorrect wiring.  The only difference I can see is that what is now a connection for "PEN" (cluster wire) was a connection for "black in B/W" (boolean wire).  Basically I had a green circle that slowly turned to black as seconds ticked down.  I have tried using the "PEN" control, entering "0" as pen color and line as "solid" but still does not work as before.  Any help would be much appreciated.  Thank You, Scott

    swins,
    hmm, sounds to me like it might not be the draw arc control. Are you sure that's the only one that could have broken in the upgrade? I dropped a simple little visual counter (just tied the arc size to the index of a for loop) into a sub vi as a test, and everything is working just fine for me. I'm interested to find out what's going on with your control that I can't replicate the issue. Maybe it's something specific with the color changing? 
    Cheers!
    TJ G

  • How to draw only straight line instead of angled one??

    Dear friends,
    I saw a very good code posted by guru here(I think is camickr),
    But I tried to change it and I hope to draw only straight line instead of angled one, can you help how to do it??
    Thanks so much.
    import java.util.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    public class DrawingArea extends JPanel
         Vector angledLines;
         Point startPoint = null;
         Point endPoint = null;
         Graphics g;
         public DrawingArea()
              angledLines = new Vector();
              setPreferredSize(new Dimension(500,500));
              MyMouseListener ml = new MyMouseListener();
              addMouseListener(ml);
              addMouseMotionListener(ml);
              setBackground(Color.white);
         public void paintComponent(Graphics g)
              // automatically called when repaint
              super.paintComponent(g);
              g.setColor(Color.black);
              AngledLine line;
              if (startPoint != null && endPoint != null)
                   // draw the current dragged line
                   g.drawLine(startPoint.x, startPoint.y, endPoint.x,endPoint.y);
              for (Enumeration e = angledLines.elements(); e.hasMoreElements();)
                   // draw all the angled lines
                   line = (AngledLine)e.nextElement();
                   g.drawPolyline(line.xPoints, line.yPoints, line.n);
         class MyMouseListener extends MouseInputAdapter
              public void mousePressed(MouseEvent e)
                   if (SwingUtilities.isLeftMouseButton(e))
                        startPoint = e.getPoint();
              public void mouseReleased(MouseEvent e)
                   if (SwingUtilities.isLeftMouseButton(e))
                        if (startPoint != null)
                             AngledLine line = new AngledLine(startPoint, e.getPoint(), true);
                             angledLines.add(line);
                             startPoint = null;
                             repaint();
              public void mouseDragged(MouseEvent e)
                   if (SwingUtilities.isLeftMouseButton(e))
                        if (startPoint != null)
                             endPoint = e.getPoint();
                             repaint();
              public void mouseClicked( MouseEvent e )
                   if (g == null)
                        g = getGraphics();
                   g.drawRect(10,10,20,20);
         class AngledLine
              // inner class for angled lines
              public int[] xPoints, yPoints;
              public int n = 3;
              public AngledLine(Point startPoint, Point endPoint, boolean left)
                   xPoints = new int[n];
                   yPoints = new int[n];
                   xPoints[0] = startPoint.x;
                   xPoints[2] = endPoint.x;
                   yPoints[0] = startPoint.y;
                   yPoints[2] = endPoint.y;
                   if (left)
                        xPoints[1] = startPoint.x;
                        yPoints[1] = endPoint.y;
                   else
                        xPoints[1] = endPoint.x;
                        yPoints[1] = startPoint.y;
         public static void main(String[] args)
              JFrame frame = new JFrame("Test angled lines");
              frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
              DrawingArea d = new DrawingArea();
              frame.getContentPane().add( d );
              frame.pack();
              frame.setVisible(true);
    }

    Change the AngledLine class to store two points instead of 3 points (I would rename the class to be StraightLine). The code is much simpler because you just store the starting and ending points and you don't need to calculate the middle point.

  • Can only draw circle and square in Illustrator CS5 and Photoshop CS5

    I am experiencing a strange bug that seems to be affecting both Photoshop CS5 and Illustrator CS5. In Illustrator, when I try to draw a rectangle or ellipse I can only draw circles and squares. Also I can't change the color of selected objects. When I try to change its fill nothing happens. I can also only drag objects on the 0, 45 and 90 degree angles. Also I can no longer select off an object by clicking on the artboard. When I click on the artboard nothing happens.
    Similarly in Photoshop I can only draw straight lines using the brush tool. The  marquee tool is also not functioning properly. When I try to use the marquee tool the marching ants form a square but when I release the mouse it selects a rectangular portion. Strangely if I use the marquee tool and make selection I can press the shift key and add to it but this second selection's marching ants are not square but are properly rectangular.
    Since the problem seems to be affecting both Illustrator and Photoshop I'm thinking it's probably some kind of system conflict or perhaps an application running in the background is affecting it. Also if I restart my mac the problem goes away. Unfortunately the problem eventually returns.
    Anyway I'm pretty sure most of the suggested fixes involve systematically going through all the programs running in the background and trying to determine which if any might be affecting Illustrator and Photoshop but I just thought I'd post something in case someone else had the problem or knew of any fixes.
    I'm running CS5 on a MBP.
    Thanks!

    Ok I figured out the problem. It was another application called teleport which lets you control 2 macs with one mouse. It requires a hot key and in my case that was the shift key. Even though it was running it was still affecting me. Had to quit it and restart. If you're having a similar problem I'd check to see you're not running any other applications that can be activated with a hot key.

  • How to Draw a vertical line in flex

    I was just wondering the simplest way to draw a vertical line , preferably dashed.

    You could always just use the graphics class of your chart component.  Just access its graphics object, set the line style/thickness, move to the start point, and line to the end point.  Something like this,
    this.graphics.lineStyle(1, 0x000000);
    this.graphics.moveTo(startX, startY);
    this.graphics.lineTo(endX, endY);

Maybe you are looking for

  • P965 Platinum

    BIOS Sign-on message: MSI P965 Platinum A7238IMS V1.5B1 032207 (Date: 03/22/2007) Attachment name: A7238IMSv151.zip BIOS Sign-on message: MSI P965 Platinum A7238IMS V1.5B2 040407 (Date: 04/04/2007) Attachment name: A7238IMSv152.zip BIOS Sign-on messa

  • How do you stop sms messages automatically being sent to an email address instead of a phone number?

    I have noticed that sometimes (particularly when sending an sms to multiple people) my iphone 4s will send the message to peoples email addresses. This happens despite there being a phone number listed on the contact. You would have thought that an s

  • My ipad no longer shows up on itunes

    my ipad no longer shows up in itunes

  • Bug: Copying and pasting a htmlText ignores embed font???

    - Adobe Flash Pro CS4 - Reproducible in Flash player 9 and 10 There seems to be a bug when copying a string value from a "htmlText" textfield and then pasting it in a standard "text" textField, and then adding that text back into the htmlText textFie

  • Can't create calendar events and reminders

    Having a problem creating events on calendar and reminders, the add button or the 'plus sign' is grayed out. and my past few added events is missing, so now, my meetings, meet ups and important events. im using iPhone 4S running in iOS 7.1.2