3 Replies Latest reply: Jun 18, 2013 3:17 PM by James_D RSS

    How can I override addAll method in LineChart ?

    famedoro

      Hi,

      I need to add some statement when the methods add or addAll are invoked in linechart. How can I do ?

       

      I thought to do an override of the method, like this


      public boolean addAll(Collection<? extends E> es) {   

              return super.addAll(es);

       

              <  ..some new statement... >

        }

       

      but something is wrong.



        • 1. Re: How can I override addAll method in LineChart ?
          James_D

          'return' returns immediately from your method, so the remaining statements can't be reached. Do

           

          public boolean addAll(Collection<? extends E> es) {   
                  //<  ..some new statement... >
                  return super.addAll(es);
          }
          

           

          or

          public boolean addAll(Collection<? extends E> es) {   
                  boolean result =  super.addAll(es);
                  // <  ..some new statement... >
                  return result ;
            }
          
          • 2. Re: How can I override addAll method in LineChart ?
            shakir.gusaroff

            Instead of overriding  the methods  add() and adAll()  you may want to add a listener:

            [code]

             

                    lineChart.getData().addListener(new ListChangeListener<Series>() {

                        public void onChanged(ListChangeListener.Change<? extends Series> c) {

             

                           //       <  ..some new statement... >

             

                        }

                    });

            [/code]  

            • 3. Re: How can I override addAll method in LineChart ?
              James_D

              Yeah, actually LineChart doesn't have an addAll(...) method. You can't override something that doesn't exist. If you're referring to the series' addAll method, register a listener as Shakir suggests.