use of org.knime.base.util.coordinate.MappingMethod in project knime-core by knime.
the class Axis method createPopupMenu.
private JPopupMenu createPopupMenu() {
if (getCoordinate() == null) {
return null;
}
m_currFormat = NORMAL;
JPopupMenu popupMenu = new JPopupMenu();
createNotationMenu(popupMenu);
// policies
if (m_coordinate != null) {
List<PolicyStrategy> strategies = new LinkedList<PolicyStrategy>();
Set<PolicyStrategy> policies = m_coordinate.getCompatiblePolicies();
if (policies != null) {
strategies.addAll(policies);
Collections.sort(strategies, new Comparator<PolicyStrategy>() {
/**
* {@inheritDoc}
*/
@Override
public int compare(final PolicyStrategy o1, final PolicyStrategy o2) {
return o1.getDisplayName().compareTo(o2.getDisplayName());
}
});
}
JMenu tickPolicyMenu = new JMenu("Tick policies");
ButtonGroup tickPolicyButtons = new ButtonGroup();
if (strategies.size() > 0) {
popupMenu.add(tickPolicyMenu);
for (PolicyStrategy strategy : strategies) {
final PolicyStrategy tempStrategy = strategy;
JRadioButtonMenuItem tickPolicy = new JRadioButtonMenuItem(strategy.getDisplayName());
tickPolicyButtons.add(tickPolicy);
tickPolicyMenu.add(tickPolicy);
if (strategy.equals(m_coordinate.getCurrentPolicy())) {
tickPolicy.setSelected(true);
}
tickPolicy.addItemListener(new ItemListener() {
/**
* {@inheritDoc}
*/
@Override
public void itemStateChanged(final ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
m_coordinate.setPolicy(tempStrategy);
// recreate popup menu
setComponentPopupMenu(createPopupMenu());
if (tempStrategy.isMappingAllowed()) {
m_mappingMethodMenu.setEnabled(true);
m_notationsMenu.setEnabled(true);
} else {
// hide mapping methods
m_mappingMethodMenu.setEnabled(false);
m_notationsMenu.setEnabled(false);
if (getCoordinate() != null) {
getCoordinate().setActiveMappingMethod(null);
}
}
notifyChangeListeners();
}
}
});
}
}
// add strategies
Set<MappingMethod> mappingMethods = m_coordinate.getCompatibleMappingMethods();
m_mappingMethodMenu = new JMenu("Mapping Methods");
if (mappingMethods != null && mappingMethods.size() > 0) {
popupMenu.add(m_mappingMethodMenu);
ButtonGroup buttons = new ButtonGroup();
final Map<MappingMethod, JRadioButtonMenuItem> checkboxes = new HashMap<MappingMethod, JRadioButtonMenuItem>();
JRadioButtonMenuItem none = new JRadioButtonMenuItem("none", true);
buttons.add(none);
none.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(final ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
m_coordinate.setActiveMappingMethod(null);
notifyChangeListeners();
}
}
});
m_mappingMethodMenu.add(none);
for (MappingMethod method : mappingMethods) {
// final needed
final MappingMethod tempMethod = method;
JRadioButtonMenuItem checkbox = new JRadioButtonMenuItem(method.getDisplayName(), false);
checkbox.setEnabled(method.isCompatibleWithDomain(getCoordinate().getDomain()));
checkboxes.put(method, checkbox);
buttons.add(checkbox);
if (method.equals(m_coordinate.getActiveMappingMethod())) {
checkbox.setSelected(true);
}
checkbox.addItemListener(new ItemListener() {
/**
* {@inheritDoc}
*/
@Override
public void itemStateChanged(final ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
m_coordinate.setActiveMappingMethod(tempMethod);
}
notifyChangeListeners();
}
});
m_mappingMethodMenu.add(checkbox);
}
for (Map.Entry<MappingMethod, JRadioButtonMenuItem> entry : checkboxes.entrySet()) {
if (entry.getKey().isCompatibleWithDomain(getCoordinate().getDomain())) {
entry.getValue().setEnabled(true);
}
}
}
}
if (popupMenu.getComponentCount() < 1) {
return null;
}
return popupMenu;
}
use of org.knime.base.util.coordinate.MappingMethod in project knime-core by knime.
the class BasicPlotter method isLogarithmic.
private boolean isLogarithmic(final Axis axis) {
Coordinate coordinate = axis.getCoordinate();
MappingMethod mapMethod = coordinate.getActiveMappingMethod();
if (mapMethod != null && mapMethod instanceof LogarithmicMappingMethod) {
return true;
}
return false;
}
Aggregations