use of org.gephi.visualization.text.TextModelImpl in project gephi by gephi.
the class LabelSettingsPanel method refreshSharedConfig.
private void refreshSharedConfig() {
VizModel vizModel = VizController.getInstance().getVizModel();
setEnable(!vizModel.isDefaultModel());
if (vizModel.isDefaultModel()) {
return;
}
TextModelImpl model = vizModel.getTextModel();
//node
nodeFontButton.setText(model.getNodeFont().getFontName() + ", " + model.getNodeFont().getSize());
((JColorButton) nodeColorButton).setColor(model.getNodeColor());
if (showNodeLabelsCheckbox.isSelected() != model.isShowNodeLabels()) {
showNodeLabelsCheckbox.setSelected(model.isShowNodeLabels());
}
if (nodeSizeSlider.getValue() / 100f != model.getNodeSizeFactor()) {
nodeSizeSlider.setValue((int) (model.getNodeSizeFactor() * 100f));
}
//edge
edgeFontButton.setText(model.getEdgeFont().getFontName() + ", " + model.getEdgeFont().getSize());
((JColorButton) edgeColorButton).setColor(model.getEdgeColor());
if (showEdgeLabelsCheckbox.isSelected() != model.isShowEdgeLabels()) {
showEdgeLabelsCheckbox.setSelected(model.isShowEdgeLabels());
}
if (edgeSizeSlider.getValue() / 100f != model.getEdgeSizeFactor()) {
edgeSizeSlider.setValue((int) (model.getEdgeSizeFactor() * 100f));
}
//general
if (hideNonSelectedCheckbox.isSelected() != model.isSelectedOnly()) {
hideNonSelectedCheckbox.setSelected(model.isSelectedOnly());
}
if (sizeModeCombo.getSelectedItem() != model.getSizeMode()) {
sizeModeCombo.setSelectedItem(model.getSizeMode());
}
if (colorModeCombo.getSelectedItem() != model.getColorMode()) {
colorModeCombo.setSelectedItem(model.getColorMode());
}
}
use of org.gephi.visualization.text.TextModelImpl in project gephi by gephi.
the class VizModel method defaultValues.
private void defaultValues() {
config = VizController.getInstance().getVizConfig();
cameraPosition = Arrays.copyOf(config.getDefaultCameraPosition(), 3);
cameraTarget = Arrays.copyOf(config.getDefaultCameraTarget(), 3);
textModel = new TextModelImpl();
backgroundColor = config.getDefaultBackgroundColor();
showEdges = config.isDefaultShowEdges();
lightenNonSelectedAuto = config.isDefaultLightenNonSelectedAuto();
autoSelectNeighbor = config.isDefaultAutoSelectNeighbor();
hideNonSelectedEdges = config.isDefaultHideNonSelectedEdges();
uniColorSelected = config.isDefaultUniColorSelected();
edgeHasUniColor = config.isDefaultEdgeHasUniColor();
edgeUniColor = config.getDefaultEdgeUniColor().getRGBComponents(null);
adjustByText = config.isDefaultAdjustByText();
edgeSelectionColor = config.isDefaultEdgeSelectionColor();
edgeInSelectionColor = config.getDefaultEdgeInSelectedColor().getRGBComponents(null);
edgeOutSelectionColor = config.getDefaultEdgeOutSelectedColor().getRGBComponents(null);
edgeBothSelectionColor = config.getDefaultEdgeBothSelectedColor().getRGBComponents(null);
edgeScale = config.getDefaultEdgeScale();
}
use of org.gephi.visualization.text.TextModelImpl in project gephi by gephi.
the class LabelSettingsPanel method setEnable.
public void setEnable(boolean enable) {
showEdgeLabelsCheckbox.setEnabled(enable);
showNodeLabelsCheckbox.setEnabled(enable);
sizeModeCombo.setEnabled(enable);
colorModeCombo.setEnabled(enable);
hideNonSelectedCheckbox.setEnabled(enable);
labelColorMode.setEnabled(enable);
labelSizeMode.setEnabled(enable);
configureLabelsButton.setEnabled(enable);
TextModelImpl model = VizController.getInstance().getVizModel().getTextModel();
boolean edgeValue = model.isShowEdgeLabels();
edgeFontButton.setEnabled(enable && edgeValue);
edgeColorButton.setEnabled(enable && edgeValue);
edgeSizeSlider.setEnabled(enable && edgeValue);
labelEdgeColor.setEnabled(enable && edgeValue);
labelEdgeFont.setEnabled(enable && edgeValue);
labelEdgeSize.setEnabled(enable && edgeValue);
boolean nodeValue = model.isShowNodeLabels();
nodeFontButton.setEnabled(enable && nodeValue);
nodeColorButton.setEnabled(enable && nodeValue);
nodeSizeSlider.setEnabled(enable && nodeValue);
labelNodeColor.setEnabled(enable && nodeValue);
labelNodeFont.setEnabled(enable && nodeValue);
labelNodeSize.setEnabled(enable && nodeValue);
}
use of org.gephi.visualization.text.TextModelImpl in project gephi by gephi.
the class LabelSettingsPanel method setup.
public void setup() {
VizModel vizModel = VizController.getInstance().getVizModel();
TextModelImpl model = vizModel.getTextModel();
vizModel.addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
if (evt.getPropertyName().equals("init")) {
refreshSharedConfig();
}
}
});
//NodePanel
showNodeLabelsCheckbox.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
boolean value = showNodeLabelsCheckbox.isSelected();
TextModelImpl model = VizController.getInstance().getVizModel().getTextModel();
if (value != model.isShowNodeLabels()) {
model.setShowNodeLabels(value);
setEnable(true);
}
}
});
nodeFontButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
TextModelImpl model = VizController.getInstance().getVizModel().getTextModel();
Font font = JFontChooser.showDialog(WindowManager.getDefault().getMainWindow(), model.getNodeFont());
if (font != null && font != model.getNodeFont()) {
model.setNodeFont(font);
}
}
});
((JColorButton) nodeColorButton).addPropertyChangeListener(JColorButton.EVENT_COLOR, new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
TextModelImpl model = VizController.getInstance().getVizModel().getTextModel();
if (!model.getNodeColor().equals(((JColorButton) nodeColorButton).getColor())) {
model.setNodeColor(((JColorButton) nodeColorButton).getColor());
}
}
});
nodeSizeSlider.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
TextModelImpl model = VizController.getInstance().getVizModel().getTextModel();
if (model.getNodeSizeFactor() != nodeSizeSlider.getValue() / 100f) {
model.setNodeSizeFactor(nodeSizeSlider.getValue() / 100f);
}
}
});
//EdgePanel
showEdgeLabelsCheckbox.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
boolean value = showEdgeLabelsCheckbox.isSelected();
TextModelImpl model = VizController.getInstance().getVizModel().getTextModel();
if (value != model.isShowEdgeLabels()) {
model.setShowEdgeLabels(value);
setEnable(true);
}
}
});
edgeFontButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
TextModelImpl model = VizController.getInstance().getVizModel().getTextModel();
Font font = JFontChooser.showDialog(WindowManager.getDefault().getMainWindow(), model.getEdgeFont());
if (font != null && font != model.getEdgeFont()) {
model.setEdgeFont(font);
}
}
});
((JColorButton) edgeColorButton).addPropertyChangeListener(JColorButton.EVENT_COLOR, new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
TextModelImpl model = VizController.getInstance().getVizModel().getTextModel();
if (!model.getEdgeColor().equals(((JColorButton) edgeColorButton).getColor())) {
model.setEdgeColor(((JColorButton) edgeColorButton).getColor());
}
}
});
edgeSizeSlider.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
TextModelImpl model = VizController.getInstance().getVizModel().getTextModel();
model.setEdgeSizeFactor(edgeSizeSlider.getValue() / 100f);
}
});
//General
final TextManager textManager = VizController.getInstance().getTextManager();
final DefaultComboBoxModel sizeModeModel = new DefaultComboBoxModel(textManager.getSizeModes());
sizeModeCombo.setModel(sizeModeModel);
final DefaultComboBoxModel colorModeModel = new DefaultComboBoxModel(textManager.getColorModes());
colorModeCombo.setModel(colorModeModel);
sizeModeCombo.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
TextModelImpl model = VizController.getInstance().getVizModel().getTextModel();
if (model.getSizeMode() != sizeModeModel.getSelectedItem()) {
model.setSizeMode((SizeMode) sizeModeModel.getSelectedItem());
}
}
});
colorModeCombo.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
TextModelImpl model = VizController.getInstance().getVizModel().getTextModel();
if (model.getColorMode() != colorModeModel.getSelectedItem()) {
model.setColorMode((ColorMode) colorModeModel.getSelectedItem());
}
}
});
hideNonSelectedCheckbox.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
TextModelImpl model = VizController.getInstance().getVizModel().getTextModel();
if (model.isSelectedOnly() != hideNonSelectedCheckbox.isSelected()) {
model.setSelectedOnly(hideNonSelectedCheckbox.isSelected());
}
}
});
//Attributes
configureLabelsButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
TextModelImpl model = VizController.getInstance().getVizModel().getTextModel();
LabelAttributesPanel panel = new LabelAttributesPanel();
panel.setup(model);
DialogDescriptor dd = new DialogDescriptor(panel, NbBundle.getMessage(VizBarController.class, "LabelAttributesPanel.title"), true, NotifyDescriptor.OK_CANCEL_OPTION, null, null);
if (DialogDisplayer.getDefault().notify(dd).equals(NotifyDescriptor.OK_OPTION)) {
panel.unsetup();
return;
}
}
});
//Evt
model.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
refreshSharedConfig();
}
});
refreshSharedConfig();
}
Aggregations