< prev index next >

modules/controls/src/test/java/javafx/scene/chart/StackedAreaChartTest.java

Print this page
rev 8907 : RT-46086: StackedAreaChart doesn't fade out removed series


   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package javafx.scene.chart;
  27 
  28 
  29 import com.sun.javafx.scene.control.infrastructure.ControlTestUtils;
  30 import java.io.IOException;
  31 import java.io.OutputStream;
  32 import java.io.PrintStream;
  33 import org.junit.Test;
  34 import static org.junit.Assert.assertEquals;
  35 import javafx.collections.*;
  36 
  37 
  38 import javafx.scene.Node;
  39 import javafx.scene.Group;
  40 import javafx.scene.shape.*;
  41 import static org.junit.Assert.assertTrue;
  42 
  43 import org.junit.Ignore;
  44 
  45 
  46 public class StackedAreaChartTest extends XYChartTestBase {
  47     StackedAreaChart<Number,Number> ac;
  48     final XYChart.Series<Number, Number> series1 = new XYChart.Series<Number, Number>();
  49     boolean useCategoryAxis = false;
  50     final String[] countries = {"USA", "Italy", "France", "China", "India"};
  51     protected Chart createChart() {
  52         final NumberAxis yAxis = new NumberAxis();
  53         ObservableList<XYChart.Data> data = FXCollections.observableArrayList();
  54         Axis xAxis;
  55         if (useCategoryAxis) {
  56             xAxis = new CategoryAxis();
  57             ((CategoryAxis)xAxis).setCategories(FXCollections.observableArrayList(countries));
  58             // add starting data
  59         series1.getData().add(new XYChart.Data(countries[0], 10d));
  60         series1.getData().add(new XYChart.Data(countries[1], 20d));
  61         series1.getData().add(new XYChart.Data(countries[2], 15d));
  62         series1.getData().add(new XYChart.Data(countries[3], 15d));
  63         series1.getData().add(new XYChart.Data(countries[4], 10d));
  64         } else {


  95         }
  96         return sb;
  97     }
  98     
  99     @Test @Ignore("pending RT-28373")
 100     public void testSeriesAdd() {
 101         startApp();
 102         ac.getData().addAll(series1);
 103         pulse();
 104         StringBuffer sb = getSeriesLineFromPlot();
 105 //        assertEquals("L220.0 59.0 L264.0 175.0 L440.0 175.0 L704.0 291.0 ", sb.toString());
 106         assertEquals("L219.0 58.0 L263.0 173.0 L438.0 173.0 L700.0 289.0 ", sb.toString());
 107     
 108     }
 109     
 110     @Test
 111     public void testSeriesRemove() {
 112         startApp();
 113         ac.getData().addAll(series1);
 114         pulse();
 115         if (!ac.getData().isEmpty()) {

 116             ac.getData().remove(0);
 117             pulse();
 118             StringBuffer sb = getSeriesLineFromPlot();
 119             assertEquals(sb.toString(), "");





























 120         }





 121     }
 122     
 123     @Test @Ignore
 124     public void testDataItemRemove() {
 125         startApp();
 126         ac.getData().addAll(series1);
 127         pulse();
 128         if (!ac.getData().isEmpty()) {
 129             series1.getData().remove(0);
 130             pulse();
 131             StringBuffer sb = getSeriesLineFromPlot();
 132             assertEquals(sb.toString(), "L247.0 171.0 L412.0 171.0 L658.0 284.0 ");
 133         }
 134     }
 135     
 136     @Test @Ignore
 137     public void testDataItemAdd() {
 138         startApp();
 139         ac.getData().addAll(series1);
 140         pulse();




   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package javafx.scene.chart;
  27 

  28 import com.sun.javafx.scene.control.infrastructure.ControlTestUtils;
  29 import javafx.collections.FXCollections;
  30 import javafx.collections.ObservableList;







  31 import javafx.scene.Group;
  32 import javafx.scene.Node;
  33 import javafx.scene.shape.Path;
  34 import static org.junit.Assert.assertEquals;
  35 import org.junit.Ignore;
  36 import org.junit.Test;
  37 
  38 public class StackedAreaChartTest extends XYChartTestBase {
  39     StackedAreaChart<Number,Number> ac;
  40     final XYChart.Series<Number, Number> series1 = new XYChart.Series<Number, Number>();
  41     boolean useCategoryAxis = false;
  42     final String[] countries = {"USA", "Italy", "France", "China", "India"};
  43     protected Chart createChart() {
  44         final NumberAxis yAxis = new NumberAxis();
  45         ObservableList<XYChart.Data> data = FXCollections.observableArrayList();
  46         Axis xAxis;
  47         if (useCategoryAxis) {
  48             xAxis = new CategoryAxis();
  49             ((CategoryAxis)xAxis).setCategories(FXCollections.observableArrayList(countries));
  50             // add starting data
  51         series1.getData().add(new XYChart.Data(countries[0], 10d));
  52         series1.getData().add(new XYChart.Data(countries[1], 20d));
  53         series1.getData().add(new XYChart.Data(countries[2], 15d));
  54         series1.getData().add(new XYChart.Data(countries[3], 15d));
  55         series1.getData().add(new XYChart.Data(countries[4], 10d));
  56         } else {


  87         }
  88         return sb;
  89     }
  90     
  91     @Test @Ignore("pending RT-28373")
  92     public void testSeriesAdd() {
  93         startApp();
  94         ac.getData().addAll(series1);
  95         pulse();
  96         StringBuffer sb = getSeriesLineFromPlot();
  97 //        assertEquals("L220.0 59.0 L264.0 175.0 L440.0 175.0 L704.0 291.0 ", sb.toString());
  98         assertEquals("L219.0 58.0 L263.0 173.0 L438.0 173.0 L700.0 289.0 ", sb.toString());
  99     
 100     }
 101 
 102     @Test
 103     public void testSeriesRemove() {
 104         startApp();
 105         ac.getData().addAll(series1);
 106         pulse();
 107         // 5 symbols and 1 area group
 108         assertEquals(6, ac.getPlotChildren().size());
 109         ac.getData().remove(0);
 110         pulse();
 111         assertEquals(0, ac.getPlotChildren().size());
 112     }
 113 
 114     @Test
 115     public void testSeriesRemoveWithoutSymbols() {
 116         startApp();
 117         ac.setCreateSymbols(false);
 118         ac.getData().addAll(series1);
 119         pulse();
 120         // 1 area group
 121         assertEquals(1, ac.getPlotChildren().size());
 122         ac.getData().remove(0);
 123         pulse();
 124         assertEquals(0, ac.getPlotChildren().size());
 125     }
 126 
 127     @Test
 128     public void testSeriesRemoveWithoutSymbolsAnimated_rt_22124() {
 129         startApp();
 130         ac.setCreateSymbols(false);
 131         ac.getData().addAll(series1);
 132         pulse();
 133         // 1 area group
 134         assertEquals(1, ac.getPlotChildren().size());
 135 
 136         ac.setAnimated(true);
 137         Thread.UncaughtExceptionHandler exceptionHandler = ControlTestUtils.setHandler();
 138         try {
 139             ac.getData().remove(0);
 140         } finally {
 141             ControlTestUtils.resetHandler(exceptionHandler);
 142         }
 143         toolkit.setAnimationTime(200);
 144         assertEquals(1, ac.getPlotChildren().size());
 145         assertEquals(0.5, ac.getPlotChildren().get(0).getOpacity(), 0.0);
 146         toolkit.setAnimationTime(400);
 147         assertEquals(0, ac.getPlotChildren().size());
 148     }
 149 
 150     @Test @Ignore
 151     public void testDataItemRemove() {
 152         startApp();
 153         ac.getData().addAll(series1);
 154         pulse();
 155         if (!ac.getData().isEmpty()) {
 156             series1.getData().remove(0);
 157             pulse();
 158             StringBuffer sb = getSeriesLineFromPlot();
 159             assertEquals(sb.toString(), "L247.0 171.0 L412.0 171.0 L658.0 284.0 ");
 160         }
 161     }
 162     
 163     @Test @Ignore
 164     public void testDataItemAdd() {
 165         startApp();
 166         ac.getData().addAll(series1);
 167         pulse();


< prev index next >