Drawing a Line between 2 Buttons. Help needed

Folks,
I have created a Layout which has a lot of buttons attached.
What I need is to create a line which seperates the button as
they are quite close to each other?
How do i create a line that will be shown between 2 horizontal buttons.
Button 1
--------------- [ Line]
Button 2
Can any one please answer.

a JSeparator() is something like a "line". but in your example it looks like a horizontal line, not like a vertical line.

Similar Messages

  • How draw a line between two buttons?

    Hi.
    I want to make two movable buttons connected  with a line. When changing position of any button you'll change look of  the line of course.  I know how to draw a line but after MOUSE_DOWN, and  I don't know how to remove an old one line, and how make this line to  be shown all the time?
    My code
    btn2.addEventListener(MouseEvent.MOUSE_DOWN,
    mouseDownHandler3);
    btn2.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler3);
    btn3.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler3);
    btn3.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler3);
    // Define a mouse down handler (user is dragging)
    function mouseDownHandler3(evt:MouseEvent):void {
       var object = evt.target;
       // we should limit dragging to the area inside the canvas
       object.startDrag();
    function mouseUpHandler3(evt:MouseEvent):void {
       var obj = evt.target;
          obj.stopDrag();
          //spisujemy x,y
          var x2Pos:Number = btn2.x;
          var y2Pos:Number = btn2.y;
          var x3Pos:Number = btn3.x;
          var y3Pos:Number = btn3.y;
          trace (x3Pos);
          trace (y3Pos);
          var roundObject:Shape = new Shape();
          roundObject.graphics.lineStyle(2, 0x990000, .75);
          roundObject.graphics.moveTo(x2Pos, y2Pos);
          roundObject.graphics.lineTo(x3Pos, y3Pos);
          this.addChild(roundObject);
          //this.removeChild(this.getChildAt(this.numChildren -1));
    Source .FLA: http://www.mediafire.com/?y2tyzz4zxun

    Here's a solution that you can adapt for two or more buttons....
    var btns:Array = [btn2, btn3]; //instances on stage
    //set btn handlers
    function setBtns():void {
          for(var i=0; i<btns.length; i++) {
                btns[i].buttonMode = true;
                btns[i].addEventListener(MouseEvent.MOUSE_DOWN, grab);
                btns[i].addEventListener(MouseEvent.MOUSE_UP, drop);
    setBtns();
    //draws lines btween all btns while a drag is occurring
    function drawLines(e:Event=null):void {
          graphics.clear();
          graphics.lineStyle(2, 0xFF0000);
          graphics.moveTo(btns[0].x+(btns[0].width/2), btns[0].y+(btns[0].height/2));
          for(var j=btns.length-1; j>=1; j--) {
                graphics.lineTo(btns[j].x+(btns[j].width/2), btns[j].y+(btns[j].height/2));
    //handlers
    function grab(event:MouseEvent):void {
          event.target.startDrag();
          addEventListener(Event.ENTER_FRAME, drawLines);
    function drop(event:MouseEvent):void {
        event.target.stopDrag();
        removeEventListener(Event.ENTER_FRAME, drawLines);
    drawLines();

  • Suggestion to draw a line between two points...

    I have the XYZ position of 2 points, I would like to draw a line between those points. I have tried with a cylinder and it did not work as I expect...I guess a better method exist in Java3D... Do you have any suggestions??
    thanks
    Pete

    try the LineArray class.

  • Simple button help needed!

    I want to make a simple round button that glows when you
    mouse over it and depresses when you click it.
    Apparently to do this I need to use Filters to make the glow
    and bevels. But Filtersonly work on movie clips, buttons and text.
    So I make a circle and convert it into a button symbol
    (Btn1). Then I make another button symbol (Btn2) and use the first
    button symbol (Btn 1) on the Up Over and Down frames of Btn 2.
    Assorted Filters are applied to Btn 1 on the Up Over and Down
    frames to get the effects I want.
    I test the button (Btn2) using Enable Simple Buttons. It
    works perfectly - glows on mouse over and depresses on click. Then
    I try Test Movie -- and the button doesn't work!!!
    Not does it work when exported as a SWF file!!!
    I watched a tutorial video that came with my Flash Pro 8
    Hands-On-Training (HOT) book and he used pretty much the same
    technique -- except he only tested his button with Enable Simple
    Buttons. I'll bet my house his didn't work with Test Movie either!
    The stupid thing, is I was just able to achieve exactly what
    I wanted very quickly using LiveMotion 2!
    What is wrong here? Why is it so impossible to create a glow
    button in Flash? Why has it been easy in Live Motion for years?
    All help appreciated!
    Thanks
    craig

    I thought the nesting button situation might be the problem
    BUT there is no other way to apply Filters to Up, Down, etc. Also,
    a freaking tutorial book described that as a valid method, but
    obviously it ain't.
    I tried using movieclips as well but basically had the same
    problem.
    I mentioned LiveMotion 2 because that ancient program can do
    easily what Flash Pro 8 seems incapable of.
    What is the logic behind not allowing Filters to be applied
    to simple graphics? It's absurd!
    There's got to be a way...

  • Flash project audio button help needed

    Hi,
    I am just learning Actionscript 3 and trying to create buttons that turn a previous sound off before they turn a new one on. Also I want a button on the front that turns all sound off if it is pressed. I have attached my files in a zip folder.
    The problem is all of my buttons which are inside movieclips just control the one sound. I have a couple more to do. I understand I will need an if statement but somehow I have to control all sounds and I don't quite get it.
    I would really love someone to point me in the right direction. I cannot find a tutorial anywhere and am going crazy.
    I look forward to someones reply,
    Jan

    Jay Robinson2 wrote:
    I've just upgraded to Logic 7.2 as I bought an intel Mac. However, for some reason the audio plays through the macs built in speaker. I've got into preferences>audio>drivers and changed the driver to 'built in line input' but it's still playing through the speaker itself. I never had this problem while i was running previous versions on my old mac
    When i boot up logic it does say something that i've never seen before which could be the cause...' Project Manager database on disk has got wrong version. Rescanning required'.
    Any ideas?
    G5 2.8 Quad Mac OS X (10.5.5)
    Hi,
    Try updating to 7.2.3
    As far as the Manager... try doing a new expanded scan, overnight. This will update the database.
    As far as the built in driver... you are selecting an INPUT.... and you expect it to change the OUTPUT??? Again, you are selecting an INPUT, while expecting the OUTPUT to change.
    The Built in drivers have only 1 output available, And in your case, that is working as expected. When you want to RECORD via either input, that is when you change the driver. You should have two choices : Mic, and Line.
    Cheers

  • Moving files between different devices, help needed.

    Hi people, i need some help working this out. I am about to buy a Tablet, it will be my first tablet.
    In a few days the iPad 3 comes out and that would be nice, But...I have 2 old PPC macs, both Running on 10.5.8 and an android Phone. I'm guessing that because the iPad doesn't have a micro SD card slot or a proper usb port, getting files from it to all of my other kit is going to be a big pain. I understand that Apple has finally made iOS5 which i'm told is non computer reliant, so in theory, i can buy an iPad, take it home, turn it on, set it up and use it, without having to connect it to a computer with iTunes on it.
    I am aware that iPad will come with iCloud, but i'm guessing Apple won't allow any of my kit listed above, to access that except maybe a windows computer. I could use bluetooth?
    Is it possible to access files i would store in iCloud from any device, anywhere in the world just by logging in over the internet browser? Or am i going to have to not use iCloud and instead use Google Docs, Dropbox, or some other combination of online storage to move file around, or get a completely diferent tablet.
    I'm also concidering an Asus Transformer Prime Tablet plus docking keyboard as that does have a full sized usb port and a micro SD card slot and a full sized SD card slot as well, plus an extra battery.

    Yes sorry, i missed a bit out. I would use iCloud from the iPad itself, to backup the iPad so that when it crashes i can restore it, but would have to keep a copy of any files in Dropbox, that i might need to share inter platform. As i tend to keep multi backups anyway coz over the years i've had 2 Hard disk failures and 1 memory stick failure. That approach is not too much hasel. Not as elegant as just using one on line storage area but Hey, Big companies are never going to make their stuff work properly with everyone elses, that would be way too idealic. It was hard enough to get them to use standard file formats.
    Thanks again.

  • Multiple Buttons help needed

    Hey everyone,
    I am just beginning to learn the basics of creating web sites in flash.
    I have been following a tutorial and have it done pretty well, but they only cover one main button, and I am at the point where I need several more, but I am doing something wrong.
    The tutorial is at this page: http://www.flash-game-design.com/flash-tutorials/advancedWebsite-flash-tutorial-3.html
    You can skip to the end and download the .fla if you want.
    What I want to do specifically is to add probably 4 other main buttons that can also have drop down menus. Please be as specific as possible because the extent of my code knowledge isn't very far.
    Thanks in advance
    The code for the main page is as follows:
    menu = ["About", "Bio", "Contact"];
    this.createEmptyMovieClip("content", 1000);
    this.attachMovie("sectionBackground","mask",1001);
    mask._y = content._y=208;
    mask._x = target=68;
    content.setMask(mask);
    content._x = -1000;
    imageScrollSpeed = 5;
    xStart = 125;
    yStart = 51;
    bWidth = 79;
    bHeight = 17;
    interval = 50;
    countDown = menu.length;
    menuOpen = false;
    theTime = 0;
    buttonScrollSpeed = 2;
    for (var i = 0; i<menu.length; i++) {
    var section = content.attachMovie("section_"+menu[i], "section_"+menu[i], i+100);
    section._x = section._width*i;
    var b = this.attachMovie("subButton", "subButton"+i, countDown);
    countDown--;
    b.stop();
    b._x = xStart;
    b._y = ySwtart;
    b.interval = interval*i;
    b.target = yStart+(bHeight*i);
    b.txt = menu[i];
    b.pos = target+(i*-section._width);
    b.onPress = function() {
      target = this.pos;
      closeMenu();
      this.gotoAndStop(1);
    b.onRollOver = function() {
      this.gotoAndStop(2);
    b.onRollOut = function() {
      this.gotoAndStop(1);
    b._visible = false;
    function closeMenu() {
    for (var i = 0; i<menu.length; i++) {
      var b = this["subButton"+i];
      b._visible = false;
      b._x = xStart;
      b._y = yStart;
    menuOpen = false;
    mainButton.onPress = function() {
    if (!menuOpen) {
      theTime = getTimer();
      menuOpen = true;
      for (var i = 0; i<menu.length; i++) {
       _root.main["subButton"+i]._visible = true;
    } else {
      closeMenu();
    mainButtoncopy.onPress = function() {
    if (!menuOpen) {
      theTime = getTimer();
      menuOpen = true;
      for (var i = 0; i<menu.length; i++) {
       _root.main["subButton"+i]._visible = true;
    } else {
      closeMenu();
    function scrollButtons() {
    if (menuOpen) {
      for (var i = 0; i<menu.length; i++) {
       var b = this["subButton"+i];
       if ((theTime+b.interval)<getTimer()) {
        b._y += (b.target-b._y)/buttonScrollSpeed;
    this.onEnterFrame = function() {
    content._x += (target-content._x)/imageScrollSpeed;
    scrollButtons();

    I still really need help on this

  • AWT start/stop bundle buttons Help needed.

    Hello,
    I need help getting start/stop buttons on my AWT Class to take the action of methods from an other class. I will give anybody who can figure this out ALL OF MY Duke Dollars. (I shortend it up to the important stuff so that there isn't too much to read):
    MY PROBLEM: I need to have my Gui user interface to start up first. Then when somebody clicks the Gui class "start" button, it will call the start method of my Activator class and similiarly for the "stop" button. When I run the program, it starts up already in "start" mode. It should start up without getting the service (stop mode) and then get it once "start" is pressed" Hopefully somebody can help me figure this out.
    First, I have the following AWT class
    public class Gui extends Frame{
          Frame f;
          MyImage imagePanel;
          Button button_start;
          Button button_stop;
          Label statusBar;
          Panel btns;
        public Gui() {
            addWindowListener(new WinClosing());
            setLayout(new BorderLayout());
            imagePanel = new MyImage();
            btns = new Panel();
            button_start  = new Button("START");
            button_stop  = new Button("STOP");
            btns.add(button_start);
            btns.add(button_stop);
            add("North", btns);
            add("Center",imagePanel);       
            button_start.addActionListener(new ActionListener(){     
                public void actionPerformed( ActionEvent e ){
                    imagePanel.getImage();
            button_stop.addActionListener(new ActionListener(){     
                public void actionPerformed( ActionEvent e ){
                imagePanel.closeImage();}
            });          }Then I have the Activator class:
    public class Activator implements BundleActivator {
         public ServiceReference reference;
         public void start(BundleContext bc) {
             reference = bc.getServiceReference(GpsService.SERVICE_NAME);
             if (reference == null) {
             System.out.println("User could not get a service.");
              } else {
             AnyService anything = (AnyService) bc.getService(reference);
                    UserClass user = new UserClass();
                    user.startup(anything);
    public void stop(BundleContext bc) {
        if (reference != null) {
        bc.ungetService(reference);
        reference = null;
        System.out.println("User has released its Service.");
        } }}Then this previous class calls the startup method for this class:
    public class Driver {
            public void startup(AnyService any){
            double any  = any.getValue();
            System.out.println(any);
            Gui g = new Gui(any);
            g.setSize(714, 480);
            g.setVisible(true); 
          }}Thanks in advance!

    Hmm, it's quite hard to imagine what's going on without the code for MyImage. However, I guess you need to add an ActionListener to your two buttons. Are you sure you need two buttons, though? Presumably you can't stop until you've started and vice versa?
    private Activator activator;
    private Button startButton;
    private Button stopButton
    public Gui()
      startButton = new Button("Start");
      stopButton = new Button("Stop");
      stopButton.setEnabled(false);
      startButton.addActionListener(new ActionListener()
        public void actionPerformed(ActionEvent e)
          start();
      stopButton.addActionListener(new ActionListener()
        public void actionPerformed(ActionEvent e)
          stop();
    private synchronized void start()
      // Construct the Activator when we need it
      if(activator == null)
        activator = new Activator();
      activator.start(...); // Don't know where you get your BundleContext from!
      startButton.setEnabled(false);
      stopButton.setEnabled(true);
    private synchronized void stop()
      activator.stop(...); // Don't know where you get your BundleContext from!
      startButton.setEnabled(true);
      stopButton.setEnabled(false);
    }I'm assuming here that once the Activator is "started" is stays started until it is told to stop, ie, it doesn't stop itself after a finite amount of time.
    Hope this helps.

  • FLV custom UI buttons help needed

    Hello everyone,
    I have been searching Google for a few hours trying to find a
    good tutorial for a beginner(myself) on how to add Custom UI
    components and control and FLV file in AS 3.0. (I am running across
    plenty of AS 2.0 tutorials) The reason being I want to play an FLV
    in my SWF with only a Play/Pause button and a Mute button and do
    not want to be limited to the positions of the flvPlayback
    component skins.. I would use the flvPlayback component with the
    custom skins but the controls get in the way of my reflection (I am
    using the Pixelfumes AS 3.0 reflection class) and autohide is not
    an option for me right now.
    So what I have done so far is created my FLV
    Created my .FLA
    Within the .FLA I dragged the flvPlayback component to the
    stage and gave it an instance name of video
    I chose "none" for the skin
    I then converted this into a MC with an instance name of
    video_mc.
    I created a new layer and added a PlayPause button from the
    components panel
    I created a new layer and added a Mute button from the
    components panel
    I created a new actionscript layer and added the following
    (this is for the reflection)
    (See attached code)
    Now I am stuck. I don't know how to get the buttons to
    control the flv in AS 3 to play, pause and mute. Can someone help
    me out and point me to a AS 3 tutorial or perhaps give me the code
    I need to input?
    Thank you very much,
    Mark

    Hello everyone,
    I have been searching Google for a few hours trying to find a
    good tutorial for a beginner(myself) on how to add Custom UI
    components and control and FLV file in AS 3.0. (I am running across
    plenty of AS 2.0 tutorials) The reason being I want to play an FLV
    in my SWF with only a Play/Pause button and a Mute button and do
    not want to be limited to the positions of the flvPlayback
    component skins.. I would use the flvPlayback component with the
    custom skins but the controls get in the way of my reflection (I am
    using the Pixelfumes AS 3.0 reflection class) and autohide is not
    an option for me right now.
    So what I have done so far is created my FLV
    Created my .FLA
    Within the .FLA I dragged the flvPlayback component to the
    stage and gave it an instance name of video
    I chose "none" for the skin
    I then converted this into a MC with an instance name of
    video_mc.
    I created a new layer and added a PlayPause button from the
    components panel
    I created a new layer and added a Mute button from the
    components panel
    I created a new actionscript layer and added the following
    (this is for the reflection)
    (See attached code)
    Now I am stuck. I don't know how to get the buttons to
    control the flv in AS 3 to play, pause and mute. Can someone help
    me out and point me to a AS 3 tutorial or perhaps give me the code
    I need to input?
    Thank you very much,
    Mark

  • Drawing small, short curves in Photoshop draws straight line between start and end points

    I recently installed Windows 8 Professional, Photoshop and the latest Wacom Bamboo tablet drivers and have been experiencing this issue. I've turned off windows flicks and ink. This only happens in Photoshop with the brush tool and I can't seem to find a setting that this corresponds to.
    Basically, when I draw small, short curves (particularly letters like 'c' and 'h'), when I lift up my pen, Photoshop automatically connects the end and start points together with a straight line ('c' almost becomes 'o' or 'a'). I'm not holding the shift or any modifier keys. I've tried googling this issue, but I have no idea how to phrase it properly to get any results.
    Here's an image of what I'm talking about (the top was drawn with the pencil tool, the bottom with the brush tool which demonstrates the issue. I've highlighted the start and end points with red dots):
    ANy ideas? :/

    Is caps lock on?

  • PayPal button help needed

    I have inserted the PayPal code as an HTML snippet in my website and the buttons look fine. When I click on them on the published site, Safari quits. Is there something I'm doing wrong?

    Your problem may be with Safari. A lot of people are experiencing random crashes...
    http://www.macfixit.com/article.php?story=20071221101855547
    The latest security update - yesterday - is supposed to fix it....
    http://www.macfixit.com/article.php?story=20071222105253236

  • Difference between the queries - help needed.

    I have three tables Plan_Zip,Service_Zip,Plan_Info
    Plan_Zip is the parent table and referenced by Service_Zip
    and Service_Zip is referenced by Plan_Info.
    I have this query:
    select
         sz.ts_nbr,pz.packages_qty,pz.stops_qty
    from
         plan_zip pz, service_zip sz, plan_info pi
    where
         pi.plan_run_nbr = sz.plan_run_nbr and
         sz.service_run_nbr = pz.service_run_nbr and     
         pi.day_plan_nbr = 43027 and
         pi.run_type_nbr = 0 and
         sz.ts_nbr = 1 or sz.ts_nbr = 2
    When I am running the query I am getting so many rows which are identical,
    but when I modified the above query as:
    select
         sz.ts_nbr,pz.packages_qty,pz.stops_qty
    from
         plan_zip pz, service_zip sz, plan_info pi
    where
         pi.plan_run_nbr = sz.plan_run_nbr and
         sz.service_run_nbr = pz.service_run_nbr and     
         pi.day_plan_nbr = 43027 and
         pi.run_type_nbr = 0 and
         (sz.ts_nbr = 1 or sz.ts_nbr = 2)
    I am getting the correct results.
    Please explain me the difference between the above two queries.
    Regards
    Raghu

    Look at the below example
    SQL> create table t
      2  as
      3  select level no, level no1, 0 no2
      4    from dual
      5  connect by level <= 5
      6  /
    Table created.
    SQL> select * from t
      2  /
            NO        NO1        NO2
             1          1          0
             2          2          0
             3          3          0
             4          4          0
             5          5          0
    SQL> select *
      2    from t
      3   where no = 1
      4     and no1 = 1
      5      or no2 = 0
      6  /
            NO        NO1        NO2
             1          1          0
             2          2          0
             3          3          0
             4          4          0
             5          5          0Here what the where condition is telling is no should be 1, no1 should be 1 or no2 is 0. you can read it like this.
    if (no = 1 and no1 = 1) or (no2 = 0)
    then
         true ;
    else
         false;
    end if;so what i does is no2 = 0 is satisfied by all the rows and hence all the rows are returned.
    Next...
    SQL> select *
      2    from t
      3   where no = 1
      4     and (no1 = 1 or no2 = 0)
      5  /
            NO        NO1        NO2
             1          1          0This can be read like this.
    if (no = 1) and (no1 = 1 or no2 = 0)
    then
         true ;
    else
         false;
    end if;Here no = 1 is a must satisfy condition. Once that is satisfied then no1 can be 1 or no2 can be 0 which ever is
    satisfied consider that. So the first condition no=1 is satisfied by only one record and hence that alone is returned.
    Thanks,
    Karthick.

  • Draw line between black pixel : coordinates of selected pixels ?

    Hi
    I want to build a script which can check a Photoshop file and :
    - find black pixel
    - for each black pixel, look for another black pixel within maximum distance of 5 pixels
    - then draw a line between the two black pixels.
    I wrote this script below (my first script ...), but it's VERY slow (and my final image is VERY big), I think because I test the colour for each pixel of the image.
    So another solution would be to first select black pixel with magic wand, then the script save all coordinates of selected pixels, then my script wil test only this pixels (less than 1% of the pixels are black in my image).
    Is it possible with JavaScript ?
    Thank you for your response !
    Marc
    function main(){
    var startRulerUnits = app.preferences.rulerUnits;
    app.preferences.rulerUnits = Units.PIXELS;
    var myHeight = app.activeDocument.height;
    var myWidth = app.activeDocument.width;
    // Find black pixel
    for(var i=5; i<myWidth; i++) {
      for(var j=5; j<myHeight; j++) {
       activeDocument.colorSamplers.removeAll()
       var sampler = activeDocument.colorSamplers.add([new UnitValue (i, 'px'), new UnitValue (j, 'px')]);
       if (sampler.color.rgb.hexValue === "000000") {
    // For each black pixel, search another black pixel below left up to 5 pixels
        for (var m=i-5; m<i; m++) {
         for (var n=j+1; n<j+5; n++) {
          activeDocument.colorSamplers.removeAll()
          var test = activeDocument.colorSamplers.add([new UnitValue (m, 'px'), new UnitValue (n, 'px')]);
          if (test.color.rgb.hexValue === "000000") {
    // Then draw a black line between the two black pixels
           var FillColour = new SolidColor;
           FillColour.rgb.hexValue = '000000';
           var ad=activeDocument;
           ad.selection.select([[m,n],[i,j],[m,n+1],[i,j+1]], SelectionType.REPLACE, 0, true);
           ad.selection.fill(FillColour);
           ad.selection.deselect()
    // For each black pixel, search another black pixel below right up to 5 pixels
         for (var m=i+1; m<i+5; m++) {
          for (var n=j; n<j+5; n++) {
           activeDocument.colorSamplers.removeAll()
           var test = activeDocument.colorSamplers.add([new UnitValue (m, 'px'), new UnitValue (n, 'px')]);
           if (test.color.rgb.hexValue === "000000") {
    // Then draw a black line between the two black pixels
            var FillColour = new SolidColor;
            FillColour.rgb.hexValue = '000000';
            var ad=activeDocument;
            ad.selection.select([[i,j],[m,n],[m,n+1],[i,j+1]], SelectionType.REPLACE, 0, true);
            ad.selection.fill(FillColour);
            ad.selection.deselect()
    main();

    The first alert should have shown the first pathPoint.anchors for all the subPaths in the path.
    The xyArray is just something I added for the alerts. The array 'myPathInfo' should have all the info extracted from the path.
    myPathInfo.length will tell you how many subPaths are in the Path.
    myPathInfo[index].entireSubPath.length will tell you how many pathPoints are in that subPath
    myPathInfo[index].entireSubPath[index].anchor will tell you the position of that pathPoint.
    The indexes start with zero.
    The bounding box of the entire subPath can be hard to work out just from the pathPoints. Unless all the point are corner points the path may extend beyond the anchors. One think you can do is create a new path from just one of the subPaths, convert by to a selection, and then get the bounds from the selection. You can make a new path from a subPath using the 'myPathInfo' array from above.
    app.activeDocument.pathItems.add("myPath1", [myPathInfo[0]]);
    That line will make a new path from the first subPath. Change the index to use a different subPath.
    Some other info that may help.
    app.activeDocument.histogram[0] will tell you how may black pixels are in the document. But its no help determining where they are. If that returns 0 there are no black pixels.
    If you don't have any luck working with converting the original color range selection into a path and need to go back to searching with the colorSampler it may help to use a grid approach. For example make a square selection, the size depending on how scattered the black pixels are, say 25x25px. Then use color range to select black. With an active selection it will only select pixels in that selected area( if any). You could then check to see if there is a selection. If not make another same size square to the right edge of the last area. If there is a selection, the solid property will tell you if more than one black pixel was selected( unless they are right next to each other ). If solid == true the selection bounds will tell you where the pixel is. If false you have to then search that square. But if there are areas where there are no black pixels checking a square range of pixels at once should be quite a bit faster than checking every pixel. And checking the historgram first will let you know if you should bother searching to start with.

  • Custom Control Help: Draw a line and output start and end points

    I'm looking to find or make a custom control (or simple subVI) that will appear as a 100x100 unit grid and allow me to draw a line from one point to another on that grid. It will then output the (x,y) of the starting and end point of that line on the grid.  Any help or ideas?
    Thanks,
    Steve
    LabVIEW 2009 SP1
    Solved!
    Go to Solution.

    What you basically want is a loop with an event structure where you process Mouse Down, Move and Up events for your controls. There are any number of ways of implementing something like this, but this one will probably be the simplest:
    Use a multicolumn listbox or a table for your grid. Hide the scrollbars and headers.
    You can use the ActiveCell property with -2,-2 to select all cells. You can then use the cell size property to set the exact size of the cell.
    Next, you put a picture control on top of the table and color its background transparent so that the table shows through. You use property node to make sure the two are aligned to exactly the same spot and size.
    You use the mouse events on the picture control to detect the clicks and moves.
    You use the table's Point to Row Column method to translate the event's position data to a cell.
    You use the picture control VIs to draw the line on the picture based on that data.
    You can even color the selected cells in the table using the table properties.
    If you want to simplify things somewhat, you can also use the timeout event instead of the Mouse Move event to draw the line, but then you'll need to keep the timeout value in a shift register and reset it to -1 (no timeout) when the Mouse Up event happens.
    I would also suggest processing Mouse Enter and Leave events to change the cursor and cancel if the user leaves in the middle of dragging.
    Try to take over the world!

  • Help needed with arraylists

    I am trying to do the following:
    Class Polygon, which takes as parameter a set of Point objects (passed to it by means of an ArrayList of Point objects), and has a method for displaying the polygon on a canvas (the polygon need not be closed, i.e. its first and last points need not have the same coordinates; the canvas may be passed to the class or to the method).
    I have the following code:
    Point.java:
    * Point.java
    * Defines the base class for the drawing exercises
    package csc812;
    import drawing.*;
    class Point
    private int m_iXValue;
    private int m_iYValue;
    // Default constructor
    public Point()
    this.m_iXValue = 0;
    this.m_iYValue = 0;
    // values constructor
    public Point(int x,int y)
    this.m_iXValue = x;
    this.m_iYValue = y;
    // Copy constructor
    public Point(Point P)
    this.m_iXValue = P.m_iXValue;
    this.m_iYValue = P.m_iYValue;
    // Calculates the distance between this and a given point
    public double distance(Point p)
    return Math.sqrt((m_iXValue-p.m_iXValue)*(m_iXValue-p.m_iXValue) +
    (m_iYValue-p.m_iYValue)*(m_iYValue-p.m_iYValue));
    // Draws a line between this and the given point
    public void DrawLine(Point p,Canvas c)
    c.drawLine(m_iXValue,m_iYValue,p.m_iXValue,p.m_iYValue);
    // Outputs the coordinates - primarily for debugging
    public void dump()
    System.out.println("(" + m_iXValue + "," + m_iYValue + ")");
    Polygon.java:
    * Polygon.java
    * This class uses the Point class to draw a polygon based on the
    given points
    * One critical assumption we make is that element 0 of the array list
    is the
    * starting point of the drawing
    package csc812;
    import java.lang.*;
    import java.util.*;
    import java.awt.Color;
    import drawing.*;
    import csc812.Point;
    class Polygon extends Point
    // Declare an ArrayList, since we cannot predetermine how many
    elements we will have
    private ArrayList m_List;
    // foreground colour is part of the polygon
    private Color m_ForeColour;
    // Default constructor
    public Polygon()
    m_List = new ArrayList();
    m_ForeColour = Color.BLACK;
    // Constructor
    public Polygon(ArrayList List,Color cl)
    if (List.contains(Point))
    m_List = new ArrayList();
    m_List = List;
    else
    System.out.println("Polygon constructor error");
    System.out.println("The ArrayList passed is not of type Point, so
    cannot construct object");
    m_ForeColour = cl;
    // Copy constructor
    public Polygon(Polygon p)
    m_List = new ArrayList();
    m_List = p.m_List;
    m_ForeColour = p.m_ForeColour;
    // Draws the polygon
    public void Display(Canvas c)
    // Declare array for use
    Point [] pArray = new Point[m_List.size()];
    pArray = m_List.toArray();
    c.setForegroundColor(m_ForeColour);
    for (int i = 0;i < pArray.length;i++)
    try
    Point p1 = new Point(pArray);
    Point p2 = new Point(pArray[i+1]);
    p1.DrawLine(p2,g);
    catch(ArrayIndexOutOfBoundsException e)
    break;
    // Sets foreground colour
    public void SetColour(Color f)
    m_ForeColour = f;
    // Output for debugging
    public void Dump()
    // Declare array for use
    Point [] pArray = new Point[m_List.size()];
    pArray = m_List.toArray();
    for (int i = 0;i < pArray.length;i++)
    Point p = new Point(pArray[i]);
    p.Dump();
    I can't seem to get this to work, I think I'm close to being correct but can anyone help me get it right?
    Thanks,
    Andy

    In general, you should not name an object the same name as a class. List is an interface in package java.util. So, you should name your ArrayList something like myList, or aList, or theStupidFarkingList. And when you call a method, you must match the type of object you are passing in (the argument) to the type declared in the method (the parameter).
    � {�                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

Maybe you are looking for