title: JFreeChart - XYLineAndShapeRenderer getItemLineVisible() not working
body: <p>I'm simulating dummy real-time data using DynamicTimeSeriesCollection, like <a href="https://stackoverflow.com/a/5048863/230513">this</a>. During random intervals, the data being passed to the plot should 'dropout' to simulate a network connection loss. At this point, this plot should stop drawing and only start plotting the data after the dropout has subsided.</p>
  <p>I subclassed <code>XYLineAndShapeRenderer</code> and overrode the <code>getItemLineVisible()</code> method:</p>
  <pre><code>@Override
          public boolean getItemLineVisible(int series, int item){
              if(offline){
                  return false;
              }else{
                  return true;
              }
          }
  </code></pre>
  <p>However when offline is true, all points are still being drawn on the graph.</p>
  <pre><code>public class Test extends ApplicationFrame {
  
      private static final String TITLE = &quot;Dynamic Series&quot;;
      private static final String START = &quot;Start&quot;;
      private static final String STOP = &quot;Stop&quot;;
      private static final int COUNT = 1000*60;
      private static final int FAST = 1; //1000/FAST = occurrences per second real time
      private static final int REALTIME = FAST * 1000;
      private static final Random random = new Random();
      private static final double threshold = 35;
      private double gateStart = ThreadLocalRandom.current().nextInt(0, 101);
      private boolean returning = false;
      private boolean offline = false;
      private Timer timer;
      private Calendar startDate;
      private static final int simulationSpeed = 1000/FAST;
      private final TimeSeries seriesA = new TimeSeries(&quot;A&quot;);
  
      public Test(final String title) throws ParseException {
          super(title);
  
          SimpleDateFormat formatter = new SimpleDateFormat(&quot;dd/mm/yyyy HH:mm&quot;, Locale.ENGLISH);
          PriceParser parser = new PriceParser();
          List&lt;List&lt;String&gt;&gt; priceData = parser.parse();
          Date date = formatter.parse(priceData.get(0).get(0));
          startDate = Calendar.getInstance();
          startDate.setTime(date);
          Calendar timeBaseStartDate = Calendar.getInstance();
          timeBaseStartDate.setTime(startDate.getTime());
          timeBaseStartDate.add(Calendar.SECOND, -COUNT);
          final TimeSeriesCollection dataset = new TimeSeriesCollection();
          dataset.addSeries(this.seriesA);
  
          JFreeChart chart = createChart(dataset);
          final JComboBox combo = new JComboBox();
          combo.addItem(&quot;Fast&quot;);
          combo.addItem(&quot;Real-time&quot;);
          combo.addActionListener(new ActionListener() {
              @Override
              public void actionPerformed(ActionEvent e) {
                  if (&quot;Fast&quot;.equals(combo.getSelectedItem())) {
                      timer.setDelay(FAST);
                  } else {
                      timer.setDelay(REALTIME);
                  }
              }
          });
  
          JFrame frame = new JFrame(&quot;Test&quot;);
          JLabel label = new JLabel(&quot;Network connectivity lost.&quot;);
  
          this.add(new ChartPanel(chart), BorderLayout.CENTER);
          JPanel btnPanel = new JPanel(new FlowLayout());
          btnPanel.add(combo);
          JPanel test = new JPanel();
          test.add(label);
          this.add(btnPanel, BorderLayout.SOUTH);
  
          // frame.add(btnPanel);
          //frame.add(test);
  
          timer = new Timer(FAST, new ActionListener() {
              Date timeToCheck = formatter.parse(priceData.get(0).get(0));
              Calendar pauseResume = Calendar.getInstance();
              Calendar offlineTime = Calendar.getInstance();
              boolean paused = false;
              boolean waiting = false;
              //boolean offline = false;
              double currentPrice;
              float[] newData = new float[1];
              PopupFactory pf = PopupFactory.getSharedInstance();
              Popup popup;
  
              @Override
              public void actionPerformed(ActionEvent e) {
                  Date datasetTime = new Date();
                  if(offline){
                      System.out.println(&quot;Offline: &quot;+offlineTime.getTime());
                      System.out.println(&quot;Current: &quot;+datasetTime);
                      if(offlineTime.getTime().compareTo(datasetTime) == 0){
                          offline = false;
                          System.out.println(&quot;Im no longer offline&quot;);
                          popup.hide();
                      }
                  }
  
                  if(ThreadLocalRandom.current().nextInt(0, 1001) &gt; 999 &amp;&amp; !offline){
                      offline = true;
                      offlineTime.setTime(datasetTime);
                      offlineTime.add(Calendar.SECOND, ThreadLocalRandom.current().nextInt(1, 5)*10);
  
  //                    dataset.addValue(0, 0, null);
                      popup = pf.getPopup(btnPanel, label, 900, 300);
                      popup.show();
                  }
  
                  if(timeToCheck.compareTo(datasetTime) == 0){
                      currentPrice = Double.valueOf(priceData.get(0).get(1));
                      paused = currentPrice &gt;= threshold;
                      priceData.remove(0);
                      try {
                          timeToCheck = formatter.parse(priceData.get(0).get(0));
                      } catch (ParseException ex) {
                          ex.printStackTrace();
                      }
                  }
  
                  if(!paused) {
                      if (Math.round(gateStart) * 10 / 10.0 == 100d) {
                          returning = true;
                      } else if (Math.round(gateStart) * 10 / 10.0 == 0) {
                          returning = false;
                      }
                      if (returning) {
                          gateStart -= 0.1d;
                      } else {
                          gateStart += 0.1d;
                      }
                  }else{
                      if(datasetTime.compareTo(pauseResume.getTime()) == 0 &amp;&amp; currentPrice &lt; threshold){
                          paused = false;
                          waiting = false;
                      }else{
                          if(Math.round(gateStart)*10/10.0 == 0 || Math.round(gateStart)*10/10.0 == 100){
                              if(!waiting){
                                  pauseResume.setTime(datasetTime);
                                  pauseResume.add(Calendar.SECOND, 120);
                              }
                              waiting = true;
                          }else{
                              if(Math.round(gateStart)*10/10.0 &gt;= 50){
                                  gateStart += 0.1d;
                              }else if(Math.round(gateStart)*10/10.0 &lt; 50){
                                  gateStart -= 0.1d;
                              }
                          }
                      }
                  }
                  newData[0] = (float)gateStart;
                  seriesA.addOrUpdate(new Second(), gateStart);
              }
          });
      }
  
      private JFreeChart createChart(final XYDataset dataset) {
          final JFreeChart result = ChartFactory.createTimeSeriesChart(
                  TITLE, &quot;Time&quot;, &quot;Shearer Position&quot;, dataset, true, true, false);
          final XYPlot plot = result.getXYPlot();
          plot.setDomainZeroBaselineVisible(false);
          XYLineAndShapeRendererTest renderer = new XYLineAndShapeRendererTest(true, false);
          plot.setRenderer(renderer);
          DateAxis domain = (DateAxis)plot.getDomainAxis();
  
          Calendar endDate = Calendar.getInstance();
          endDate.setTime(new Date());
          endDate.add(Calendar.HOUR_OF_DAY, 12);
          System.out.println(new Date());
          System.out.println(endDate.getTime());
          domain.setRange(new Date(), endDate.getTime());
          domain.setTickUnit(new DateTickUnit(DateTickUnitType.HOUR, 1));
          domain.setDateFormatOverride(new SimpleDateFormat(&quot;HH:mm&quot;));
  
          ValueAxis range = plot.getRangeAxis();
          range.setRange(0, 100);
  
          return result;
      }
  
      private class XYLineAndShapeRendererTest extends XYLineAndShapeRenderer {
  
          private boolean drawSeriesLineAsPath;
  
          public XYLineAndShapeRendererTest(boolean line, boolean shapes){
              super(line, shapes);
          }
  
          @Override
          public Paint getItemPaint(int row, int col) {
              if(!offline){
                  return super.getItemPaint(row, col);
              }else{
                  return new Color(0, 0, 0);
              }
  
          }
      }
  
      private void start() {
          timer.start();
      }
  
      public static void main(final String[] args) {
          EventQueue.invokeLater(new Runnable() {
              @Override
              public void run() {
                  Test demo = null; //pass date in from csv
                  try {
                      demo = new Test(TITLE);
                  } catch (ParseException e) {
                      e.printStackTrace();
                  }
                  demo.pack();
                  RefineryUtilities.centerFrameOnScreen(demo);
                  demo.setVisible(true);
                  demo.start();
              }
          });
      }
  }
  </code></pre>
  <p>What am I doing wrong?</p>