Drawing of objects

Hello!
I am a german student and I have the following problem.
I need to draw a connected directed graph onto a panel. Therefore I created a class that represents the nodes of the graph. Each object has a pair of coordinates (all coordinates are located on a circle) and a paintComponent-method that works with the graphics-context of a panel where all objects should paint themselves on.
In the moment I have to check for every MouseEvent performed on the surface of the panel whether the clicking occured in the area of one of my objects, that is i have to run through all objects even if the user clicked the panel somewhere else.
It would be best if I could handle the nodes of my graph as single components, each equipped with its own ActionListener. I am sure that it must be possible to work things in that way, cause otherwise I cannot imagine how to realise drag-and-drop applications while editting graphes.
Perhaps someone can help me.

Thanks, and bugger! I had no idea Smart Guides were changed that much - if it ain't broke, why fix it?
I've now read somthing about pressing teh shift key will bring up movement alignment in 45 degree increments. Pretty clumsy, as I often have the Alt key pressed as well when copying objects accross severy layers. I have Shift and Alt as the two buttons on the pen of my Intuos pad - I don't think I can press both at the same time (and even if I could it just makes things really awkward)...
Oh and btw. when I asked the question I wasn't aware that I was on a user forum - I thought I was writing to Adobe's customer service team! They did really well at disguising the path of getting in touch with them and thus making you guys do the work for them!
So sorry for not having much of a forum ettiquette in my very first posting.
Cheers
Jeffrey

Similar Messages

  • Adobe Flash CS5.5 Crashes while drawing/dragging objects.

    I have experienced quite a few crashes trying out Adobe Creative Suite CS5.5 Premium when it comes to using Flash Professional CS5.5. I have documented one of the crashes at a pastebin entry, which I will link it and an earlier crash log dump below.
    Here's how the crash occurs on my iMac (27-inch, Mid-2011 with AMD 1GB Dedicated Graphics):
    1.) Create either a Flash Document - AS 2.0 or AS 3.0 does not matter, though using 3.0 makes it crash faster I've noticed.
    2.) Draw shapes. After a while of drawing shapes and making them into groups/objects/symbols...
    3.) Drag the shapes around, eventually performance starts to drop over time.
    4.) After a while, Flash will freeze and crash, complete with the beach-ball spinning.
    The most recent crash:
    http://pastebin.com/YCWKAbhp
    There is my pastebin of my latest crash, using an Adobe Flash document using ActionScript 2.0.
    Alternatively, sometimes Flash CS5.5 will crash using ActionScript 3.0 as the language of choice, and oddly much quicker. One of those crashes can be found here: http://pastebin.com/pTSerErw
    The irony in both cases is I don't primarily use Flash Professional CS5.5 for programming or scripting at all. I use it for basic vector artwork for an array of projects. Thus, I don't use AS3.0 with this program.
    Here's what I have done so far to try to remedy this:
    I have updated the Apple JRE/JDK for Mac OS X Lion to the latest revision. I also have cleared out the JRE/JDKs and have started from scratch, to clear out any possible mistakes in installation. I know Java seems to be part of the Flash complilation process, oddly enough
    Use ActionScript 2.0 documents helps keep crashes down, oddly. Yet they still happen eventually
    Booted into Safe Mode to try to fix permissions and such. No dice
    Repaired permissions manually using Disk Utility. No dice
    Edited my jvm.ini file on my install to have no memory constraints, instead defaulting to the ones I have manually set for my JRE/JDKs. Specifically for my Java 64-bit JRE/JDK: -Xmx2048m -Xms512m -Xss2048m -d64 using the Java Preferences application in /Application/Utilities/
    I have also monitored the console for any activity aside crashes. No dice
    Trashed my Preferences and Application Support files
    Deleted/Fixed corrupt or duplicate fonts - I did find some duplicates due to Microsoft Office 2011
    I also have sought out other errors here on the Adobe Forums/Community. While similar, they are usually for more complicated projects, while mine is simply drawing and copy/pasting stuff seems to be a problem.
    In short, I've done my research and still haven't been able to fix it
    Oddly enough, most of the time no corruption has been reported due to this. In fact, I usually just have to restart Flash, save often, and if it crashes, repeat until my project is done. I also don't use auto recovery because it actually makes things more confusing and I admittedly don't trust it.
    Also, I usually have Flash Professional running, as well as Adium (IM client), Safari, and iTunes. Usually no other programs are running outside background programs or menu bar items.
    Does anyone have insight, solutions or possible pointers on how to fix this? It's more of an annoyance - but this is painful since I spent good money on this product. I hope CS6 improves this with full 64-bit support and better memory management.

    Hi,
    I am not sure if this is a "Master Page since we use a French version (the functionnality is  named "Gabarit" in French), so here is a printscreen which shows what our users try to do:
    Immediately after the drop is completed, InDesign shuts down without further notice as described before.
    I fully patched one machine to 7.5.3, rebooted it and it still does not work.
    I know 2 GB is a little bit short, but since this is currently a corporate standard in my customer's organization, I will need to be sure that this is the direct and only cause before any upgrade request can be made.
    Thank you for your help.

  • Precise movement and drawing of objects in CS6

    Hi,
    having used CS3 before, I've recently bought the CS6 package. I set all Preference settings they way they were in CS3 but I'm having difficulties moving a selected object in precise orthogonal (or diagonal) orientation. I'm used to seeing an "origin" alignment aid when I drag the object, usually at 0, 45, 90 or 180 degrees to its original position. This doesn't happen anymore in CS6, instead I get a myrad of alignment options to any other objects of anchors in sight, but not the important "origin" one. The same problem exists with the rotation tool - when I want to rotate an object quickly by 90 or 180 degrees, in CS3 I could just use the rotation tool and it would "click" into origin positions at 90 or 180 degrees. In CS6 I get an small window showing me the exact rotation degree, but to me it's pretty useless to know that I've just rotated the object by 179.6 degrees, but I can't get to the exact 180.
    I am aware that I couold always use the Transformation option and enter a precise value of either moveemnt or rotation, but for simple actions it was much quicker to use a select and drag or select and rotate tool.
    The pen tool is slightly better with the "origin" alignment aid, but still I get a lot more unwanted alignment options than before in CS3, distracting from quick and precise positioning of anchor points.
    I do a lot of quite technical drawing, more akin to CAD than "free" illustration, but never had such a problem with Illustrator in CS3.
    Is there a way to set up CS6 so it behaves the way I'm used to?
    Best regards
    Jeffrey Kubiak

    Thanks, and bugger! I had no idea Smart Guides were changed that much - if it ain't broke, why fix it?
    I've now read somthing about pressing teh shift key will bring up movement alignment in 45 degree increments. Pretty clumsy, as I often have the Alt key pressed as well when copying objects accross severy layers. I have Shift and Alt as the two buttons on the pen of my Intuos pad - I don't think I can press both at the same time (and even if I could it just makes things really awkward)...
    Oh and btw. when I asked the question I wasn't aware that I was on a user forum - I thought I was writing to Adobe's customer service team! They did really well at disguising the path of getting in touch with them and thus making you guys do the work for them!
    So sorry for not having much of a forum ettiquette in my very first posting.
    Cheers
    Jeffrey

  • Drawing small objects?

    I'd like to be able to draw a disk of 2 mm diameter quickly.
    I'm working on MacOS X 10.4.11, and in my environment,
    the decimal separation character is the ",". Hence, for example,
    2 and a half inch is written 2,5".
    I proceeded as follow:
    • open Pages'08 (version 3.0.2) which will open a blank page;
    • select Shapes > disk (from the Toolbar) which will drop a green disk of 3,53 cm x 3,53 cm;
    • select the down right handle of this disk with the shift key pressed;
    • move this handle upside left to reach the desired value: 0.2 cm.
    First problem:
    I can't reach the 0,2 cm value.
    I'm able to reach 0,21 cm and 0,18 cm.
    Second problem:
    I opened the Inspector > Metrics
    I tried to type 0,2 cm in the Width field, but the only result was the
    bong! from the speaker.
    I tried to type 0.2 cm ("." in place of ","), but the field value was replaced with 2 cm, and the disk resized to 2 cm.
    Did I do something wrong?
    I have the exact same problem with all the small objects I want to create.
    I simply can't draw them quickly.
    I found a workaround: enter the Inspector > Metrics, *for each object*,
    enter a size of 1,2 cm in the Width field, and then decrease it with
    the scroll button on the right of the field, which does set it to
    0,2 cm. I feel like trying to hunt flies with a hammer.
    What is the direct and efficient method?
    <pre>--------
    don't look for my Macs models in my signature, this would be uggly... and irrelevant
    dan</pre>

    Jerrold Green1 wrote:
    Daniel,
    What you would like to do works well in my version of Pages and my language setting (US English).
    Thank you for your different viewpoint. I tried to set my international settings (International > Input) to United states, and the second problem
    disappeared. But the first one is still a serious problem biting me many times
    per hour (I do a lot of graphics for technical documentation).
    Until you find the answer to your difficulty with direct entry of the decimal character, you may find some convenience in creating an otherwise blank document to leave open on your desktop with the little circle in it. Then just Copy/Paste whenever you need it in your working document.
    That's pretty much like the workaround I found. Once I have done one of my graphics, I try
    to limit myself to copy and paste of the same one inside the same document
    to avoid an unaffordable waste of time. Nonetheless, this method is a limit of
    use of graphics and a huge waste of time.
    <pre>--------
    don't look for my Macs models in my signature, this would be uggly... and irrelevant
    dan</pre>

  • Drawing InDesign objects on a extension panel

    hi all,
    I'm trying to develop an InDesign extension using the Extension Builder 2.1 – unfortunately I am almost completely new to the whole topic.
    I was wondering if it's possible to draw objects, lets say a rectangle or a vector shape from an opened InDesign document to the panel. Actually it doesn't sound like a difficult task but anyway I'm a lost. I would appreciate any hint where to look for that concern. 
    Thanks for helping!

    Hi,
    Since you're new to the topic, I would start here: http://labs.adobe.com/technologies/extensionbuilder3/ (use Extension Builder 3, not 2.1).
    Also, read this: http://www.adobe.com/devnet/creativesuite/articles/introducing-html5-extensions.html
    Best regards,
    Hallgrimur
    Hallgrimur Th. Bjornsson | Product Manager - SET | Adobe | Tel: +44 (0) 1314582787

  • Pen Tool - Curve drawing under Object Lock

    How do you draw a smoother curved line as described in this tutorial in Steps 6 and 7?
    http://design.tutsplus.com/articles/create-a-glowing-neon-sign-using-the-appearance-palett e--vector-3791

    Thank you - As it turns out, I was using the tutorial here as a guide http://design.tutsplus.com/articles/create-a-glowing-neon-sign-using-the-appearance-palett e--vector-3791
    I was trying to use Steps 6, 7, and 8 to draw lines with the Pen tool that traced the interior of letters to generate a neon sign effect to keep applying new strokes to build up the glowing effect. 
    I am having difficulty recreating smooth lines inside the trace of the letters – my lines look choppy and not at all like the tutorial suggests.
    I was using the Appearance Palette, which stressed using simple paths that can be turned into vector artwork simply by using multiple fills and effects.  The approach was to use the approach outlined to avoid having to use complicated Bezier curves or stacking multiple vector shapes on top of one another.

  • Bug? draw line object front of image

    Post Author: Hamid
    CA Forum: Charts and Graphs
    who can draw a line front of an image? or it s a missed bug?

    Post Author: Hamid
    CA Forum: Charts and Graphs
    dose anybody have this problem?

  • Drawing lines, rectangles and circles as objects onto a JPanel.

    Hi. I have to complete a task in school. The work is to create some simple 2D graphical editor. I'm new to java and I have some problems with this job, so I'm looking for help where it is possible...
    I created a JFrame and using it as a window. Into this JFrame I've added a toolbox (JToolBox) and "drawpad" - a JPanel. The toolbox wasn't any problem, but I aim to use the JPanel for drawing 2D objects. I tought about creating some container of objects, where I could put lines, rectangles or circles, each one with its properties (color, [x; y] coordinates on the scene, filling and drawing width) and then, draw this scene onto the JPanel.
    It should be something like windows Paintbrush. Can be simplier, but including the possibility to move and change properties of drawn objects.

    Well, there are two approaches to this that come to mind:
    1. Create an image. If this program is supposed to be like Windows Paint, the tools you are describing are only there for the sake of modifying a two dimensional image. In that case, I would recommend using a BufferedImage.
    The JPanel can contain a single JLabel. The JLabel is constructed in the following fashion:
    JLabel image_label = new JLabel(new ImageIcon(bufferedImage));...where bufferedImage is the image on which you will be storing the data. You can use bufferedImage.getGraphics() to get an object which will quite happily draw geometric shapes for you. Then, after each draw, you tell the panel to repaint itself.
    2. Store the shapes and create a component to draw them for you. You'd create a new JComponent class that would accept objects representing geometric shapes. You then override the paintComponent method on this new class to have it render itself according to the contents of the geometry objects. It would also probably be advisable to have all of these classes implement a common interface (which you would also create) so the rendering component could treat them identically.

  • Drawing objects in Flash

    Help
    When I draw to the stage using the line tool or pencil tool,
    I am unable to fill the item with a solid color or gradient color.
    You must be able to do it as most tutorials say "draw the object
    using the line tool and fill it using the paint bucket"
    What am I doing wrong??????
    Brian M

    Hi...You should tuch every line...then you can do..

  • How to make lines I draw as an objects??

    Hi friends:
    I met a problem here, I find a similiar code below, but cannot solve it.
    How to make lines I draw as objects in this application??
    ie the lines I draw will be selectable as other JLabels, can be highlighted, can be deleted etc, just like any other components or object,
    How to do this??
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import java.util.Vector;
    import java.lang.reflect.Array;
    import javax.swing.*;
    import javax.swing.event.*;
    public class Drawines
         public static void main(String[] args)
            JFrame f = new JFrame("Draw Lines");
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.getContentPane().add(new ConnectionPanel());
            f.setSize(400,300);
            f.setLocation(200,200);
            f.setVisible(true);
    class Drawines extends JPanel
        JLabel                                       label1, label2, label3, label4;
        JLabel[]                       labels;
        JLabel                                       selectedLabel;
        protected              JButton btn            = new JButton("DrawLines");
        protected              JButton btn1           = new JButton("Clear");
        protected              JButton btn2           = new JButton("No Draw");
        protected                      boolean isActivated = false;
        protected           int      stoppoint     = 0;          
        int cx, cy;
        Vector order                     = new Vector();
        Vector order1                     = new Vector();
        Object[] arr                    = null;
        public ConnectionPanel()
            setLayout(null);
            addLabels();
            label1.setBounds( 25,  50, 125, 25);
            label2.setBounds(225,  50, 125, 25);
            label3.setBounds( 25, 175, 125, 25);
            label4.setBounds(225, 175, 125, 25);
            btn.setBounds(10, 5, 100, 25);
            btn1.setBounds(100, 5, 100, 25);
            btn2.setBounds(200, 5, 100, 25);
                add(btn);
             add(btn1);
             add(btn2);
            determineCenterOfComponents();
            ComponentMover mover = new ComponentMover();
             ActionListener lst = new ActionListener() {
                 public void actionPerformed(ActionEvent e) {
                     ComponentMover mover = new ComponentMover();
                           addMouseListener(mover);
                           addMouseMotionListener(mover);
                           isActivated = false;
            ActionListener lst1 = new ActionListener() {
                       public void actionPerformed(ActionEvent e) {
                           isActivated=true;
              btn.addActionListener(lst);
              btn1.addActionListener(lst1);
        public void paintComponent(final Graphics g)
             super.paintComponent(g);
            Graphics2D g2 = (Graphics2D)g;
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
             Point[] p;
                System.out.println("order.size()"+ order.size());
                System.out.println("order1.size()"+ order1.size());
                     if (!isActivated && order1.size()==0) {
                         for(int i = 0 ; i < order.size()-1; i++) {
                                JLabel l1 = (JLabel)order.elementAt(i);
                               JLabel l2 = (JLabel)order.elementAt(i+1);
                               order1.add(order.elementAt(i));
                               order1.add(order.elementAt(i+1));
                               System.out.println();
                               p = getCenterPoints(l1, l2);
                               g2.setColor(Color.black);
                                            g2.draw(new Line2D.Double(p[0], p[1]));            
                     }else if(!isActivated && order1.size()>0){
                             order=order1;
                         for(int i1 = 0 ; i1 < order.size()-1; i1++) {
                               JLabel l1 = (JLabel)order.elementAt(i1);
                               JLabel l2 = (JLabel)order.elementAt(i1+1);
                               System.out.println();
                               p = getCenterPoints(l1, l2);
                               g2.setColor(Color.red);
                                g2.draw(new Line2D.Double(p[0], p[1]));    
                                System.out.println(" order1.size() = " + order.size());
                     }else {
                          order1 = order;
                         for(int i1 = 0 ; i1 < order1.size()-1; i1++) {
                                    JLabel l1 = (JLabel)order1.elementAt(i1);
                                    JLabel l2 = (JLabel)order1.elementAt(i1+1);
                                    p = getCenterPoints(l1, l2);
                                    g2.setColor(Color.blue);
                                    if (order.elementAt(i1) !=null){
                                         g2.draw(new Line2D.Double(p[0], p[1]));    
        private Point[] getCenterPoints(Component c1, Component c2)
            Point
                p1 = new Point(),
                p2 = new Point();
            Rectangle
                r1 = c1.getBounds(),
                r2 = c2.getBounds();
                 p1.x = r1.x + r1.width/2;
                 p1.y = r1.y + r1.height/2;
                 p2.x = r2.x + r2.width/2;
                 p2.y = r2.y + r2.height/2;
            return new Point[] {p1, p2};
        private void determineCenterOfComponents()
            int
                xMin = Integer.MAX_VALUE,
                yMin = Integer.MAX_VALUE,
                xMax = 0,
                yMax = 0;
            for(int i = 0; i < labels.length; i++)
                Rectangle r = labels.getBounds();
    if(r.x < xMin)
    xMin = r.x;
    if(r.y < yMin)
    yMin = r.y;
    if(r.x + r.width > xMax)
    xMax = r.x + r.width;
    if(r.y + r.height > yMax)
    yMax = r.y + r.height;
    cx = xMin + (xMax - xMin)/2;
    cy = yMin + (yMax - yMin)/2;
    private class ComponentMover extends MouseInputAdapter
    Point offsetP = new Point();
    boolean dragging;
    public void mousePressed(MouseEvent e)
    Point p = e.getPoint();
    for(int i = 0; i < labels.length; i++)
    Rectangle r = labels[i].getBounds();
    if(r.contains(p) && !isActivated )
    selectedLabel = labels[i];
    order.addElement(labels[i]);
    offsetP.x = p.x - r.x;
    offsetP.y = p.y - r.y;
    dragging = true;
    repaint(); //added
    break;
    public void mouseReleased(MouseEvent e)
    dragging = false;
    public void mouseDragged(MouseEvent e)
    if(dragging)
    Rectangle r = selectedLabel.getBounds();
    r.x = e.getX() - offsetP.x;
    r.y = e.getY() - offsetP.y;
    selectedLabel.setBounds(r.x, r.y, r.width, r.height);
    //determineCenterOfComponents();
    repaint();
    private void addLabels()
    label1 = new JLabel("Label 1");
    label2 = new JLabel("Label 2");
    label3 = new JLabel("Label 3");
    label4 = new JLabel("Label 4");
    labels = new JLabel[] {
    label1, label2, label3, label4
    for(int i = 0; i < labels.length; i++)
    labels[i].setHorizontalAlignment(SwingConstants.CENTER);
    labels[i].setBorder(BorderFactory.createEtchedBorder());
    add(labels[i]);
    Thanks in advance.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    2 choice, bundle your app in a jar, or get a native compiler.
    executable jar
    http://java.sun.com/j2se/1.3/docs/guide/jar/jarGuide.html
    http://developer.java.sun.com/developer/qow/archive/21/index.html
    native
    http://gcc.gnu.org/java/
    http://www-106.ibm.com/developerworks/library/j-native.html
    http://icafe.sourceforge.net/
    http://www.towerj.com/
    http://www.xlsoft.com/en/products/development/jet/jetpro.html

  • Need Help to Draw and Drag Triangle - URGENT

    Hi everyone - I am developing various proofs of the pythagora's theorem
    and the following code draws a triangle on screen and the proof follows -
    but i need to know how to drag the triangle such tht 1 angle is always set to 90 degrees.
    i.e. i need to resize the triangle by dragging its vertex points by which the1 angle remains at 90 no matter what the size.
    The proof has got some graphics code hardcoded in it - i.e. LINES AND POLYGONS have been hardcoded
    i need to reconfigure that such that everytime the user increases the size of the triagnle and clicks on next it draws the lines and polygons in the correct area and place
    PLEASE HELP
    the code is as follows
    MAIN CLASS
    import java.awt.BorderLayout;
    import java.awt.Container;
    import java.awt.*;
    import java.awt.event.*;
    import java.text.*;
    import javax.swing.*;
    public class TestProof {
        TestControl control;          // the controls for the visual proof
        TestView view;          // the drawing area to display proof
        // called upon class creation
        public TestProof() {
            view = new TestView();
    view.setBackground(Color.WHITE);
            control = new TestControl(view);
            Frame f = new Frame("Pythagoras");
            f.add(view,"Center");
            f.add(control,"South");
            f.setSize(600,600);
            f.setBackground(Color.lightGray);
            f.addMouseMotionListener(
            new MouseMotionListener() { //anonymous inner class
                //handle mouse drag event
                public void mouseMoved(MouseEvent e) {
                    System.out.println("Mouse  " + e.getX() +","  + e.getY());
                public void mouseDragged(MouseEvent e) {
                    System.out.println("Draggg: x=" + e.getX() + "; y=" + e.getY());
            JMenu File = new JMenu("File");
            JMenuItem Exit = new JMenuItem("Exit");
            Exit.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    ExitActionPerformed(evt);
            JMenuBar menuBar = new JMenuBar();
            menuBar.add(File);
       File.add(Exit);
            f.add(menuBar,"North");
            f.show();
        private JMenuBar getMenuBar() {
            JMenu File = new JMenu("File");
            JMenuItem Exit = new JMenuItem("Exit");
            Exit.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    ExitActionPerformed(evt);
            JMenuBar menuBar = new JMenuBar();
            menuBar.add(File);
                 File.add(Exit);   
            return menuBar;
        private void ExitActionPerformed(java.awt.event.ActionEvent evt) {
            // TODO add your handling code here:
            System.exit(0);
        // for standalone use
        public static void main(String args[]) {
      TestProof TP = new TestProof();
    }Test VIEW
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import java.text.*;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    public class TestView extends Canvas {
        int TRANSLUCENT = 1;
        int sequence;          // sequencer that determines what should be drawn
        // notes matter
        int noteX = 100;     // note coordinates
        int noteY = 60;
        int fontSize = 11;     // font size
        int lineSpacing     // space between two consecutive lines
        = fontSize + 2;
        Font noteFaceFont;     // font used to display notes
        // objects matter
        Polygon tri;          // right-angled triangle with sides A, B, and C
        Polygon tri1;
        Polygon sqrA;          // square with side of length A
        Polygon sqrB;          // square with side of length B
        Polygon sqrC;          // square with side of length C
        Polygon parA;          // parallelogram of base A and height A
        Polygon parB;          // parallelogram of base B and height B
        Polygon poly1;
        Polygon poly2;
        Polygon poly3;
        Polygon poly4;
        Polygon poly5;
        Polygon poly6;
        int X0 = 350;          // coordinates of triangle
        int Y0 = 350;
        int A = 90;//60;          // triangle size
        int B = 120;//80;
        int C = 150;//100;
        //CORDS of 2nd triangle
        int X1 = 350;
        int Y1 = 500;
        // notes: three lines per note
        String notes[] = {
            // note 0
            // note 1
            // note 2
            // note 3
            // note 4
            // note 5
            // note 6
            // note 7
            // note 8
            // note 9
            // note 10
            // note 11
            // note 12
            // note 13
            // note 14
        // constructor
        public TestView() {
            addMouseMotionListener(
            new MouseMotionListener() { //anonymous inner class
                //handle mouse drag event
                public void mouseMoved(MouseEvent e) {
                    System.out.println("Mouse  " + e.getX() +","  + e.getY());
                public void mouseDragged(MouseEvent e) {
                    System.out.println("Draggg: x=" + e.getX() + "; y=" + e.getY());
            // set font
            noteFaceFont = new Font("TimesRoman", Font.PLAIN, fontSize);
            // (coordinates specified w.r.t. to P0, unless otherwise specified)
            // create the triangle
            tri = new Polygon();
            tri.addPoint(0, 0);                    // add P0 coordinate
            tri.addPoint(A*A/C, -A*B/C);          // add A3 coordinate
            tri.addPoint(C, 0);                    // add C1 coordinate
            tri.translate(X0, Y0);               // place triangle
            tri1 = new Polygon();
            tri1.addPoint(0,0);                    // add P0 coordinate
            tri1.addPoint(A*A/C +38, +A*B/C);          // add A3 coordinate
            tri1.addPoint(C, 0);                    // add C1 coordinate
            tri1.translate(X1, Y1);
            // create square of side A
            sqrA = new Polygon();
            sqrA.addPoint(0, 0);               // add P0 coordinate
            sqrA.addPoint(-A*B/C, -A*A/C);          // add A1 coordinate
            sqrA.addPoint(-A*(B-A)/C, -A*(A+B)/C);     // add A2 coordinate
            sqrA.addPoint(A*A/C, -A*B/C);          // add A3 coordinate
            sqrA.translate(X0, Y0);               // place square
            // create square of side B
            // warning: the coordinate of this object are specified relative to C1
            sqrB = new Polygon();
            sqrB.addPoint(0, 0);               // add C1 coordinate
            sqrB.addPoint(B*A/C, -B*B/C);          // add B1 coordinate
            sqrB.addPoint(B*(A-B)/C, -B*(A+B)/C);     // add B2 coordinate
            sqrB.addPoint(-B*B/C, -B*A/C);          // add A3 coordinate
            sqrB.translate(X0 + C, Y0);               // place square
            // create square of side C
            sqrC = new Polygon();
            sqrC.addPoint(0, 0);               // add P0 coordinate
            sqrC.addPoint(C, 0);               // add C1 coordinate
            sqrC.addPoint(C, C);               // add C2 coordinate
            sqrC.addPoint(0, C);               // add C3 coordinate
            sqrC.translate(X0, Y0);               // place square
            poly1 = new Polygon();
            poly1.addPoint(405,279);
            poly1.addPoint(413,350);
            poly1.addPoint(432,500);
            poly1.addPoint(442,571);
            poly1.addPoint(500,500);
            poly1.addPoint(500,350);
            poly2 = new Polygon();
            poly2.addPoint(279,297);
            poly2.addPoint(404,280);
            poly2.addPoint(571,254);
            poly2.addPoint(500,350);
            poly2.addPoint(350,350);
            //Polygon 3
            poly3 = new Polygon();
            poly3.addPoint(404,280);
            poly3.addPoint(350,350);
            poly3.addPoint(414,350);
            poly4 = new Polygon();
            poly4.addPoint(350,350);
            poly4.addPoint(350,500);
            poly4.addPoint(442,572);
            poly4.addPoint(433,500);
            poly4.addPoint(414,350);
            poly5 = new Polygon();
            poly5.addPoint(476,183);
            poly5.addPoint(332,225);
            poly5.addPoint(278,295);
            poly5.addPoint(404,279);
            poly5.addPoint(571,254);
            poly6= new Polygon();
            poly6.addPoint(405,278);
            poly6.addPoint(332,224);
            poly6.addPoint(476,182);
            // create parallelogram of height A
            parA = new Polygon();
            parA.addPoint(0, 0);               // add P0 coordinate
            parA.addPoint(0, C);               // add C3 coordinate
            parA.addPoint(A*A/C, C - A*B/C);          // add Q0 coordinate
            parA.addPoint(A*A/C, -A*B/C);          // add A3 coordinate
            parA.translate(X0,Y0);               // place parallelogram
            // create parallelogram of height B
            // warning: the coordinate of this object are specified from C1
            parB = new Polygon();
            parB.addPoint(0, 0);               // add C1 coordinate
            parB.addPoint(-B*B/C, -B*A/C);          // add A3 coordinate
            parB.addPoint(A*A/C - C, C - A*B/C);     // add Q0 coordinate
            parB.addPoint(0, C);               // add C2 coordinate
            parB.translate(X0 + C, Y0);
            // place parallelogram
        // depending on the sequence number we draw certain objects
        public void paint(Graphics gfx) {
            super.paint(gfx);
            Graphics2D g = (Graphics2D) gfx;
            g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
            RenderingHints.VALUE_ANTIALIAS_ON);
            // text first, then objects (and animation)
            // we always output some notes
            g.drawString(notes[3*sequence], noteX, noteY);
            g.drawString(notes[3*sequence + 1], noteX, noteY + lineSpacing);
            g.drawString(notes[3*sequence + 2], noteX, noteY + 2*lineSpacing);
            // the object are drawn in an order so that they are properly overlapped
            if(sequence == 13) {
                g.setColor(Color.green);
                g.fillPolygon(poly1);
                g.fillPolygon(poly2);
                g.fillPolygon(poly3);
                g.fillPolygon(poly4);
                g.fillPolygon(poly5);
                g.setColor(Color.RED);
                g.setColor(Color.GREEN);
                g.drawLine(413,351,433,499);
                g.setColor(Color.white);
                g.fillPolygon(tri);
                g.fillPolygon(tri1);
                g.fillPolygon(poly6);
            if(sequence == 12 ) {
                g.setColor(Color.green);
                g.fillPolygon(poly1);
                g.fillPolygon(poly2);
                g.fillPolygon(poly3);
                g.fillPolygon(poly4);
                g.fillPolygon(poly5);
                g.setColor(Color.BLACK);
            if(sequence == 11){
                g.setColor(Color.green);
                g.fillPolygon(poly1);
                g.fillPolygon(poly3);
                g.fillPolygon(poly4);
                g.setColor(Color.BLACK);
            if(sequence == 8 ){
                g.setColor(Color.green);
                g.fillPolygon(poly5);
                g.setColor(Color.MAGENTA);
                g.drawString("E",578,254);
                g.drawString("D",268,302);
                g.setColor(Color.black);
                g.drawArc(250,150,350,250,320,65);
            else if (sequence == 9 ){
                g.setColor(Color.green);
                g.fillPolygon(poly2);
                g.setColor(Color.MAGENTA);
                g.drawString("E",578,254);
                g.drawString("D",268,302);
                g.setColor(Color.black);
                g.drawArc(250,150,350,250,320,65);
            if( sequence == 10){
                g.setColor(Color.green);
                g.fillPolygon(poly2);
                g.fillPolygon(poly5);
                g.setColor(Color.black);
                g.setColor(Color.MAGENTA);
                g.drawString("E",578,254);
                g.drawString("D",268,302);
                g.setColor(Color.black);
                g.drawArc(250,150,350,250,320,65);
            if(sequence == 7){
                g.setColor(Color.green);
                g.fillPolygon(poly2);
                g.setColor(Color.MAGENTA);
                g.drawString("E",578,254);
                g.drawString("D",268,302);
                g.setColor(Color.black);
            if(sequence == 6){
                g.setColor(Color.yellow);
                g.fillPolygon(poly2);
                g.setColor(Color.green);
                g.fillPolygon(poly3);
                g.setColor(Color.blue);
                g.fillPolygon(poly4);
                g.setColor(Color.black);
                g.drawArc(250,175,350,275,300,65);
                //g.drawArc(250,150,350,250,320,65);
                g.drawLine( 606,309,599,299);
                g.drawLine(592,313, 599,299);
                g.drawString("+90 degrees",605,378);
            if (sequence == 5 ) {
                g.setColor(Color.yellow);
                g.fillPolygon(poly2);
                g.setColor(Color.black);
            if (sequence == 4) {
                g.setColor(Color.YELLOW);
                g.fillPolygon(poly1);
                g.setColor(Color.black);
                g.drawArc(319,310,250,195,89,-35);
                g.drawLine(499,319, 492,312);
                g.drawLine(499,319, 492,325);
                g.drawArc(200,180, 233,238,-120,-60);
                g.drawLine(200,298, 208,309);
                g.drawLine(200,298, 194,313);
                g.drawString("-90 degrees",227,347);
            if (sequence >= 3) {
                g.drawLine(404,279,442,572);
            // draw the squares
            if (sequence >= 2) {
                g.drawLine(278,296,572,254);
            // draw the squares
            if (sequence >= 1) {
                g.drawLine(333,224,476,182);
                g.drawPolygon(tri1);
            // always draw the triangle
            g.drawPolygon(tri);
            g.drawPolygon(sqrA);
            g.drawPolygon(sqrB);
            g.drawPolygon(sqrC);
            g.setColor(Color.MAGENTA);
            g.drawString("C", X0 + C/2 - fontSize/2, Y0 + lineSpacing);
            g.drawString("A",
            X0 + A*A/(2*C) - fontSize*A/B/2,
            Y0 - A*B/(2*C) - lineSpacing*A/B);
            g.drawString("B",
            X0 + C - B*B/(2*C) - fontSize*A/B/2,// the last "-" isn't log.
            Y0 - B*A/(2*C) - lineSpacing*A/B);
        public void redraw(int sequence) {
            this.sequence = sequence;
            repaint();
    }TEST CONTROL
    * TestControl.java
    * Created on 28 February 2005, 11:16
    import java.awt.*;
    import java.awt.event.*;
    import java.text.*;
    import javax.swing.JFrame;
    * @author  Kripa Bhojwani
    public class TestControl extends Panel implements ActionListener {
      TestView view;
      int sequence;                    // event sequence
      // constructor
      public TestControl(TestView view) {
        Button b = null;
        Label label = new Label("A^2 ");
        this.view = view;          // initialize drawble area
        sequence = 0;               // initialize sequence
        b = new Button("Prev");
        b.addActionListener(this);
        add(b);
        b = new Button("Next");
        b.addActionListener(this);
        add(b);
        add(label);
      // exported method
      public void actionPerformed(ActionEvent ev) {
        String label = ev.getActionCommand();
        if (label.equals("Prev")) {
          if (sequence >0) {
         --sequence;
        else {
          if (sequence < 15) {
         ++sequence;
        this.setEnabled(false);          // disable the controls
        view.redraw(sequence);
        this.setEnabled(true);          // enable the controls
    }Please help --- really need to sort this out...
    THANKS

    One of the problems you face is that it is hard to recognise which parts of your code are drawing the triangle. This is because you are writing code in a procedural way rather than an object oriented way.
    In object oriented code you would have a triangle object that could draw itself. You would create the triangle object by specifying its sizes and angles in some way. Then it should be easy to change the triangles sizes and angles and ask all the drawn objects to redraw themselves.

  • Positioning moving objects

    I'm getting ready to make a 2d game and wasn't sure how to draw moving objects on the screen. I've played around in the past and always had a fixed sized window and basically moved objects around on a pixel grid. I want to have a resizeable window but keep the relative size and movements of objects the same. How is this usually done? Should I just render it to the largest possible window size and then transform it to the appropriate size? Thanks in advance!

    jgould wrote:
    I'm getting ready to make a 2d game and wasn't sure how to draw moving objects on the screen. I've played around in the past and always had a fixed sized window and basically moved objects around on a pixel grid. I want to have a resizeable window but keep the relative size and movements of objects the same. How is this usually done? Should I just render it to the largest possible window size and then transform it to the appropriate size? Thanks in advance!Not sure what that means. Basically you have a couple options:
    1- Store locations by ratios, not exact coordinates. So if you want a GameObject's location to be in the direct middle of the screen, its position would be (.5, .5). Then when you go to draw that GameObject, you have to convert that position to screen coordinates. You do this simply by multiplying the ratio-coordinates by the game window's width or height.
    2- Store locations by some model coordinates. This is similar to the first method, but requires some extra translation. You would store the GameObject's location via coordinates such as (50, 50), but you would also have to keep track of how large your game window model was (for simplicity's sake, let's say it is 200 by 100):
    drawPoint( (gameObject.getX() / 200) * gamePanel.getWidth(), (gameObject.getY() / 100) * gamePanel.getHeight() );Does that make any more sense?
    Edit- I should say that there probably are a ton of other ways to do it, these are just the ways that most easily fit into my head. It's all just algebra though.
    Edited by: kevinaworkman on Nov 13, 2009 2:54 PM

  • How do I create an offset outside (outside only) an object?

    The problem is:
    I often have complex vector objects which contain paths and I want to create a path around the object.
    I have tried Offset Path, but this command also offset the interior of the object.
    I have also tried Effect>Path>Offset Path, but the original path that I selected disappears and is replaced by the new offset path.
    I want to keep the original path and have an offset around it.
    I am a long time AI CS3 user and this question has always been lingering over my head.
    My problem is that I create engravings of images and I want my machine to cut an outline around the engraving, the outline being X pts bigger than the engraving.
    I have uploaded some images to help visualize the issue.
    Thanks for any help.
    P.S: I'm stuck with CS3 unfortunately.
    Original image: http://i46.tinypic.com/21edvs6.jpg
    Image with path that I want to offset: http://i48.tinypic.com/15xmsso.jpg
    Image after offset: http://i47.tinypic.com/5nnind.jpg

    Just to set up an example, draw these objects near each other:
    A closed simple path (ex: Rectangle), solid fill, no stroke
    A compound path (ex: two compounded circles, solid fill, no stroke
    Duplicates of the above two objects, no fill, solid strokes of differing weights
    An open path, no fill , solid stroke
    Now carefully do the following to create an offset outline. Be aware, the resulting outline will take on the stroke/fill of the frontmost path.
    For example, if the frontmost path has a black stroke, fill of none, so will the resulting offset contour.
    1. Select all the Paths.
    2. Object>Group.
    3. Edit>Copy.
    4. Edit>Paste In Front.
    5. Effect>Path>Outline Object.
    6. Effect>Path>Offset Path. Offset: as desired. Joins: Round.
    7. Effect>Pathfinder>Add.
    Now store this as a Graphic Style:
    8. Black pointer: Drag the Group and drop it into the Graphic Styles palette.
    9. DoubleClick the Style’s icon. Set its name to “Offset Contour” (or whatever).
    Now you can apply the same Graphic Style to a different Group with one click.
    Graphic Styles are saved with the document. So if you want to use the same Style in other documents:
    10. Graphic Styles flyout menu: Save Graphic Style Library...
    By default, the Graphic Style Library will be written into the Graphic Styles folder of your user account. Example:
    C:\Users\firstName.lastName\AppData\Roaming\Adobe\Adobe Illustrator CS5.1 Settings\en_US\Graphic Styles
    You can later load it into a new document by Graphic Style palette flyout menu>Open Graphic Style Library>User Defined,
    or by simply copying a Group to which the Style has been applied and pasting it into the new document.
    After storing the Style for future use, expand it into an ordinary path (or compound path, depending on the artwork):
    11. Object>Expand Appearance.
    12. Ungroup.
    13. Apply fill/stroke as desired.
    Once you have created the Graphic Style, you can record an Action to automate the  whole thing, by recording these steps:
    1. Steps 2-4
    2. Application of the Offset Contour Style
    3. Steps 11-13
    Now you can create such an outline for any set of paths with a single click by selecting all the associated paths and clicking the Action.
    JET

  • Adding line-art shading to line-art object

    I'm hoping that someone can give me an idea of how to do something a little easier than I have been doing. It's a little hard to describe but without an image upload function on this forum I'm going to have to try with words alone.
    I am drawing simple line art (entirely vector) objects with solid colors that need a 3d look to them. For instance, a simple balloon where the right side is in the shadow, so it needs to be darker. If I were doing it with a pencil I'd just shade the right side of the balloon in a crescent shape. In illustrator though I need to create another vector object to be the shading.
    The outside of the balloon needs to be a solid black line. The object that becomes the shading needs to have no outline because it's just a darker color of the balloon (e.g. dark red to the balloon's bright red color). Making the outline its own object can't be done because it will either not reach the line of the balloon or its own color will partially cover up the black outline (because it is in front).
    I've been successful at making these by implementing the shading as a large object that intersects the balloon, creating a live object out of the two, then setting the various line segments and areas with the live paint tool until it looks right. However this is time consuming and I wind up with an object that is conspicuously larger than it looks because of the invisible parts of the live paint object sticking out. Also, if things get just a little more complex with additional live paint objects then there are a bunch of line segments and live paint areas that I have to take care of. Maintenance of the object is difficult.
    Can anyone suggest a better way to do this that doesn't involve live objects, patterns/gradients (everything needs to be a solid color) and doesn't take a lot of work to create?
    Thanks!

    One way is the old fashion way:
    1. Draw balloon object with highlight color, no stroke.
    2. Copy balloon object, paste in front, reshape copy into crescent by dragging individual points from left edge toward right; recolor this copy as shadow tint.
    3. Paste in front a second time, assign no fill, black stroke to this copy.

  • Illustrator CS6: Missing small pixels box that should follow the cursor when creating objects

    Somehow I've managed to disable a feature in Illustrator CS6 that does two things: 1) it causes a small box to follow the cursor when I'm drawing an object 2) the light green lines or x's are gone now, too. How can I get them back? Are they only visible under certain circumstances?  Thanks!

    SmartGuides is not simply "on" or "off". It has settings for what displays. Check your SmartGuides preferences.
    JET

Maybe you are looking for

  • Wifi problem after.4.3 update on xperia z

    Hi all, After updating my Xperia Z (C6603) to build number 10.4.1.B.0.101 I've been having connection issues with every Wi-Fi network. I've checked the forum but I only found problems about people having Wi-Fi issues with their smartwatch, I do not o

  • Best Practice for ASA Route Monitoring Options?

    We have one pair Cisco ASA 5505 located in different location and there are two point to point links between those two locations, one for primary link (static route w/ low metric) and the other for backup (static route w/ high metric). The tracked op

  • How to read the column name of the Table.

    hi    I have applied sort functionality to the Table columns. It is working fine but I need to read the table column name before sorting ( On which column user trying to sort ).    Thank you all, Rama...

  • How to write validation in java sript item should not allow more than 20 ch

    HI, I need to write validation in java script for a item it should not allow more than 20 characters. Thanks Nr

  • Newest movie purchase won't play/sync on iPod3rdGen

    I just downloaded a movie that came out today. My ipod refuses to play it - iTunes won't even transfer it to back it up. When I downloaded trailers of this movie on my ipod in the past it said they couldn't be played, but I figured it was a glitch. E