Quinn-Curtis Forums
Quinn-Curtis Forums
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Tools for Java
 QCRTGraph for Java
 Highlighting part of a waveform in a RTScrollFrame
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

tbarr5072

3 Posts

Posted - 12 Feb 2007 :  09:09:06  Show Profile
Could you please point me in the right direction on how to accomplish the following:
I am plotting a real-time waveform with an RTScrollPane and I need to highlight or change the color of pieces of the waveform as it’s drawn. The color is determined by some meta-data that goes along with the data, so using anything strictly time-series based won’t really serve my purposes.

Any advice on the subject would be greatly appreciated. Thanks!

quinncurtis

1586 Posts

Posted - 12 Feb 2007 :  11:25:38  Show Profile
We did not add direct support for setting unique colors for individual line segments in a scrolling plot because it will slow the drawing of the traces by factor of 10. Anything that breaks up long polyline runs of a single color will slow line drawing drastically. Java graphics is already slow enough.

If you can live with the speed degradation, you can probably use the segment colors of the SimpleLinePlot object attached to the RTSimpleSingleValuePlot. You must set the size of the segment buffer to the maximum number of data points that you collect, so that the buffer is large enough to hold a unique color for every data point you plan to collect. The lineplot1.initSegmentAttributes(attrib1, 1000) call in the example below sets a buffer size of 1000 and sets the default color for each line segment to the colors assigned to attrib1.

You MUST also turn off the FASTCLIP_X flag.

The following codes is a modified version of our ScrollApplication1 example program.


	

// declaration moved outside of the InitializeScrollGraph method so that it can be accessed from the timer1_Tick method
SimpleLinePlot lineplot1;

private void InitializeScrollGraph()
{
  .
  .
  .
 	

  ChartAttribute attrib1 = new ChartAttribute (Color.yellow, 3, ChartConstants.LS_SOLID);
  lineplot1 =  new SimpleLinePlot(pTransform1, null, attrib1);

  // NO FASTCLIP_X
  // lineplot1.setFastClipMode( ChartConstants.FASTCLIP_X);
			
  RTSimpleSingleValuePlot solarPanelLinePlot1 = new RTSimpleSingleValuePlot(pTransform1,lineplot1, currentTemperature1);
  chartVu.addChartObject(solarPanelLinePlot1);		

  ChartAttribute attrib2 = new ChartAttribute (Color.green, 3,ChartConstants.LS_SOLID);
  SimpleLinePlot lineplot2 =  new SimpleLinePlot(pTransform1, null, attrib2);
  lineplot2.setFastClipMode( ChartConstants.FASTCLIP_X);
			
  RTSimpleSingleValuePlot solarPanelLinePlot2 = new RTSimpleSingleValuePlot(pTransform1,lineplot2, currentTemperature2);
  chartVu.addChartObject(solarPanelLinePlot2);		

  // This must be called after the RTSimpleSingleValuePlot call
  lineplot1.initSegmentAttributes(attrib1, 1000);
  .
  .

}

private void timer1_Tick(ActionEvent e)
{
  .
  .
  .

  counter++;


  // Highlight data elements 50 to 89
  if (counter == 100)
  {
    for (int i=0; i < 40; i++)
    {
      lineplot1.setSegmentColor(50 + i, ChartColors.LIGHTBLUE);
    }
  }

  // Highlight data elements 150 to 189
  if (counter == 200)
  {
    for (int i=0; i < 40; i++)
    {
        lineplot1.setSegmentColor(150 + i, ChartColors.LIGHTBLUE);
    }
  }
}	
			

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Quinn-Curtis Forums © 2000-2018 Quinn-Curtis, Inc. Go To Top Of Page
Powered By: Snitz Forums 2000 Version 3.4.07