Пример #1
0
  /*
   * (non-Javadoc)
   *
   * @see com.ibm.examples.chart.widget.chart.AbstractChartBuilder#buildXSeries()
   */
  protected void buildXSeries() {

    data = adapter.getData();

    int starting = 0;
    if (data.length > xSeriesTicks) starting = data.length - xSeriesTicks;
    x = new String[data.length - starting];

    try {
      for (int j = starting, k = 0; j < data.length; j++, k++) x[k] = data[j][0].toString();
    } catch (Exception e) {
      //        	  e.printStackTrace();
    }
    TextDataSet categoryValues = TextDataSetImpl.create(x);
    // NumberDataSet categoryValues = NumberDataSetImpl.create(new double[] { 0, 1, 2, 3 });

    Series seCategory = SeriesImpl.create();

    seCategory.setDataSet(categoryValues);

    // Apply the color palette
    SeriesDefinition sdX = SeriesDefinitionImpl.create();
    sdX.getSeriesPalette().update(1);

    xAxis.getSeriesDefinitions().add(sdX);

    sdX.getSeries().add(seCategory);
  }
Пример #2
0
 /**
  *
  * <!-- begin-user-doc -->
  * <!-- end-user-doc -->
  *
  * @generated
  */
 @Override
 public void eUnset(int featureID) {
   switch (featureID) {
     case TypePackage.LINE_SERIES__MARKERS:
       getMarkers().clear();
       return;
     case TypePackage.LINE_SERIES__MARKER:
       setMarker((Marker) null);
       return;
     case TypePackage.LINE_SERIES__LINE_ATTRIBUTES:
       setLineAttributes((LineAttributes) null);
       return;
     case TypePackage.LINE_SERIES__PALETTE_LINE_COLOR:
       unsetPaletteLineColor();
       return;
     case TypePackage.LINE_SERIES__CURVE:
       unsetCurve();
       return;
     case TypePackage.LINE_SERIES__SHADOW_COLOR:
       setShadowColor((ColorDefinition) null);
       return;
     case TypePackage.LINE_SERIES__CONNECT_MISSING_VALUE:
       unsetConnectMissingValue();
       return;
   }
   super.eUnset(featureID);
 }
Пример #3
0
 /**
  *
  * <!-- begin-user-doc -->
  * <!-- end-user-doc -->
  *
  * @generated
  */
 @SuppressWarnings("unchecked")
 @Override
 public void eSet(int featureID, Object newValue) {
   switch (featureID) {
     case TypePackage.LINE_SERIES__MARKERS:
       getMarkers().clear();
       getMarkers().addAll((Collection<? extends Marker>) newValue);
       return;
     case TypePackage.LINE_SERIES__MARKER:
       setMarker((Marker) newValue);
       return;
     case TypePackage.LINE_SERIES__LINE_ATTRIBUTES:
       setLineAttributes((LineAttributes) newValue);
       return;
     case TypePackage.LINE_SERIES__PALETTE_LINE_COLOR:
       setPaletteLineColor((Boolean) newValue);
       return;
     case TypePackage.LINE_SERIES__CURVE:
       setCurve((Boolean) newValue);
       return;
     case TypePackage.LINE_SERIES__SHADOW_COLOR:
       setShadowColor((ColorDefinition) newValue);
       return;
     case TypePackage.LINE_SERIES__CONNECT_MISSING_VALUE:
       setConnectMissingValue((Boolean) newValue);
       return;
   }
   super.eSet(featureID, newValue);
 }
Пример #4
0
  /**
   * Initializes all member variables within this object recursively
   *
   * <p>Note: Manually written
   */
  protected void initDefault() // SUBCLASSED BY ScatterSeriesImpl
      {
    super.initDefault();

    final LineAttributes lia =
        LineAttributesImpl.createDefault(null, LineStyle.SOLID_LITERAL, 1, true);
    setLineAttributes(lia);
    labelPosition = Position.ABOVE_LITERAL;

    final Marker m = MarkerImpl.createDefault(MarkerType.BOX_LITERAL, 4, true);
    LineAttributes la = LineAttributesImpl.createDefault(true);
    m.setOutline(la);
    getMarkers().add(m);

    paletteLineColor = true;
  }
Пример #5
0
  /**
   * Initializes all member variables within this object recursively
   *
   * <p>Note: Manually written
   */
  protected void initialize() // SUBCLASSED BY ScatterSeriesImpl
      {
    super.initialize();

    final LineAttributes lia = AttributeFactory.eINSTANCE.createLineAttributes();
    ((LineAttributesImpl) lia).set(ColorDefinitionImpl.BLACK(), LineStyle.SOLID_LITERAL, 1);
    lia.setVisible(true);
    setLineAttributes(lia);
    setLabelPosition(Position.ABOVE_LITERAL);

    final Marker m = AttributeFactory.eINSTANCE.createMarker();
    m.setType(MarkerType.BOX_LITERAL);
    m.setSize(4);
    m.setVisible(true);
    LineAttributes la = AttributeFactory.eINSTANCE.createLineAttributes();
    la.setVisible(true);
    m.setOutline(la);
    getMarkers().add(m);
    setPaletteLineColor(true);
  }
Пример #6
0
  /** @generated */
  protected void set(LineSeries src) {

    super.set(src);

    // children

    if (src.getMarkers() != null) {
      EList<Marker> list = getMarkers();
      for (Marker element : src.getMarkers()) {
        list.add(element.copyInstance());
      }
    }

    if (src.getMarker() != null) {
      setMarker(src.getMarker().copyInstance());
    }

    if (src.getLineAttributes() != null) {
      setLineAttributes(src.getLineAttributes().copyInstance());
    }

    if (src.getShadowColor() != null) {
      setShadowColor(src.getShadowColor().copyInstance());
    }

    // attributes

    paletteLineColor = src.isPaletteLineColor();

    paletteLineColorESet = src.isSetPaletteLineColor();

    curve = src.isCurve();

    curveESet = src.isSetCurve();

    connectMissingValue = src.isConnectMissingValue();

    connectMissingValueESet = src.isSetConnectMissingValue();
  }
Пример #7
0
  public static final Chart createSeriesScript() {
    ChartWithAxes cwaBar = ChartWithAxesImpl.create();
    cwaBar.setType("Bar Chart"); // $NON-NLS-1$
    cwaBar.setSubType("Side-by-side"); // $NON-NLS-1$

    cwaBar.setScript(
        "function beforeDrawSeries(series, renderer, scriptContext)" //$NON-NLS-1$
            + "{series.getLabel().getCaption().getColor().set(12, 232, 182);}" //$NON-NLS-1$
        );

    cwaBar.getLegend().setVisible(false);
    cwaBar.getTitle().getLabel().getCaption().setValue("Chart with Series Script"); // $NON-NLS-1$

    // X-Axis
    Axis xAxisPrimary = cwaBar.getPrimaryBaseAxes()[0];
    xAxisPrimary.setType(AxisType.TEXT_LITERAL);
    xAxisPrimary.getOrigin().setType(IntersectionType.VALUE_LITERAL);

    // Y-Axis
    Axis yAxisPrimary = cwaBar.getPrimaryOrthogonalAxis(xAxisPrimary);
    yAxisPrimary.getMajorGrid().setTickStyle(TickStyle.LEFT_LITERAL);
    yAxisPrimary.setType(AxisType.LINEAR_LITERAL);

    // Data Set
    TextDataSet categoryValues =
        TextDataSetImpl.create(
            new String[] {
              "Item 1", "Item 2", "Item 3", "Item 4", "Item 5"
            }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
    NumberDataSet orthoValues = NumberDataSetImpl.create(new double[] {8, 18, -15, -8, 10});

    SampleData sd = DataFactory.eINSTANCE.createSampleData();
    BaseSampleData sdBase = DataFactory.eINSTANCE.createBaseSampleData();
    sdBase.setDataSetRepresentation(""); // $NON-NLS-1$
    sd.getBaseSampleData().add(sdBase);

    OrthogonalSampleData sdOrthogonal = DataFactory.eINSTANCE.createOrthogonalSampleData();
    sdOrthogonal.setDataSetRepresentation(""); // $NON-NLS-1$
    sdOrthogonal.setSeriesDefinitionIndex(0);
    sd.getOrthogonalSampleData().add(sdOrthogonal);

    cwaBar.setSampleData(sd);

    // X-Series
    Series seCategory = SeriesImpl.create();
    seCategory.setDataSet(categoryValues);

    SeriesDefinition sdX = SeriesDefinitionImpl.create();
    xAxisPrimary.getSeriesDefinitions().add(sdX);
    sdX.getSeries().add(seCategory);

    // Y-Series
    BarSeries bs = (BarSeries) BarSeriesImpl.create();
    bs.setDataSet(orthoValues);
    bs.getLabel().setVisible(true);

    SeriesDefinition sdY = SeriesDefinitionImpl.create();
    yAxisPrimary.getSeriesDefinitions().add(sdY);
    sdY.getSeries().add(bs);

    return cwaBar;
  }
Пример #8
0
  /**
   * Creates a scatter chart model as a reference implementation
   *
   * @return An instance of the simulated runtime chart model (containing filled datasets)
   */
  public static final Chart createDateTimeScatter() {
    ChartWithAxes cwaScatter = ChartWithAxesImpl.create();

    // TODO: research running script under plugin test.

    cwaScatter.setScript(
        "function beforeDrawAxisLabel(axis, label, context)" //$NON-NLS-1$
            + "{label.getCaption().setValue(\"ABC\"); " //$NON-NLS-1$
            + "axis.setLabel(label);}" //$NON-NLS-1$
        );

    // Plot

    cwaScatter.getPlot().getClientArea().getOutline().setVisible(true);

    // Title
    cwaScatter.getTitle().setVisible(false);

    // X-Axis
    Axis xAxisPrimary = ((ChartWithAxesImpl) cwaScatter).getPrimaryBaseAxes()[0];
    xAxisPrimary.getTitle().getCaption().setValue("Time");
    xAxisPrimary.setType(AxisType.DATE_TIME_LITERAL);
    xAxisPrimary.getTitle().setVisible(true);
    xAxisPrimary.getOrigin().setType(IntersectionType.MIN_LITERAL);

    // Y-Axis
    Axis yAxisPrimary = ((ChartWithAxesImpl) cwaScatter).getPrimaryOrthogonalAxis(xAxisPrimary);
    yAxisPrimary.getTitle().getCaption().setValue("Score");

    yAxisPrimary.getTitle().setBackground(ColorDefinitionImpl.WHITE());
    yAxisPrimary.getTitle().setVisible(true);
    yAxisPrimary.setType(AxisType.LINEAR_LITERAL);
    yAxisPrimary.getOrigin().setType(IntersectionType.MIN_LITERAL);

    // create chart data
    int seriesLen = 10;
    double[] yseries = new double[seriesLen];
    Calendar[] datetime = new Calendar[seriesLen];
    for (int i = 0; i < seriesLen; i++) {
      yseries[i] = ((double) i);
      datetime[i] = new GregorianCalendar();
      datetime[i].setTime(new Date(i));
      // uncomment the following line and chart works ok
      // datetime[i].setTime(new Date(i*1000));
    }
    NumberDataSet dsNumericValues2 = NumberDataSetImpl.create(yseries);
    DateTimeDataSet dsDateTime = DateTimeDataSetImpl.create(datetime);

    // X-Series
    Series seBase = SeriesImpl.create();
    seBase.setDataSet(dsDateTime);
    SeriesDefinition sdX = SeriesDefinitionImpl.create();
    xAxisPrimary.getSeriesDefinitions().add(sdX);
    sdX.getSeries().add(seBase);

    // Y-Series
    ScatterSeries ss = (ScatterSeries) ScatterSeriesImpl.create();
    ss.setDataSet(dsNumericValues2);
    SeriesDefinition sdY = SeriesDefinitionImpl.create();
    yAxisPrimary.getSeriesDefinitions().add(sdY);
    sdY.getSeries().add(ss);

    return cwaScatter;
  }