use of org.gephi.visualization.VizModel in project gephi by gephi.
the class GlobalSettingsPanel method setup.
public void setup() {
VizModel vizModel = VizController.getInstance().getVizModel();
vizModel.addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
if (evt.getPropertyName().equals("init")) {
refreshSharedConfig();
} else if (evt.getPropertyName().equals("backgroundColor")) {
refreshSharedConfig();
} else if (evt.getPropertyName().equals("autoSelectNeighbor")) {
refreshSharedConfig();
} else if (evt.getPropertyName().equals("lightenNonSelectedAuto")) {
refreshSharedConfig();
} else if (evt.getPropertyName().equals("use3d")) {
refreshSharedConfig();
}
}
});
refreshSharedConfig();
hightlightCheckBox.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
VizModel vizModel = VizController.getInstance().getVizModel();
vizModel.setLightenNonSelectedAuto(hightlightCheckBox.isSelected());
}
});
((JColorButton) backgroundColorButton).addPropertyChangeListener(JColorButton.EVENT_COLOR, new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
VizModel vizModel = VizController.getInstance().getVizModel();
vizModel.setBackgroundColor(((JColorButton) backgroundColorButton).getColor());
}
});
autoSelectNeigborCheckbox.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
VizModel vizModel = VizController.getInstance().getVizModel();
vizModel.setAutoSelectNeighbor(autoSelectNeigborCheckbox.isSelected());
}
});
zoomSlider.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
int cam = (int) VizController.getInstance().getVizModel().getCameraDistance();
if (zoomSlider.getValue() != cam && cam < zoomSlider.getMaximum()) {
GraphIO io = VizController.getInstance().getGraphIO();
io.setCameraDistance(zoomSlider.getValue());
}
}
});
}
use of org.gephi.visualization.VizModel in project gephi by gephi.
the class VizBarController method createDefaultGroups.
private void createDefaultGroups() {
groups = new VizToolbarGroup[4];
groups[0] = new GlobalGroupBar();
groups[1] = new NodeGroupBar();
groups[2] = new EdgeGroupBar();
groups[3] = new LabelGroupBar();
VizModel model = VizController.getInstance().getVizModel();
model.addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
if (evt.getPropertyName().equals("init")) {
VizModel model = VizController.getInstance().getVizModel();
toolbar.setEnable(!model.isDefaultModel());
((NodeGroupBar) groups[1]).setModelValues(model);
((EdgeGroupBar) groups[2]).setModelValues(model);
((LabelGroupBar) groups[3]).setModelValues(model);
}
}
});
}
use of org.gephi.visualization.VizModel in project gephi by gephi.
the class EdgeSettingsPanel method refreshSharedConfig.
private void refreshSharedConfig() {
VizModel vizModel = VizController.getInstance().getVizModel();
setEnable(!vizModel.isDefaultModel());
if (vizModel.isDefaultModel()) {
return;
}
if (showEdgesCheckbox.isSelected() != vizModel.isShowEdges()) {
showEdgesCheckbox.setSelected(vizModel.isShowEdges());
}
float[] edgeCol = vizModel.getEdgeUniColor();
((JColorButton) edgeColorButton).setColor(new Color(edgeCol[0], edgeCol[1], edgeCol[2], edgeCol[3]));
if (sourceNodeColorCheckbox.isSelected() != !vizModel.isEdgeHasUniColor()) {
sourceNodeColorCheckbox.setSelected(!vizModel.isEdgeHasUniColor());
}
if (selectionColorCheckbox.isSelected() != vizModel.isEdgeSelectionColor()) {
selectionColorCheckbox.setSelected(vizModel.isEdgeSelectionColor());
}
Color in = new Color(ColorSpace.getInstance(ColorSpace.CS_sRGB), vizModel.getEdgeInSelectionColor(), 1f);
Color out = new Color(ColorSpace.getInstance(ColorSpace.CS_sRGB), vizModel.getEdgeOutSelectionColor(), 1f);
Color both = new Color(ColorSpace.getInstance(ColorSpace.CS_sRGB), vizModel.getEdgeBothSelectionColor(), 1f);
if (!edgeInSelectionColorChooser.getColor().equals(in)) {
edgeInSelectionColorChooser.setColor(in);
}
if (!edgeBothSelectionColorChooser.getColor().equals(both)) {
edgeBothSelectionColorChooser.setColor(both);
}
if (!edgeOutSelectionColorChooser.getColor().equals(out)) {
edgeOutSelectionColorChooser.setColor(out);
}
if (scaleSlider.getValue() / 10f + 0.1f != vizModel.getEdgeScale()) {
scaleSlider.setValue((int) ((vizModel.getEdgeScale() - 0.1f) * 10));
}
}
use of org.gephi.visualization.VizModel 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