use of com.jidesoft.swing.CheckBoxList in project aspro by JMMC-OpenDev.
the class ObservabilityPanel method initComponents.
/**
* Initialize the components (once)
*/
private void initComponents() {
this.chart = AsproChartUtils.createXYBarChart();
this.xyPlot = (XYPlot) this.chart.getPlot();
// change the Range axis (horizontal):
this.xyPlot.setRangeAxis(new BoundedDateAxis(""));
// create new JMMC annotation (moving position):
this.aJMMC = AsproChartUtils.createJMMCAnnotation();
// define sliding adapter :
this.slidingXYPlotAdapter = new SlidingXYPlotAdapter(this.chart, this.xyPlot, SlidingXYPlotAdapter.MAX_VIEW_ITEMS, this.aJMMC);
// add listener :
this.chart.addProgressListener(this);
// show tooltips
this.chartPanel = ChartUtils.createChartPanel(this.chart, true);
// intercept component resize events:
this.chartPanel.addComponentListener(new PanelResizeAdapter());
// zoom options :
this.chartPanel.setDomainZoomable(true);
// date axis :
this.chartPanel.setRangeZoomable(true);
this.chartPanel.addChartMouseListener(new ChartMouseListener() {
@Override
public void chartMouseClicked(final ChartMouseEvent event) {
final ChartEntity entity = event.getEntity();
int seriesIndex = -1;
// only support click on ranges (not text annotations):
if (entity instanceof XYItemEntity) {
final XYItemEntity itemEntity = (XYItemEntity) entity;
seriesIndex = itemEntity.getSeriesIndex();
} else if (entity instanceof ClickableXYAnnotationEntity) {
final ClickableXYAnnotationEntity anEntity = (ClickableXYAnnotationEntity) entity;
seriesIndex = anEntity.getRendererIndex();
// TODO: finalize interactions
if (false) {
// get object reference:
final Object ref = anEntity.getReference();
if (ref instanceof Observations) {
final Observations obsGroup = (Observations) ref;
logger.info("clicked on group [" + obsGroup.getGroupId() + " for " + obsGroup.getTargetId() + "]");
StatusBar.show("obs log : " + obsGroup.first().getObsId());
/*
TODO: show group in table ?
*/
}
}
} else if (entity instanceof XYAnnotationEntity) {
final XYAnnotationEntity anEntity = (XYAnnotationEntity) entity;
seriesIndex = anEntity.getRendererIndex();
}
if (seriesIndex != -1) {
final ObservationCollectionObsData chartData = getChartData();
// do not change selection if baseline limits displayed:
if ((chartData != null) && !chartData.getFirstObsData().isDoBaseLineLimits()) {
final int index = slidingXYPlotAdapter.getSeriePosition(seriesIndex);
if (logger.isDebugEnabled()) {
logger.debug("chartMouseClicked: serie={}, target index={}", seriesIndex, index);
}
final String targetName = slidingXYPlotAdapter.getTargetName(index);
if (targetName != null && !ObjectUtils.areEquals(targetName, selectedTargetName)) {
if (logger.isDebugEnabled()) {
logger.debug("chartMouseClicked: selectedTargetName={}", targetName);
}
final ObservationManager om = ObservationManager.getInstance();
om.fireTargetSelectionChanged(om.getTarget(targetName));
}
}
}
}
@Override
public void chartMouseMoved(final ChartMouseEvent event) {
}
});
this.add(this.chartPanel, BorderLayout.CENTER);
this.scroller = new JScrollBar(JScrollBar.VERTICAL, 0, 0, 0, 0);
this.scroller.setName("scroller");
this.scroller.getModel().addChangeListener(new ChangeListener() {
@Override
public void stateChanged(final ChangeEvent ce) {
final DefaultBoundedRangeModel model = (DefaultBoundedRangeModel) ce.getSource();
// update position and repaint the plot:
slidingXYPlotAdapter.setPosition(model.getValue());
// update current target from updated position:
setCurrentTargetName(slidingXYPlotAdapter.getCurrentTargetName());
}
});
// update mouse wheel handler:
updateMouseWheelHandler(false);
// Use a panel to define custom margin arround the scroll bar:
this.scrollerPanel = new JPanel(new BorderLayout());
this.scrollerPanel.add(this.scroller);
this.scrollerPanel.setBorder(BorderFactory.createEmptyBorder(20, 0, 20, 0));
this.scrollerPanel.setBackground(Color.WHITE);
this.add(this.scrollerPanel, BorderLayout.EAST);
final JPanel panelOptions = new JPanel(new FlowLayout(FlowLayout.CENTER, 6, 2));
panelOptions.add(new JLabel("Time:"));
this.jComboTimeRef = new JComboBox(AsproConstants.TIME_CHOICES);
this.jComboTimeRef.setName("jComboTimeRef");
this.jComboTimeRef.setSelectedItem(this.myPreferences.getPreference(Preferences.TIME_REFERENCE));
this.jComboTimeRef.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent e) {
refreshPlot();
}
});
panelOptions.add(this.jComboTimeRef);
this.jCheckBoxNightOnly = new JCheckBox("Night only");
this.jCheckBoxNightOnly.setName("jCheckBoxNightOnly");
this.jCheckBoxNightOnly.setSelected(myPreferences.getPreferenceAsBoolean(Preferences.ONLY_NIGHT));
this.jCheckBoxNightOnly.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(final ItemEvent e) {
if (getChartData() != null && jCheckBoxNightOnly.isEnabled()) {
if (e.getStateChange() == ItemEvent.SELECTED) {
// Update date axis = zoom on night bounds:
if (nightLower != 0d && nightUpper != 0d) {
updateDateAxisBounds(nightLower, nightUpper);
}
} else {
// full range:
final ObservabilityData obsData = getChartData().getFirstObsData();
updateDateAxisBounds(obsData.getDateMin().getTime(), obsData.getDateMax().getTime());
}
}
}
});
panelOptions.add(this.jCheckBoxNightOnly);
this.jCheckBoxBaseLineLimits = new JCheckBox("Baseline limits");
this.jCheckBoxBaseLineLimits.setName("jCheckBoxBaseLineLimits");
this.jCheckBoxBaseLineLimits.setSelected(DEFAULT_DO_BASELINE_LIMITS);
this.jCheckBoxBaseLineLimits.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(final ItemEvent e) {
final boolean doBaseLineLimits = e.getStateChange() == ItemEvent.SELECTED;
// disable the automatic refresh :
final boolean prevAutoRefresh = setAutoRefresh(false);
try {
if (doBaseLineLimits) {
// force LST to compute correctly base line limits :
jComboTimeRef.setSelectedItem(TimeRef.LST.getDisplayName());
jCheckBoxDetailedOutput.setSelected(false);
} else {
// restore user preference :
jComboTimeRef.setSelectedItem(myPreferences.getPreference(Preferences.TIME_REFERENCE));
}
jComboTimeRef.setEnabled(!doBaseLineLimits);
jCheckBoxDetailedOutput.setEnabled(!doBaseLineLimits);
} finally {
// restore the automatic refresh :
setAutoRefresh(prevAutoRefresh);
}
refreshPlot();
}
});
panelOptions.add(this.jCheckBoxBaseLineLimits);
this.jCheckBoxDetailedOutput = new JCheckBox("Details");
this.jCheckBoxDetailedOutput.setName("jCheckBoxDetailedOutput");
this.jCheckBoxDetailedOutput.setSelected(DEFAULT_DO_DETAILED_OUTPUT);
this.jCheckBoxDetailedOutput.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(final ItemEvent e) {
refreshPlot();
}
});
panelOptions.add(this.jCheckBoxDetailedOutput);
this.jCheckBoxListFilters = new CheckBoxList(FILTERS) {
/**
* default serial UID for Serializable interface
*/
private static final long serialVersionUID = 1;
/**
* This method is called as the cursor moves within the list
*/
@Override
public String getToolTipText(final MouseEvent evt) {
// Get item index :
final int index = locationToIndex(evt.getPoint());
if (index != -1) {
// Get filter:
final ObservabilityFilter filter = (ObservabilityFilter) getModel().getElementAt(index);
if (filter != null) {
// Return the tool tip text :
return filter.getTooltip();
}
}
return getToolTipText();
}
};
this.jCheckBoxListFilters.setName("jCheckBoxListFilters");
// note: only 1 is ugly on macOS X
this.jCheckBoxListFilters.setVisibleRowCount(2);
this.jCheckBoxListFilters.getCheckBoxListSelectionModel().addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(final ListSelectionEvent e) {
if (!e.getValueIsAdjusting() && getChartData() != null) {
updatePlot(getChartData());
}
}
});
panelOptions.add(createSeparator());
panelOptions.add(new JLabel("Filters:"));
panelOptions.add(new JScrollPane(this.jCheckBoxListFilters));
this.jLabelGroups = new JLabel("Groups:");
panelOptions.add(this.jLabelGroups);
this.checkBoxListGroups = createCheckBoxList();
this.checkBoxListGroups.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
this.checkBoxListGroups.setToolTipText("groups whose target belongs to");
// note: only 1 is ugly on macOS X
this.checkBoxListGroups.setVisibleRowCount(2);
this.checkBoxListGroups.setCellRenderer(TargetGroupRenderer.INSTANCE);
this.checkBoxListGroups.getCheckBoxListSelectionModel().addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(final ListSelectionEvent e) {
if (!e.getValueIsAdjusting() && getChartData() != null) {
updatePlot(getChartData());
}
}
});
this.jScrollPaneGroups = new JScrollPane(this.checkBoxListGroups);
panelOptions.add(jScrollPaneGroups);
this.jCheckBoxShowRelated = new JCheckBox("<html>Show<br>related</html>");
this.jCheckBoxShowRelated.setName("jCheckBoxShowRelated");
this.jCheckBoxShowRelated.setToolTipText("If enabled, selected target and its calibrators are always shown (not filtered)");
this.jCheckBoxShowRelated.setSelected(DEFAULT_DO_SHOW_RELATED);
this.jCheckBoxShowRelated.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(final ItemEvent e) {
// refresh the plot:
updatePlot(getChartData());
}
});
panelOptions.add(this.jCheckBoxShowRelated);
this.jCheckBoxScrollView = new JCheckBox("Scroll view");
this.jCheckBoxScrollView.setName("jCheckBoxScrollView");
this.jCheckBoxScrollView.setToolTipText("<html>If enabled, only few targets are displayed and the plot is scrollable (mousewheel supported)" + "<br>but <b>the exported PDF always contains all targets</b> (multiple page if necessary)" + "<br>If disabled, all targets are displayed and the plot can be zoomed in / out (mouse)" + "<br>but <b>the exported PDF document contains targets as displayed (single page only)</b></html>");
this.jCheckBoxScrollView.setSelected(DEFAULT_DO_SCROLL_VIEW);
this.jCheckBoxScrollView.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(final ItemEvent e) {
// update scrollbar state and repaint the plot:
updateSliderProperties(false);
}
});
panelOptions.add(createSeparator());
panelOptions.add(this.jCheckBoxScrollView);
this.add(panelOptions, BorderLayout.PAGE_END);
// register this instance as a Preference Observer :
this.myPreferences.addObserver(this);
}
use of com.jidesoft.swing.CheckBoxList in project aspro by JMMC-OpenDev.
the class ObservabilityPanel method createCheckBoxList.
private static CheckBoxList createCheckBoxList() {
final CheckBoxList list = new CheckBoxList() {
/**
* default serial UID for Serializable interface
*/
private static final long serialVersionUID = 1L;
@Override
public boolean isCheckBoxEnabled(final int index) {
return true;
}
};
list.setClickInCheckBoxOnly(false);
return list;
}
use of com.jidesoft.swing.CheckBoxList in project aspro by JMMC-OpenDev.
the class TargetGroupForm method createCheckBoxList.
private CheckBoxList createCheckBoxList() {
final CheckBoxList list = new CheckBoxList() {
/**
* default serial UID for Serializable interface
*/
private static final long serialVersionUID = 1L;
@Override
public boolean isCheckBoxEnabled(final int index) {
return isCheckBoxListGroupsEnabled(index);
}
};
list.setClickInCheckBoxOnly(false);
return list;
}
Aggregations