@Override
public JComponent[] getToolbarComponents() {
TextModelImpl model = VizController.getInstance().getVizModel().getTextModel();
//Mode
final JPopupButton labelSizeModeButton = new JPopupButton();
TextManager textManager = VizController.getInstance().getTextManager();
for (final SizeMode sm : textManager.getSizeModes()) {
labelSizeModeButton.addItem(sm, sm.getIcon());
}
labelSizeModeButton.setSelectedItem(model.getSizeMode());
labelSizeModeButton.setChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
SizeMode sm = (SizeMode) e.getSource();
TextModelImpl model = VizController.getInstance().getVizModel().getTextModel();
model.setSizeMode(sm);
}
});
labelSizeModeButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/gephi/visualization/component/labelSizeMode.png")));
labelSizeModeButton.setToolTipText(NbBundle.getMessage(VizBarController.class, "VizToolbar.Labels.sizeMode"));
model.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
TextModelImpl model = VizController.getInstance().getVizModel().getTextModel();
if (model.getSizeMode() != labelSizeModeButton.getSelectedItem()) {
labelSizeModeButton.setSelectedItem(model.getSizeMode());
}
}
});
components[0] = labelSizeModeButton;
//Color mode
final JPopupButton labelColorModeButton = new JPopupButton();
for (final ColorMode cm : textManager.getColorModes()) {
labelColorModeButton.addItem(cm, cm.getIcon());
}
labelColorModeButton.setSelectedItem(textManager.getModel().getColorMode());
labelColorModeButton.setChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
ColorMode cm = (ColorMode) e.getSource();
TextModelImpl model = VizController.getInstance().getVizModel().getTextModel();
model.setColorMode(cm);
}
});
labelColorModeButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/gephi/visualization/component/labelColorMode.png")));
labelColorModeButton.setToolTipText(NbBundle.getMessage(VizBarController.class, "VizToolbar.Labels.colorMode"));
model.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
TextModelImpl model = VizController.getInstance().getVizModel().getTextModel();
if (model.getColorMode() != labelColorModeButton.getSelectedItem()) {
labelColorModeButton.setSelectedItem(model.getColorMode());
}
}
});
components[1] = labelColorModeButton;