1. Dmytro Kovalchuk
  2. cross-stitch-patches

Commits

Dmytro Kovalchuk  committed 70f2690

Applying patches

  • Participants
  • Parent commits bd2b6fd
  • Branches default

Comments (0)

Files changed (3)

File colorSwatches

  • Ignore whitespace
-# HG changeset patch
-# Parent 73da8e6d3f5d5a90c3144172952e294f411027eb
-Changing algorithm of laying out color swatches
-
-diff -r 73da8e6d3f5d src/main/java/net/anatolich/cstitch/ui/dialogs/PaletteColorPickerPanel.java
---- a/src/main/java/net/anatolich/cstitch/ui/dialogs/PaletteColorPickerPanel.java	Tue Apr 10 13:23:40 2012 +0300
-+++ b/src/main/java/net/anatolich/cstitch/ui/dialogs/PaletteColorPickerPanel.java	Tue Apr 10 13:55:21 2012 +0300
-@@ -19,6 +19,7 @@
- import java.awt.Component;
- import java.awt.Dimension;
- import java.util.Enumeration;
-+import java.util.Iterator;
- import javax.swing.*;
- import javax.swing.colorchooser.AbstractColorChooserPanel;
- import javax.swing.event.ListSelectionEvent;
-@@ -38,6 +39,7 @@
-  */
- public class PaletteColorPickerPanel extends AbstractColorChooserPanel {
- 
-+    private static final Dimension SWATCH_SIZE = new Dimension(16, 16);
-     private JTable swatchesTable;
-     private final Palette palette;
- 
-@@ -51,7 +53,7 @@
- 
-     @Override
-     protected void buildChooser() {
--        
-+
-         createSwatchesTable(createColorModel());
- 
-         setLayout(new BorderLayout());
-@@ -68,22 +70,27 @@
-         };
- 
-         final int colorsCount = palette.getColors().size();
--        final int width = (int) Math.round(Math.sqrt(colorsCount));
-+        final int width = (int) Math.ceil(Math.sqrt(colorsCount));
-+        int height = (int) Math.ceil(colorsCount / width);
-+        if (colorsCount % width > 0) {
-+            height++;
-+        }
- 
-         tableModel.setColumnCount(width);
-+        tableModel.setRowCount(height);
-+        Iterator<PaletteColor> colorsIterator = palette.getColors().iterator();
- 
--        int column = 0;
--        int row = -1;
--        for (PaletteColor color : palette.getColors()) {
--            if (column % width == 0) {
--                row++;
--                tableModel.setRowCount(row + 1);
--                column = 0;
-+        for (int y = 0; y < height; y++) {
-+            for (int x = 0; x < width; x++) {
-+                if (colorsIterator.hasNext()) {
-+                    PaletteColor color = colorsIterator.next();
-+                    tableModel.setValueAt(color, y, x);
-+                } else {
-+                    break;
-+                }
-             }
--            tableModel.setValueAt(color, row, column);
--            column++;
-+        }
- 
--        }
-         return tableModel;
- 
-     }
-@@ -114,8 +121,6 @@
- 
-     private class PaletteColorCellRenderer extends JLabel implements TableCellRenderer {
- 
--        private final Dimension swatchSize = new Dimension(16, 16);
--
-         @Override
-         public Component getTableCellRendererComponent(JTable table, Object value,
-                 boolean isSelected, boolean hasFocus, int row, int column) {
-@@ -130,7 +135,7 @@
-             setText(" ");
-             setOpaque(true);
-             setToolTipText(color.getName());
--            setSize(swatchSize);
-+            setSize(SWATCH_SIZE);
-             if (isSelected) {
-                 setBorder(BorderFactory.createLoweredSoftBevelBorder());
-             } else {
-@@ -144,7 +149,7 @@
- 
-         @Override
-         public void valueChanged(ListSelectionEvent e) {
--            if (e.getValueIsAdjusting()){
-+            if (e.getValueIsAdjusting()) {
-                 return;
-             }
-             final int column = swatchesTable.getSelectedColumn();
-diff -r 73da8e6d3f5d src/main/java/net/anatolich/cstitch/ui/editor/legend/JLegendPanel.java
---- a/src/main/java/net/anatolich/cstitch/ui/editor/legend/JLegendPanel.java	Tue Apr 10 13:23:40 2012 +0300
-+++ b/src/main/java/net/anatolich/cstitch/ui/editor/legend/JLegendPanel.java	Tue Apr 10 13:55:21 2012 +0300
-@@ -46,7 +46,6 @@
- 
-     private static final int SWATCH_WIDTH = 24;
-     private static final int SWATCH_HEIGHT = 24;
--    private AbstractAction[] actions;
-     private DefaultListModel defaultListModel;
-     private Legend legend = new DefaultLegend();
-     private JList colorList;
-@@ -93,9 +92,9 @@
-                 }
-             }
-         });
--        add(availableColorsPanel, BorderLayout.SOUTH);
-+        add(availableColorsPanel, BorderLayout.NORTH);
- 
--        setPreferredSize(new Dimension(360, 600));
-+        setPreferredSize(new Dimension(400, 800));
-     }
- 
-     private class ColorCellRenderer extends JLabel implements ListCellRenderer {
-@@ -144,20 +143,11 @@
-         firePropertyChange("legend", oldValue, legend);
-     }
- 
--    @Deprecated
--    public AbstractAction[] getActions() {
--        if (actions == null) {
--            actions = new AbstractAction[]{
--                new AddColorAction()
--            };
--        }
--        return actions;
--    }
--
-     private JColorChooser getColorChooser() {
-         if (colorChooser == null) {
-             colorChooser = new JColorChooser();
--            colorChooser.setPreferredSize(new Dimension(320, 480));
-+            colorChooser.setPreviewPanel(new JPanel());
-+            colorChooser.setPreferredSize(new Dimension(400, 400));
-             colorChooser.setChooserPanels(new AbstractColorChooserPanel[0]);
-             for (Palette palette : paletteService.getPalettes()) {
-                 colorChooser.addChooserPanel(
-@@ -169,48 +159,6 @@
-         return colorChooser;
-     }
- 
--    private class AddColorAction extends AbstractAction {
--
--        private JDialog colorChooserDialog;
--
--        public AddColorAction() {
--            putValue(NAME, "Add color");
--            putValue(MNEMONIC_KEY, KeyEvent.VK_A);
--            getColorChooser();
--            getColorDialog();
--        }
--
--        private JDialog getColorDialog() throws HeadlessException {
--            if (colorChooserDialog == null) {
--                colorChooserDialog = JColorChooser.createDialog(JLegendPanel.this,
--                        "Select color", true, getColorChooser(), okListener, cancelListener);
--            }
--            return colorChooserDialog;
--        }
--
--        @Override
--        public void actionPerformed(ActionEvent e) {
--            getColorDialog().setVisible(true);
--        }
--        private ActionListener okListener = new ActionListener() {
--
--            @Override
--            public void actionPerformed(ActionEvent e) {
--                final PaletteColor color = (PaletteColor) getColorChooser().getColor();
--                if (color != null) {
--                    legend.addColor(color);
--                    legend.setSelectedColor(color);
--                }
--            }
--        };
--        private ActionListener cancelListener = new ActionListener() {
--
--            @Override
--            public void actionPerformed(ActionEvent e) {
--            }
--        };
--    }
--
-     @Override
-     public void colorAdded(Legend legend, PaletteColor color) {
-         defaultListModel.addElement(color);

File mainWindow

  • Ignore whitespace
-# HG changeset patch
-# Parent 51f1ac2e6a88d15720444764e7ae5c6328f30cac
-Removed unused variable in main window
-
-diff -r 51f1ac2e6a88 src/main/java/net/anatolich/cstitch/MainWindow.java
---- a/src/main/java/net/anatolich/cstitch/MainWindow.java	Tue Apr 10 12:58:14 2012 +0300
-+++ b/src/main/java/net/anatolich/cstitch/MainWindow.java	Tue Apr 10 13:23:40 2012 +0300
-@@ -54,7 +54,6 @@
-     private JMenuBar menuBar;
-     private JMenu menuFile;
-     private JMenuItem menuFileNew;
--    private JMenu menuLegend;
-     private JMenu menuTools;
-     private JToolBar toolbar;
-     private ToolsService toolsService;
-@@ -88,8 +87,7 @@
-         mainSplitPane.setPreferredSize(mainSplitterSize);
-         mainSplitPane.setSize(mainSplitterSize);
-         mainSplitPane.setDividerLocation(schemaEditor.getPreferredSize().width + mainSplitPane.getDividerSize());
--        mainSplitPane.setOneTouchExpandable(true);
--
-+        mainSplitPane.setResizeWeight(1.0);
-         add(mainSplitPane, BorderLayout.CENTER);
- 
-         createMenu();

File series

View file
  • Ignore whitespace
-mainWindow
-colorSwatches
 # Placed by Bitbucket