use of javax.swing.DefaultComboBoxModel in project gephi by gephi.
the class EdgeListPanel method setSQLDrivers.
public void setSQLDrivers(SQLDriver[] drivers) {
DefaultComboBoxModel driverModel = new DefaultComboBoxModel(drivers);
driverComboBox.setModel(driverModel);
}
use of javax.swing.DefaultComboBoxModel 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();
}
use of javax.swing.DefaultComboBoxModel in project libgdx by libgdx.
the class BillboardBatchPanel method initializeComponents.
private void initializeComponents(BillboardParticleBatch renderer) {
//Align
alignCombo = new JComboBox();
alignCombo.setModel(new DefaultComboBoxModel(AlignModeWrapper.values()));
alignCombo.setSelectedItem(getAlignModeWrapper(renderer.getAlignMode()));
alignCombo.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
AlignModeWrapper align = (AlignModeWrapper) alignCombo.getSelectedItem();
editor.getBillboardBatch().setAlignMode(align.mode);
}
});
//Cpu/Gpu
useGPUBox = new JCheckBox();
useGPUBox.setSelected(renderer.isUseGPU());
useGPUBox.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent event) {
editor.getBillboardBatch().setUseGpu(useGPUBox.isSelected());
}
});
//Sort
sortCombo = new JComboBox();
sortCombo.setModel(new DefaultComboBoxModel(SortMode.values()));
sortCombo.setSelectedItem(getSortMode(renderer.getSorter()));
sortCombo.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
SortMode mode = (SortMode) sortCombo.getSelectedItem();
editor.getBillboardBatch().setSorter(mode.sorter);
}
});
int i = 0;
contentPanel.add(new JLabel("Align"), new GridBagConstraints(0, i, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(6, 0, 0, 0), 0, 0));
contentPanel.add(alignCombo, new GridBagConstraints(1, i++, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(6, 0, 0, 0), 0, 0));
contentPanel.add(new JLabel("Use GPU"), new GridBagConstraints(0, i, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(6, 0, 0, 0), 0, 0));
contentPanel.add(useGPUBox, new GridBagConstraints(1, i++, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(6, 0, 0, 0), 0, 0));
contentPanel.add(new JLabel("Sort"), new GridBagConstraints(0, i, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(6, 0, 0, 0), 0, 0));
contentPanel.add(sortCombo, new GridBagConstraints(1, i, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(6, 0, 0, 0), 0, 0));
}
use of javax.swing.DefaultComboBoxModel in project libgdx by libgdx.
the class TextureLoaderPanel method initializeComponents.
@Override
protected void initializeComponents() {
super.initializeComponents();
JButton atlasButton = new JButton("Open Atlas");
JButton textureButton = new JButton("Open Texture");
JButton defaultTextureButton = new JButton("Default Texture");
final JCheckBox genMipMaps = new JCheckBox("Generate MipMaps");
final JComboBox minFilterBox = new JComboBox(new DefaultComboBoxModel(TextureFilter.values()));
final JComboBox magFilterBox = new JComboBox(new DefaultComboBoxModel(TextureFilter.values()));
minFilterBox.setSelectedItem(editor.getTexture().getMinFilter());
magFilterBox.setSelectedItem(editor.getTexture().getMagFilter());
ActionListener filterListener = new ActionListener() {
public void actionPerformed(ActionEvent event) {
editor.getTexture().setFilter((TextureFilter) minFilterBox.getSelectedItem(), (TextureFilter) magFilterBox.getSelectedItem());
}
};
minFilterBox.addActionListener(filterListener);
magFilterBox.addActionListener(filterListener);
atlasButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
File file = editor.showFileLoadDialog();
if (file != null) {
TextureAtlas atlas = editor.load(file.getAbsolutePath(), TextureAtlas.class, null, null);
if (atlas != null) {
editor.setAtlas(atlas);
}
}
}
});
textureButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
File file = editor.showFileLoadDialog();
if (file != null) {
TextureParameter params = new TextureParameter();
params.genMipMaps = genMipMaps.isSelected();
params.minFilter = (TextureFilter) minFilterBox.getSelectedItem();
params.magFilter = (TextureFilter) magFilterBox.getSelectedItem();
Texture texture = editor.load(file.getAbsolutePath(), Texture.class, null, params);
if (texture != null) {
editor.setTexture(texture);
}
}
}
});
defaultTextureButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
editor.setTexture(editor.assetManager.get(FlameMain.DEFAULT_BILLBOARD_PARTICLE, Texture.class));
}
});
contentPanel.add(new JLabel("Min. Filter"), new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(6, 0, 0, 0), 0, 0));
contentPanel.add(minFilterBox, new GridBagConstraints(1, 0, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(6, 0, 0, 0), 0, 0));
contentPanel.add(new JLabel("Mag. Filter"), new GridBagConstraints(0, 1, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(6, 0, 0, 0), 0, 0));
contentPanel.add(magFilterBox, new GridBagConstraints(1, 1, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(6, 0, 0, 0), 0, 0));
contentPanel.add(genMipMaps, new GridBagConstraints(0, 2, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(6, 0, 0, 0), 0, 0));
contentPanel.add(atlasButton, new GridBagConstraints(0, 3, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(6, 0, 0, 0), 0, 0));
contentPanel.add(textureButton, new GridBagConstraints(1, 3, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(6, 0, 0, 0), 0, 0));
contentPanel.add(defaultTextureButton, new GridBagConstraints(2, 3, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(6, 0, 0, 0), 0, 0));
}
use of javax.swing.DefaultComboBoxModel in project libgdx by libgdx.
the class SpawnInfluencerPanel method initializeComponents.
protected void initializeComponents() {
super.initializeComponents();
pointSpawnShapeValue = new PointSpawnShapeValue();
lineSpawnShapeValue = new LineSpawnShapeValue();
rectangleSpawnShapeValue = new RectangleSpawnShapeValue();
ellipseSpawnShapeValue = new EllipseSpawnShapeValue();
cylinderSpawnShapeValue = new CylinderSpawnShapeValue();
meshSpawnShapeValue = new UnweightedMeshSpawnShapeValue();
weightMeshSpawnShapeValue = new WeightMeshSpawnShapeValue();
lineSpawnShapeValue.setDimensions(6, 6, 6);
rectangleSpawnShapeValue.setDimensions(6, 6, 6);
ellipseSpawnShapeValue.setDimensions(6, 6, 6);
cylinderSpawnShapeValue.setDimensions(6, 6, 6);
pointSpawnShapeValue.setActive(true);
lineSpawnShapeValue.setActive(true);
rectangleSpawnShapeValue.setActive(true);
ellipseSpawnShapeValue.setActive(true);
cylinderSpawnShapeValue.setActive(true);
meshSpawnShapeValue.setActive(true);
weightMeshSpawnShapeValue.setActive(true);
Model defaultModel = editor.assetManager.get(FlameMain.DEFAULT_MODEL_PARTICLE);
Array<Model> models = new Array<Model>();
models.add(defaultModel);
int i = 0;
JPanel panel = new JPanel(new GridBagLayout());
EditorPanel.addContent(panel, i, 0, new JLabel("Shape"), false, GridBagConstraints.WEST, GridBagConstraints.NONE, 0, 0);
EditorPanel.addContent(panel, i++, 1, shapeCombo = new JComboBox(new DefaultComboBoxModel(spawnShapes)), false, GridBagConstraints.WEST, GridBagConstraints.NONE, 1, 0);
EditorPanel.addContent(panel, i, 0, edgesLabel = new JLabel("Edges"), false, GridBagConstraints.WEST, GridBagConstraints.NONE, 0, 0);
EditorPanel.addContent(panel, i++, 1, edgesCheckbox = new JCheckBox(), false, GridBagConstraints.WEST, GridBagConstraints.NONE, 0, 0);
EditorPanel.addContent(panel, i, 0, sideLabel = new JLabel("Side"), false, GridBagConstraints.WEST, GridBagConstraints.NONE, 0, 0);
EditorPanel.addContent(panel, i++, 1, sideCombo = new JComboBox(new DefaultComboBoxModel(SpawnSide.values())), false, GridBagConstraints.WEST, GridBagConstraints.NONE, 1, 0);
edgesCheckbox.setHorizontalTextPosition(SwingConstants.LEFT);
i = 0;
addContent(i++, 0, panel, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL);
addContent(i++, 0, meshPanel = new TemplatePickerPanel<Model>(editor, models, this, Model.class, new LoaderButton.ModelLoaderButton(editor), true, false), false, GridBagConstraints.WEST, GridBagConstraints.NONE);
addContent(i++, 0, xPanel = new RangedNumericPanel(editor, pointSpawnShapeValue.xOffsetValue, "X Offset", "Amount to offset a particle's starting X location, in world units.", false));
addContent(i++, 0, yPanel = new RangedNumericPanel(editor, pointSpawnShapeValue.yOffsetValue, "Y Offset", "Amount to offset a particle's starting Y location, in world units.", false));
addContent(i++, 0, zPanel = new RangedNumericPanel(editor, pointSpawnShapeValue.zOffsetValue, "Z Offset", "Amount to offset a particle's starting Z location, in world units.", false));
addContent(i++, 0, widthPanel = new ScaledNumericPanel(editor, pointSpawnShapeValue.getSpawnWidth(), "Duration", "Spawn Width", "Width of the spawn shape, in world units.", true));
addContent(i++, 0, heightPanel = new ScaledNumericPanel(editor, pointSpawnShapeValue.getSpawnWidth(), "Duration", "Spawn Height", "Height of the spawn shape, in world units.", true));
addContent(i++, 0, depthPanel = new ScaledNumericPanel(editor, pointSpawnShapeValue.getSpawnWidth(), "Duration", "Spawn Depth", "Depth of the spawn shape, in world units.", true), false);
meshPanel.setIsAlwayShown(true);
onTemplateChecked(defaultModel, true);
shapeCombo.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
String shape = (String) shapeCombo.getSelectedItem();
if (shape == SPAWN_SHAPE_POINT) {
setPrimitiveSpawnShape(pointSpawnShapeValue, false, null);
} else if (shape == SPAWN_SHAPE_LINE) {
setPrimitiveSpawnShape(lineSpawnShapeValue, false, null);
} else if (shape == SPAWN_SHAPE_RECTANGLE) {
setPrimitiveSpawnShape(rectangleSpawnShapeValue, true, null);
} else if (shape == SPAWN_SHAPE_ELLIPSE) {
setPrimitiveSpawnShape(ellipseSpawnShapeValue, true, ellipseSpawnShapeValue.getSide());
} else if (shape == SPAWN_SHAPE_CYLINDER) {
setPrimitiveSpawnShape(cylinderSpawnShapeValue, true, null);
} else if (shape == SPAWN_SHAPE_MESH) {
setMeshSpawnShape(meshSpawnShapeValue);
} else if (shape == SPAWN_SHAPE_WEIGHT_MESH) {
setMeshSpawnShape(weightMeshSpawnShapeValue);
}
editor.restart();
}
});
edgesCheckbox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
SpawnInfluencer influencer = (SpawnInfluencer) editor.getEmitter().findInfluencer(SpawnInfluencer.class);
PrimitiveSpawnShapeValue shapeValue = (PrimitiveSpawnShapeValue) influencer.spawnShapeValue;
shapeValue.setEdges(edgesCheckbox.isSelected());
setEdgesVisible(true);
}
});
sideCombo.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
SpawnSide side = (SpawnSide) sideCombo.getSelectedItem();
SpawnInfluencer influencer = (SpawnInfluencer) editor.getEmitter().findInfluencer(SpawnInfluencer.class);
EllipseSpawnShapeValue shapeValue = (EllipseSpawnShapeValue) influencer.spawnShapeValue;
shapeValue.setSide(side);
}
});
}
Aggregations