Esempio n. 1
0
  public static void main(String[] args) {
    Chart shc = new Chart("C:/TEMP/table.csv");

    JFrame frame = new JFrame("Stock History Chart for " + shc.getSymbol());
    frame.getContentPane().add(shc, BorderLayout.CENTER);
    frame.setSize(640, 480);
    frame.setVisible(true);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  }
Esempio n. 2
0
  /** Creates a dataset of type XYSeries */
  public XYDataset convertDataSet() {
    int size = 0; // Initialises a value for size
    int sum = 0; // initialises a value for sum
    int pos = 0; // initialises a value for position
    int j = 0; // initialises a increment for the for loop

    XYSeriesCollection dataset = new XYSeriesCollection();
    XYSeries series = new XYSeries(super.GetTitle());

    DataCell preVal = super.GetDataSet().GetCell(0, 0);
    // Creates a new list for the found elements
    super.m_foundElements = new ArrayList<String>();

    for (int i = 0; i < super.GetDataSet().GetNumOfRows() - 1; i++) {

      if (!super.isUnique(super.GetDataSet().GetCell(super.GetXColumnPosition(), i).toString())) {
        for (j = pos; j < super.GetDataSet().GetNumOfRows() - 1; j++) {
          if (preVal
              .toString()
              .equals(super.GetDataSet().GetCell(super.GetXColumnPosition(), j).toString())) {

            // Check if datatype is a number
            if (super.GetDataSet().GetCell(super.GetXColumnPosition(), j).GetDataType()
                == DataType.INTEGER) {
              sum += super.GetDataSet().GetCell(super.GetYColumnPosition(), j).GetInteger();
            } else if (super.GetDataSet().GetCell(super.GetXColumnPosition(), j).GetDataType()
                == DataType.DOUBLE) {
              sum += super.GetDataSet().GetCell(super.GetYColumnPosition(), j).GetDouble();
            }
          }
        }
        super.m_foundElements.add(
            super.GetDataSet().GetCell(super.GetXColumnPosition(), i).toString());

        // Add to chart dataSet
        series.add(sum, preVal.GetInteger());

        preVal = super.GetDataSet().GetCell(super.GetXColumnPosition(), i++);
        sum = 0; //
        pos++;
      }
    }

    for (j = pos; j < super.GetDataSet().GetNumOfRows() - 1; j++) {
      if (super.m_foundElements
          .get(super.m_foundElements.size() - 1)
          .equals(super.GetDataSet().GetCell(super.GetXColumnPosition(), j).toString())) {
        if (super.GetDataSet().GetCell(super.GetXColumnPosition(), j).GetDataType()
            == DataType.INTEGER) {
          sum += super.GetDataSet().GetCell(super.GetYColumnPosition(), j).GetInteger();
        } else if (super.GetDataSet().GetCell(super.GetXColumnPosition(), j).GetDataType()
            == DataType.DOUBLE) {
          sum += super.GetDataSet().GetCell(super.GetYColumnPosition(), j).GetDouble();
        }
      }
    }
    series.add(sum, preVal.GetInteger());
    dataset.addSeries(series);
    return dataset;
  }
Esempio n. 3
0
 /**
  * Returns a author
  *
  * @return author of the Chart;
  */
 @Override
 public boolean SetAuthor(String author) {
   super.SetAuthor(author);
   return true;
 }
Esempio n. 4
0
 /**
  * Returns the colourmap selected
  *
  * @return colourmap set of the Chart;
  */
 @Override
 public boolean SetColourMap(ColourMap colours) {
   super.SetColourMap(colours);
   return true;
 }
Esempio n. 5
0
 /**
  * returns the title of the Chart
  *
  * @return Chart title of the Chart;
  */
 @Override
 public boolean SetChartTitle(String title) {
   super.SetChartTitle(title);
   return true;
 }
Esempio n. 6
0
 /**
  * returns the y axis values
  *
  * @return yData set values;
  */
 @Override
 public boolean SetYData(int yData) {
   super.SetYData(yData);
   return true;
 }
Esempio n. 7
0
 /**
  * returns the x axis values
  *
  * @return xData set values;
  */
 @Override
 public boolean SetXData(int xData) {
   super.SetXData(xData);
   return true;
 }
Esempio n. 8
0
 /**
  * Returns the data set
  *
  * @return true the set data is correct;
  */
 @Override
 public boolean SetDataSet(DataSet data) {
   super.SetData(data);
   return true;
 }
Esempio n. 9
0
 /**
  * Sets the type of chart to the constant SCATTERPLOT
  *
  * @return true of set correctly;
  */
 public boolean SetChartType() {
   super.SetChartType(ChartType.BARCHART);
   return true;
 }
Esempio n. 10
0
 /**
  * returns the description
  *
  * @return description of the Chart class;
  */
 @Override
 public boolean SetDescription(String description) {
   super.SetDescription(description);
   return true;
 }
Esempio n. 11
0
 public static void naitab(int[] arvud) {
   Chart chart = new Chart("Mälu", arvud);
   chart.pack();
   RefineryUtilities.centerFrameOnScreen(chart);
   chart.setVisible(true);
 }