private JPanel createDynamicCenterPanel(PrimitiveForm primitiveForm, DOTProperty property) { final JTable theTable = new JTable(); PrimitiveFormPropertyPair pfpPair = new PrimitiveFormPropertyPair(primitiveForm.getName(), property); _dynamicTables.put(pfpPair, theTable); DOTPoint dotPoint = (DOTPoint) _dotDefinitionDialogFrame.getScratchDisplayObjectType(); final DynamicDOTItemManager tableModel = (DynamicDOTItemManager) dotPoint.getTableModel(primitiveForm, property); theTable.setModel(tableModel); class NumberComparator implements Comparator<Number> { public int compare(Number o1, Number o2) { final double d1 = o1.doubleValue(); final double d2 = o2.doubleValue(); if (d1 < d2) { return -1; } if (d1 == d2) { return 0; } return 1; } } TableRowSorter<DynamicDOTItemManager> tableRowSorter = new TableRowSorter<DynamicDOTItemManager>(); tableRowSorter.setModel(tableModel); tableRowSorter.setComparator(4, new NumberComparator()); tableRowSorter.setComparator(5, new NumberComparator()); theTable.setRowSorter(tableRowSorter); JButton newDOTItemButton = new JButton("Neue Zeile"); newDOTItemButton.setEnabled(_dotDefinitionDialogFrame.isEditable()); JButton deleteDOTItemButton = new JButton("Zeile löschen"); deleteDOTItemButton.setEnabled(false); JButton showConflictsButton = new JButton("Zeige Konflikte"); addButtonListeners( primitiveForm, property, newDOTItemButton, deleteDOTItemButton, showConflictsButton); addListSelectionListener(theTable, deleteDOTItemButton); JPanel dotButtonsPanel = new JPanel(); dotButtonsPanel.setLayout(new SpringLayout()); dotButtonsPanel.add(newDOTItemButton); dotButtonsPanel.add(deleteDOTItemButton); dotButtonsPanel.add(showConflictsButton); dotButtonsPanel.setBorder(BorderFactory.createEmptyBorder(5, 10, 5, 10)); SpringUtilities.makeCompactGrid(dotButtonsPanel, 1, 5, 20); JPanel thePanel = new JPanel(); thePanel.setLayout(new SpringLayout()); thePanel.setBorder(BorderFactory.createMatteBorder(2, 2, 2, 2, Color.BLACK)); thePanel.add(new JScrollPane(theTable)); thePanel.add(dotButtonsPanel); SpringUtilities.makeCompactGrid(thePanel, 2, 20, 5); return thePanel; }
public JPanel getAdditionalCharacteristicsPanel(final DisplayObjectType displayObjectType) { JLabel translationFactorLabel = new JLabel("Verschiebungsfaktor: "); SpinnerModel spinnerModel = new SpinnerNumberModel(100, 0, 5000, 1); _translationFactorSpinner.setModel(spinnerModel); _translationFactorSpinner.setMaximumSize(new Dimension(60, 30)); _translationFactorSpinner.setEnabled(_dotDefinitionDialogFrame.isEditable()); JPanel translationPanel = new JPanel(); translationPanel.setLayout(new BoxLayout(translationPanel, BoxLayout.X_AXIS)); translationPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 10)); translationPanel.add(translationFactorLabel); translationPanel.add(_translationFactorSpinner); JLabel joinByLineLabel = new JLabel("Verbindungslinie: "); _joinByLineCheckBox.setSelected(false); _joinByLineCheckBox.setEnabled(_dotDefinitionDialogFrame.isEditable()); JPanel joinByLinePanel = new JPanel(); joinByLinePanel.setLayout(new BoxLayout(joinByLinePanel, BoxLayout.X_AXIS)); joinByLinePanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); joinByLinePanel.add(joinByLineLabel); joinByLinePanel.add(_joinByLineCheckBox); JPanel invisiblePanel = new JPanel(); invisiblePanel.add(new JTextField()); invisiblePanel.setVisible(false); JPanel thePanel = new JPanel(); thePanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 10)); thePanel.setLayout(new SpringLayout()); thePanel.add(translationPanel); thePanel.add(joinByLinePanel); thePanel.add(invisiblePanel); SpringUtilities.makeCompactGrid(thePanel, 3, 5, 5); if (displayObjectType != null) { DOTPoint dotPoint = (DOTPoint) displayObjectType; _translationFactorSpinner.setValue(dotPoint.getTranslationFactor()); _joinByLineCheckBox.setSelected(dotPoint.isJoinByLine()); } addChangeListeners(); // Erst jetzt, denn sonst werden die Setzungen von // _translationFactorSpinner und _joinByLineCheckBox schon verarbeitet! return thePanel; }
private StaticPanel createStaticComboBoxPanel( PrimitiveForm primitiveForm, DOTProperty property, String labelText, Object[] items) { JLabel label = new JLabel(labelText); JComboBox comboBox = new JComboBox(items); comboBox.setMaximumSize(new Dimension(300, 25)); comboBox.setEnabled(_dotDefinitionDialogFrame.isEditable()); StaticPanel thePanel = new StaticPanel(primitiveForm, property); thePanel.setMaximumSize(new Dimension(300, 25)); thePanel.setLayout(new SpringLayout()); thePanel.setBorder(BorderFactory.createMatteBorder(2, 2, 2, 2, Color.BLACK)); thePanel.add(label); thePanel.add(comboBox); SpringUtilities.makeCompactGrid(thePanel, 2, 5, 5); thePanel.setValue(comboBox); thePanel.addListener(comboBox); return thePanel; }
private StaticPanel createStaticSpinnerPanel( PrimitiveForm primitiveForm, DOTProperty property, String labelText, SpinnerModel spinnerModel) { JLabel label = new JLabel(labelText); JSpinner spinner = new JSpinner(spinnerModel); spinner.setMaximumSize(new Dimension(200, 20)); spinner.setEnabled(_dotDefinitionDialogFrame.isEditable()); StaticPanel thePanel = new StaticPanel(primitiveForm, property); thePanel.setLayout(new SpringLayout()); thePanel.setBorder(BorderFactory.createMatteBorder(2, 2, 2, 2, Color.BLACK)); thePanel.add(label); thePanel.add(spinner); SpringUtilities.makeCompactGrid(thePanel, 2, 5, 5); thePanel.setValue(spinner); thePanel.addListener(spinner); return thePanel; }
DOTItemDialog() { super(); _primitiveForm = primitiveForm; _property = property; _dynamicDefinitionComponent = new DynamicDefinitionComponent(_configuration, new DOTPointPlugin()); final Object propertyValue = initDynamicDefinitionComponent(); final JPanel panel = new JPanel(); panel.setLayout(new SpringLayout()); JLabel aLabel = null; if (_property == DOTProperty.DURCHMESSER) { aLabel = new JLabel("Durchmesser: "); if (propertyValue != null) { _diameterSpinner.setValue(propertyValue); } _component = _diameterSpinner; } else if (_property == DOTProperty.FARBE || _property == DOTProperty.FUELLUNG) { aLabel = new JLabel("Farbe: "); if (propertyValue != null) { _colorComboBox.setSelectedItem(propertyValue); } _component = _colorComboBox; } else if (_property == DOTProperty.GROESSE) { aLabel = new JLabel("Schriftgröße: "); if (propertyValue != null) { _textSizeSpinner.setValue(propertyValue); } _component = _textSizeSpinner; } else if (_property == DOTProperty.STRICHBREITE) { aLabel = new JLabel("Strichbreite: "); if (propertyValue != null) { _strokeWidthSpinner.setValue(propertyValue); } _component = _strokeWidthSpinner; } else if (_property == DOTProperty.TEXT) { aLabel = new JLabel("Text: "); prepareTextComboBox(propertyValue); _component = _textComboBox; } else if (_property == DOTProperty.TEXTSTIL) { aLabel = new JLabel("Textstil: "); if (propertyValue != null) { _textStyleComboBox.setSelectedItem(propertyValue); } _component = _textStyleComboBox; } else if (_property == DOTProperty.TRANSPARENZ) { aLabel = new JLabel("Tranzparenz: "); if (propertyValue != null) { _transparencySpinner.setValue(propertyValue); } _component = _transparencySpinner; } panel.add(aLabel); panel.add(_component); panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 0)); SpringUtilities.makeCompactGrid(panel, 2, 20, 5); final JButton saveButton = new JButton("Speichern"); saveButton.setEnabled(_dotDefinitionDialogFrame.isEditable()); final JButton cancelButton = new JButton("Dialog schließen"); final JPanel buttonsPanel = new JPanel(); buttonsPanel.setLayout(new SpringLayout()); buttonsPanel.add(saveButton); buttonsPanel.add(cancelButton); buttonsPanel.setBorder(BorderFactory.createEmptyBorder(5, 10, 5, 10)); SpringUtilities.makeCompactGrid(buttonsPanel, 2, 20, 5); addButtonListeners(saveButton, cancelButton); setTitle("GND: Darstellungsfestlegung für Punkte"); setLayout(new BorderLayout()); add(new JScrollPane(panel), BorderLayout.NORTH); add(new JScrollPane(_dynamicDefinitionComponent), BorderLayout.CENTER); add(buttonsPanel, BorderLayout.SOUTH); pack(); setSize(700, 550); final Rectangle bounds = getBounds(); setLocation( new Point((int) (bounds.getHeight() / 1.5 + 300), (int) (bounds.getWidth() / 1.5))); }