Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding new feature histogram #1856

Open
omokshyna opened this issue May 16, 2024 · 1 comment
Open

Adding new feature histogram #1856

omokshyna opened this issue May 16, 2024 · 1 comment
Labels
gui gui related issue javafx javafx related

Comments

@omokshyna
Copy link
Collaborator

Introduce new feature histogram able to pick up numeric data types across all the features in selected feature list.

@omokshyna omokshyna added javafx javafx related gui gui related issue labels May 16, 2024
@robinschmid
Copy link
Member

Structure similar to VolcanoPlotController

FxModel, FxViewBuilder, FxController, FxUpdateTask

Idea

  • reuse HistogramPanel inside a new FxViewBuilder. No need to change HistogramPanel itself too much. Unless you need to set new things. But there is the HistgramPanel.setData method taking a HistogramData instance. Maybe you need to find out how to set the x-axis label (JFreeChart names it DomainAxis)
  • Extract all Feature data types from a feature list
  • Have user select one data type by ComboBox and then update the HinstogramData
    FeatureList list = ...;
    // this list would go into an ObservableList<NumberType> and be set as items in a combobox - maybe sorted by header name
    List<NumberType> types = list.getFeatureTypes().stream().filter(dt -> dt instanceof NumberType<?>).map(dt -> (NumberType)dt).toList();
    // This selected type would be in model.selectedTypeProperty() and 
    // be bound to the comboBox.getSelectionModel().selectedItemProperty()
    NumberType selectedType = types.getFirst(); 


    double[] data = list.streamFeatures().map(f -> extractDouble(f, selectedType)).filter(Objects::nonNull).mapToDouble(Double::doubleValue).toArray();

  private static Double extractDouble(final ModularFeature f, final NumberType selectedType) {
    Object o = f.get(selectedType);
    if(o instanceof Number num) {
      try {
        return num.doubleValue();
      } catch (Exception ex) {
        return null;
      }
    }
    return null;
  }

@omokshyna omokshyna mentioned this issue Jun 3, 2024
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gui gui related issue javafx javafx related
Projects
None yet
Development

No branches or pull requests

2 participants