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; }
private JPanel createStaticCenterPanel(PrimitiveForm primitiveForm, DOTProperty property) { final PrimitiveFormType primitiveFormType = primitiveForm.getType(); if (primitiveFormType.equals(PrimitiveFormType.PUNKT)) { if (property.equals(DOTProperty.DURCHMESSER)) { return createStaticDiameterPanel(primitiveForm, property); } else if (property.equals(DOTProperty.FARBE)) { return createStaticColorPanel(primitiveForm, property); } } else if (primitiveFormType.equals(PrimitiveFormType.RECHTECK) || primitiveFormType.equals(PrimitiveFormType.KREIS) || primitiveFormType.equals(PrimitiveFormType.HALBKREIS)) { if (property.equals(DOTProperty.FUELLUNG)) { return createStaticColorPanel(primitiveForm, property); } else if (property.equals(DOTProperty.STRICHBREITE)) { return createStaticStrokeWidthPanel(primitiveForm, property); } else if (property.equals(DOTProperty.TRANSPARENZ)) { return createStaticTransparencyPanel(primitiveForm, property); } } else if (primitiveFormType.equals(PrimitiveFormType.TEXTDARSTELLUNG)) { if (property.equals(DOTProperty.FARBE)) { return createStaticColorPanel(primitiveForm, property); } else if (property.equals(DOTProperty.GROESSE)) { return createStaticTextsizePanel(primitiveForm, property); } else if (property.equals(DOTProperty.TEXT)) { return createStaticTextPanel(primitiveForm, property); } else if (property.equals(DOTProperty.TEXTSTIL)) { return createStaticTextstylePanel(primitiveForm, property); } } return null; }
public JPanel getDOTItemDefinitionPanel() { DOTPoint dotPoint = (DOTPoint) _dotDefinitionDialogFrame.getScratchDisplayObjectType(); final PrimitiveForm primitiveForm = dotPoint.getPrimitiveForm(_dotDefinitionDialogFrame.getSelectedPrimitiveForm()); final DOTProperty property = _dotDefinitionDialogFrame.getSelectedProperty(); if ((primitiveForm == null) || (property == null)) { return null; } PrimitiveFormPropertyPair pfpPair = new PrimitiveFormPropertyPair(primitiveForm.getName(), property); final boolean isStatic = _dotDefinitionDialogFrame.getStaticCheckBoxState(); if (isStatic) { if (!_staticPanels.containsKey(pfpPair)) { _staticPanels.put(pfpPair, createStaticCenterPanel(primitiveForm, property)); } return _staticPanels.get(pfpPair); } else { if (!_dynamicPanels.containsKey(pfpPair)) { _dynamicPanels.put(pfpPair, createDynamicCenterPanel(primitiveForm, property)); } return _dynamicPanels.get(pfpPair); } }