Package simtools.data

Examples of simtools.data.DataSource


                public void run() {
                    // first get the data from the data pool
                    while (true) {
                        try {
                            if (a == null) {
                                DataSource d = DataSourcePool.global.getDataSourceWithId("A");
                                if (d instanceof StreamingTSDataSource) {
                                    a = (StreamingTSDataSource) d;
                                    a.addEndNotificationListener(SourceCollection.this);
                                }
                            }
                            if (b == null) {
                                DataSource d = DataSourcePool.global.getDataSourceWithId("B");
                                if (d instanceof StreamingTSDataSource) {
                                    b = (StreamingTSDataSource) d;
                                }
                            }
                            if ((a != null) && (b != null)) {
View Full Code Here


                        add("Csmooth", at, av + bv + db * (at - btp));
                    } else {
                        add("Csmooth", at, av + bv);
                    }
                    if (first) {
                        DataSource c = (DataSource) SourceCollection.this.get(2 * 2);
                        cc.path2s.addDataSource(c);
                        DataSource cs = (DataSource) SourceCollection.this.get(3 * 2);
                        cc.path2s.addDataSource(cs);
                        DataSourcePool.global.DataSourceCollectionDataSourceAdded(this, c);
                    }
                } catch (UnsupportedOperation e) {
                    // TODO Auto-generated catch block
View Full Code Here

        /* (non-Javadoc)
         * @see jsynoptic.builtin.RandomSource.OptionPanel#createSource()
         */
        public DataSource createSource(String name) {
           
            DataSource urs;
            Number seed = null;
            if (cbSeed.isSelected()) seed = NumberStringComparator.stringToNumber(tfSeed.getText());
            if (rbDynamic.isSelected()) {
                Number period = NumberStringComparator.stringToNumber(tfPeriod.getText());
                if (period==null) period = new Long(1000);
View Full Code Here

    if (s==null) return "";
    else return s;
  }
 
  public int getItemCount(int series) {
    DataSource x = getXSource(series);
    DataSource y = getYSource(series);
    // if x or y is null, nominal case when setting sources separately
    if ((x==null) || (y==null)) return 0;
    try {
      long lastix = x.computeLastIndex();
      if (lastix<0) return 0;
      long startix = x.computeStartIndex();
      if (startix<0) return 0;
      long lastiy = y.computeLastIndex();
      if (lastiy<0) return 0;
      long startiy = y.computeStartIndex();
      if (startiy<0) return 0;
      long starti = Math.max(startix,startiy);
      // Store start for optimization purpose in get[XY]Value below
      ((SourceCouple)sources.get(series)).startIndex = starti;
      int ret =  (int)Math.min(lastix - starti,lastiy - starti)+1;
View Full Code Here

    protected void setCellsTextValues(){

        if (cells.size() > 0){

            TextShape ts0 = (TextShape) cells.get(0)
            DataSource source = ts0.source;

            if (source != null) {
                try {
                    long dsIndex = source.getLastIndex();
                    for (int i = 0; i < cells.size(); i++) {

                        // Get text value from fisrt cell properties
                        String text = "";
                        if (ts0.displayDsName.booleanValue()) {
                            String name = DataInfo.getLabel(source);
                            if ((name != null) && !name.equals("")) {
                                text += name;
                                if (ts0.displayDsValue.booleanValue()) {
                                    text += "=";
                                }
                            }
                        }
                        try {
                            if (ts0.displayDsValue.booleanValue()) {
                                text += ts0.formatSourceValue(source.getValue(dsIndex));
                            }
                        } catch (DataException e) {
                            text += TextShape.resources.getString("NoValue");
                        }
                        if (ts0.displayDsUnit.booleanValue()) {
View Full Code Here

        /* (non-Javadoc)
         * @see jsynoptic.builtin.RandomSource.OptionPanel#createSource()
         */
        public DataSource createSource(String name) {
            
            DataSource urs;
            Number seed = null;
            if (cbSeed.isSelected()) seed = NumberStringComparator.stringToNumber(tfSeed.getText());
            if (rbDynamic.isSelected()) {
                Number period = NumberStringComparator.stringToNumber(tfPeriod.getText());
                if (period==null) period = new Long(1000);
View Full Code Here

   */
  public Paint getItemPaint(JSynopticXYItemRenderer renderer, int row, int column) {
    ColorMapper colorMapper = getColorMapper(row);
   
    if (colorMapper!=null) {
      DataSource ds = getDataSource(row);
      Paint ret;
      try {
        ret = colorMapper.getPaint(ds,ds.getStartIndex()+column);
      } catch (UnsupportedOperation e) {
        ret = null;
      }
      if (ret!=null) return ret;
    }
View Full Code Here

      pcurvecolor.setFocusPainted(false);
      SourceXYDataset dst = (SourceXYDataset)plot.getDataset();
      int n = dst.getSeriesCount();
      JSynopticXYItemRenderer renderer = (JSynopticXYItemRenderer)plot.getRenderer();
      for (int i=0; i<n; ++i) {
        DataSource ds = renderer.getDataSource(i);
        if (ds==null) {
          ds = dst.getYSource(i); // take the datasource associated with this curve by default
          DataSource linked = DataInfo.getLinkedSource(ds); // and follow link if necessary
          if (linked!=null) ds = linked;
        }
        pcbxcurves.addItem(new CbxEntry(i,dst.getSeriesName(i),(Color)renderer.getSeriesPaint(i),ds,renderer.getColorMapper(i)));
      }
      pcbxeditortf = (JTextField)pcbxcurves.getEditor().getEditorComponent();
      pupdateForEntry(pcbxcurves.getSelectedItem());
     
      pcbxcurves.addPopupMenuListener(new PopupMenuListener() {
        public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
          peditLocked = true;
        }
        public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
          peditLocked = false;
        }
        public void popupMenuCanceled(PopupMenuEvent e) {
          peditLocked = false;
        }
      });

      pcbxcurves.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
          if (e.getStateChange()==ItemEvent.DESELECTED) pactiveEntry = null;
          else pupdateForEntry(e.getItem());
        }
      });

      pcbxeditortf.getDocument().addDocumentListener(new DocumentListener() {
        public void insertUpdate(DocumentEvent e) {
          updateName();
        }
        public void removeUpdate(DocumentEvent e) {
          updateName();
        }
        public void changedUpdate(DocumentEvent e) {
          updateName();
        }
        public void updateName() {
          if ((peditLocked) || (pactiveEntry == null)) return;
          pactiveEntry.name = pcbxeditortf.getText();
        }
      });

      pcurvecolor.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
          if (pactiveEntry==null) return;
         
           DynamicColorChooser dialog = new DynamicColorChooser(
                              null, resources.getString("ChooseAColor"),null ,pactiveEntry.color,pactiveEntry.source,pactiveEntry.mapper);


                      dialog.pack();
                      dialog.setVisible(true);

                      if (dialog.isOk()){
                          pactiveEntry.color = dialog.getColor();
                          pactiveEntry.source = dialog.getSource();
                          pactiveEntry.mapper = dialog.getMapper();
                          pupdateForEntry(pactiveEntry);
                      }
        }
      });

      pcurvedelete.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
          if (pactiveEntry==null) return;
          pcbxcurves.removeItem(pactiveEntry);
        }
      });

      // Now handle Secondary Y axis
      if (plot.getSecondaryRangeAxis(0) != null) {
        section = new Box(BoxLayout.Y_AXIS);
        section.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),resources.getString("SecondaryYAxis")));
        panel = new JPanel();
        panel.setLayout(new FlowLayout(FlowLayout.LEFT));
        panel.add(scbautoy = new ActionCheckBox(resources.getString("Auto-update"), plot.getSecondaryRangeAxis(0).isAutoRange()) {
          public void actionPerformed(ActionEvent e) {
            scbfixedautoy.setEnabled(isSelected());
            scbfixedautoy.apply();
            slpymin.setEnabled(!isSelected());
            slpymax.setEnabled(!isSelected());
            stfpymin.setEnabled(!isSelected());
            stfpymax.setEnabled(!isSelected());
          }
        });
        autorange = plot.getSecondaryRangeAxis(0).getFixedAutoRange();
        panel.add(scbfixedautoy = new ActionCheckBox(resources.getString("FixedRange"),autorange!=0) {
          public void actionPerformed(ActionEvent e) {
            snffixedautoy.setEnabled(isSelected() && isEnabled());
          }
        });
        panel.add(snffixedautoy = new NumberField(autorange,8));
        panel.add(slpymin = new JLabel(resources.getString("minLabel")));
        panel.add(stfpymin = new NumberField(8));
        stfpymin.setValue(plot.getSecondaryRangeAxis(0).getLowerBound());
        panel.add(slpymax = new JLabel(resources.getString("maxLabel")));
        panel.add(stfpymax = new NumberField(8));
        stfpymax.setValue(plot.getSecondaryRangeAxis(0).getUpperBound());
        section.add(panel);
        scbautoy.apply();
 
        section.add(panel);
 
        box = Box.createHorizontalBox();
 
        box.add(new JLabel(resources.getString("Curves:")));
        box.add(scbxcurves = new JComboBox());
        box.add(scurvecolor = new JButton("    "));
        box.add(scurvedelete = new JButton(resources.getString("Delete")));
        section.add(box);
        content.add(section);
 
        scbxcurves.setEditable(true);
        //noCurveColor = scurvecolor.getBackground();
        scurvecolor.setFocusPainted(false);
        dst = (SourceXYDataset)plot.getSecondaryDataset(0);
        n = dst.getSeriesCount();
        renderer = (JSynopticXYItemRenderer)plot.getSecondaryRenderer(0);
        for (int i=0; i<n; ++i) {
          DataSource ds = renderer.getDataSource(i);
          if (ds==null) {
            ds = dst.getYSource(i); // take the datasource associated with this curve by default
            DataSource linked = DataInfo.getLinkedSource(ds); // and follow link if necessary
            if (linked!=null) ds = linked;
          }
          scbxcurves.addItem(new CbxEntry(i,dst.getSeriesName(i),(Color)renderer.getSeriesPaint(i),ds,renderer.getColorMapper(i)));
        }
        scbxeditortf = (JTextField)scbxcurves.getEditor().getEditorComponent();
View Full Code Here

        if (!(optionalInformation instanceof Object[])) return null;
       
        Object[] info = (Object[])optionalInformation;
        if (info.length!=5) return null;
       
        DataSource ret = null;
       
        if (id.startsWith(GaussianRandomSource.ID_PREFIX)) {
            if (info[1]==null) ret = new GaussianRandomSource((String)info[0], ((Double)info[2]).doubleValue(), ((Double)info[3]).doubleValue(), ((Long)info[4]).longValue());
            else ret = new GaussianRandomSource((String)info[0], ((Long)info[1]).longValue(), ((Double)info[2]).doubleValue(), ((Double)info[3]).doubleValue(), ((Long)info[4]).longValue());
        }
View Full Code Here

        if (!(optionalInformation instanceof Object[])) return null;
       
        Object[] info = (Object[])optionalInformation;
        if (info.length!=4) return null;
       
        DataSource ret = null;
       
        if (info[1] instanceof Double) ret = new RangeSource((String)info[0], ((Double)info[1]).doubleValue(), ((Double)info[2]).doubleValue(), ((Double)info[3]).doubleValue());
        else if (info[1] instanceof Long) ret = new RangeSource((String)info[0], ((Long)info[1]).longValue(), ((Long)info[2]).longValue(), ((Long)info[3]).longValue());
        else return null; // error
       
View Full Code Here

TOP

Related Classes of simtools.data.DataSource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.