From 8743d446d245334d396500b87fe0d852dc52fe40 Mon Sep 17 00:00:00 2001 From: Mathieu Bastian Date: Tue, 23 Jul 2013 08:05:46 -0700 Subject: [PATCH] Implement category and transformer toolbar system --- .../org/gephi/appearance/spi/Category.java | 64 ------ .../gephi/appearance/spi/TransformerUI.java | 2 + .../gephi/appearance/spi/Bundle.properties | 5 - modules/AppearancePluginUI/pom.xml | 1 + .../PartitionColorTransformerPanel.java | 53 +++-- .../PartitionElementColorTransformerUI.java | 11 +- .../plugin/RankingColorTransformerPanel.form | 2 +- .../plugin/RankingColorTransformerPanel.java | 6 +- .../RankingElementColorTransformerUI.java | 11 +- .../UniqueElementColorTransformerUI.java | 11 +- .../plugin/UniqueNodeSizeTransformerUI.java | 11 +- .../plugin/category/DefaultCategory.java | 96 +++++++++ .../ui/appearance/plugin/Bundle.properties | 1 + .../plugin/category/Bundle.properties | 3 + .../plugin/resources/color-swatch.png | Bin 0 -> 359 bytes .../plugin/resources/color.png | Bin .../plugin/resources/labelcolor.png | Bin .../plugin/resources/labelsize.png | Bin .../plugin/resources/randomize.png | Bin .../plugin/resources/size.png | Bin .../desktop/appearance/AppearanceToolbar.java | 193 +++++++++++++++--- .../appearance/AppearanceTopComponent.form | 18 +- .../appearance/AppearanceTopComponent.java | 7 +- .../appearance/AppearanceUIController.java | 54 ++++- .../desktop/appearance/AppearanceUIModel.java | 48 ++++- .../appearance/AppearanceUIModelEvent.java | 4 +- modules/DesktopExport/pom.xml | 2 +- modules/FiltersAPI/pom.xml | 2 +- .../ui/ranking/plugin/RecentPalettes.java | 113 +++++----- 29 files changed, 506 insertions(+), 212 deletions(-) create mode 100644 modules/AppearancePluginUI/src/main/java/org/gephi/ui/appearance/plugin/category/DefaultCategory.java create mode 100644 modules/AppearancePluginUI/src/main/resources/org/gephi/ui/appearance/plugin/category/Bundle.properties create mode 100644 modules/AppearancePluginUI/src/main/resources/org/gephi/ui/appearance/plugin/resources/color-swatch.png rename modules/AppearancePluginUI/src/main/resources/org/gephi/ui/{partition => appearance}/plugin/resources/color.png (100%) rename modules/AppearancePluginUI/src/main/resources/org/gephi/ui/{partition => appearance}/plugin/resources/labelcolor.png (100%) rename modules/AppearancePluginUI/src/main/resources/org/gephi/ui/{partition => appearance}/plugin/resources/labelsize.png (100%) rename modules/AppearancePluginUI/src/main/resources/org/gephi/ui/{partition => appearance}/plugin/resources/randomize.png (100%) rename modules/AppearancePluginUI/src/main/resources/org/gephi/ui/{partition => appearance}/plugin/resources/size.png (100%) diff --git a/modules/AppearanceAPI/src/main/java/org/gephi/appearance/spi/Category.java b/modules/AppearanceAPI/src/main/java/org/gephi/appearance/spi/Category.java index 088ef33b1..519cc96cc 100644 --- a/modules/AppearanceAPI/src/main/java/org/gephi/appearance/spi/Category.java +++ b/modules/AppearanceAPI/src/main/java/org/gephi/appearance/spi/Category.java @@ -5,7 +5,6 @@ package org.gephi.appearance.spi; import javax.swing.Icon; -import org.openide.util.NbBundle; /** * @@ -20,67 +19,4 @@ public interface Category { public boolean isNode(); public boolean isEdge(); - public static Category NODE_SIZE = new Category() { - @Override - public String getName() { - return NbBundle.getMessage(Category.class, "Category.NodeSize.name"); - } - - @Override - public Icon getIcon() { - return null; - } - - @Override - public boolean isNode() { - return true; - } - - @Override - public boolean isEdge() { - return false; - } - }; - public static Category NODE_COLOR = new Category() { - @Override - public String getName() { - return NbBundle.getMessage(Category.class, "Category.NodeColor.name"); - } - - @Override - public Icon getIcon() { - return null; - } - - @Override - public boolean isNode() { - return true; - } - - @Override - public boolean isEdge() { - return false; - } - }; - public static Category EDGE_COLOR = new Category() { - @Override - public String getName() { - return NbBundle.getMessage(Category.class, "Category.EdgeColor.name"); - } - - @Override - public Icon getIcon() { - return null; - } - - @Override - public boolean isNode() { - return false; - } - - @Override - public boolean isEdge() { - return true; - } - }; } diff --git a/modules/AppearanceAPI/src/main/java/org/gephi/appearance/spi/TransformerUI.java b/modules/AppearanceAPI/src/main/java/org/gephi/appearance/spi/TransformerUI.java index f2a23cd53..3554dd961 100644 --- a/modules/AppearanceAPI/src/main/java/org/gephi/appearance/spi/TransformerUI.java +++ b/modules/AppearanceAPI/src/main/java/org/gephi/appearance/spi/TransformerUI.java @@ -16,6 +16,8 @@ public interface TransformerUI { public String getDisplayName(); + public String getDescription(); + public Icon getIcon(); public Class getTransformerClass(); diff --git a/modules/AppearanceAPI/src/main/resources/org/gephi/appearance/spi/Bundle.properties b/modules/AppearanceAPI/src/main/resources/org/gephi/appearance/spi/Bundle.properties index 8556e5c2c..e69de29bb 100644 --- a/modules/AppearanceAPI/src/main/resources/org/gephi/appearance/spi/Bundle.properties +++ b/modules/AppearanceAPI/src/main/resources/org/gephi/appearance/spi/Bundle.properties @@ -1,5 +0,0 @@ -Category.ElementSize.name = Size -Category.ElementColor.name = Color -Category.NodeSize.name = Size -Category.NodeColor.name = Color -Category.EdgeColor.name = Color \ No newline at end of file diff --git a/modules/AppearancePluginUI/pom.xml b/modules/AppearancePluginUI/pom.xml index bee8f8eec..6f2be842e 100644 --- a/modules/AppearancePluginUI/pom.xml +++ b/modules/AppearancePluginUI/pom.xml @@ -53,6 +53,7 @@ nbm-maven-plugin + org.gephi.ui.appearance.plugin.category diff --git a/modules/AppearancePluginUI/src/main/java/org/gephi/ui/appearance/plugin/PartitionColorTransformerPanel.java b/modules/AppearancePluginUI/src/main/java/org/gephi/ui/appearance/plugin/PartitionColorTransformerPanel.java index ff71a793c..f87d32032 100644 --- a/modules/AppearancePluginUI/src/main/java/org/gephi/ui/appearance/plugin/PartitionColorTransformerPanel.java +++ b/modules/AppearancePluginUI/src/main/java/org/gephi/ui/appearance/plugin/PartitionColorTransformerPanel.java @@ -43,8 +43,6 @@ package org.gephi.ui.appearance.plugin; import java.awt.Component; import java.awt.Graphics; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.beans.PropertyChangeEvent; @@ -53,7 +51,6 @@ import java.text.NumberFormat; import javax.swing.AbstractCellEditor; import javax.swing.Icon; import javax.swing.JLabel; -import javax.swing.JMenuItem; import javax.swing.JPopupMenu; import javax.swing.JTable; import javax.swing.table.DefaultTableModel; @@ -65,8 +62,6 @@ import org.gephi.appearance.api.Part; import org.gephi.appearance.api.Partition; import org.gephi.appearance.plugin.PartitionElementColorTransformer; import org.gephi.appearance.spi.PartitionTransformer; -import org.openide.util.ImageUtilities; -import org.openide.util.NbBundle; /** * @@ -157,30 +152,30 @@ public class PartitionColorTransformerPanel extends javax.swing.JPanel { } private void createPopup() { - popupMenu = new JPopupMenu(); - JMenuItem randomizeItem = new JMenuItem(NbBundle.getMessage(PartitionColorTransformerPanel.class, "NodeColorTransformerPanel.action.randomize")); - randomizeItem.setIcon(ImageUtilities.loadImageIcon("org/gephi/ui/partition/plugin/resources/randomize.png", false)); - randomizeItem.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { -// nodeColorTransformer.getMap().clear(); -// setup(partition, nodeColorTransformer, true); - revalidate(); - repaint(); - } - }); - popupMenu.add(randomizeItem); - JMenuItem allBlackItem = new JMenuItem(NbBundle.getMessage(PartitionColorTransformerPanel.class, "NodeColorTransformerPanel.action.allBlacks")); - allBlackItem.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { -// for (Entry entry : nodeColorTransformer.getMap().entrySet()) { -// entry.setValue(Color.BLACK); -// } -// setup(partition, nodeColorTransformer, false); - revalidate(); - repaint(); - } - }); - popupMenu.add(allBlackItem); +// popupMenu = new JPopupMenu(); +// JMenuItem randomizeItem = new JMenuItem(NbBundle.getMessage(PartitionColorTransformerPanel.class, "NodeColorTransformerPanel.action.randomize")); +// randomizeItem.setIcon(ImageUtilities.loadImageIcon("org/gephi/ui/partition/plugin/resources/randomize.png", false)); +// randomizeItem.addActionListener(new ActionListener() { +// public void actionPerformed(ActionEvent e) { +//// nodeColorTransformer.getMap().clear(); +//// setup(partition, nodeColorTransformer, true); +// revalidate(); +// repaint(); +// } +// }); +// popupMenu.add(randomizeItem); +// JMenuItem allBlackItem = new JMenuItem(NbBundle.getMessage(PartitionColorTransformerPanel.class, "NodeColorTransformerPanel.action.allBlacks")); +// allBlackItem.addActionListener(new ActionListener() { +// public void actionPerformed(ActionEvent e) { +//// for (Entry entry : nodeColorTransformer.getMap().entrySet()) { +//// entry.setValue(Color.BLACK); +//// } +//// setup(partition, nodeColorTransformer, false); +// revalidate(); +// repaint(); +// } +// }); +// popupMenu.add(allBlackItem); } class ColorChooserRenderer extends JLabel implements TableCellRenderer { diff --git a/modules/AppearancePluginUI/src/main/java/org/gephi/ui/appearance/plugin/PartitionElementColorTransformerUI.java b/modules/AppearancePluginUI/src/main/java/org/gephi/ui/appearance/plugin/PartitionElementColorTransformerUI.java index 71f53728c..8a38a5250 100644 --- a/modules/AppearancePluginUI/src/main/java/org/gephi/ui/appearance/plugin/PartitionElementColorTransformerUI.java +++ b/modules/AppearancePluginUI/src/main/java/org/gephi/ui/appearance/plugin/PartitionElementColorTransformerUI.java @@ -11,12 +11,16 @@ import org.gephi.appearance.plugin.PartitionElementColorTransformer; import org.gephi.appearance.spi.Category; import org.gephi.appearance.spi.PartitionTransformer; import org.gephi.appearance.spi.PartitionTransformerUI; +import org.gephi.appearance.spi.TransformerUI; +import org.gephi.ui.appearance.plugin.category.DefaultCategory; import org.openide.util.NbBundle; +import org.openide.util.lookup.ServiceProvider; /** * * @author mbastian */ +@ServiceProvider(service = TransformerUI.class, position = 200) public class PartitionElementColorTransformerUI implements PartitionTransformerUI { private final PartitionColorTransformerPanel panel; @@ -27,7 +31,7 @@ public class PartitionElementColorTransformerUI implements PartitionTransformerU @Override public Category[] getCategories() { - return new Category[]{Category.NODE_COLOR, Category.EDGE_COLOR}; + return new Category[]{DefaultCategory.NODE_COLOR, DefaultCategory.EDGE_COLOR}; } @Override @@ -40,6 +44,11 @@ public class PartitionElementColorTransformerUI implements PartitionTransformerU return null; } + @Override + public String getDescription() { + return null; + } + @Override public JPanel getPanel(PartitionTransformer transformer, Partition partition) { panel.setup(transformer, partition); diff --git a/modules/AppearancePluginUI/src/main/java/org/gephi/ui/appearance/plugin/RankingColorTransformerPanel.form b/modules/AppearancePluginUI/src/main/java/org/gephi/ui/appearance/plugin/RankingColorTransformerPanel.form index 99910b763..683d928fd 100644 --- a/modules/AppearancePluginUI/src/main/java/org/gephi/ui/appearance/plugin/RankingColorTransformerPanel.form +++ b/modules/AppearancePluginUI/src/main/java/org/gephi/ui/appearance/plugin/RankingColorTransformerPanel.form @@ -148,7 +148,7 @@ - + diff --git a/modules/AppearancePluginUI/src/main/java/org/gephi/ui/appearance/plugin/RankingColorTransformerPanel.java b/modules/AppearancePluginUI/src/main/java/org/gephi/ui/appearance/plugin/RankingColorTransformerPanel.java index 97dcbb17e..f52e86090 100644 --- a/modules/AppearancePluginUI/src/main/java/org/gephi/ui/appearance/plugin/RankingColorTransformerPanel.java +++ b/modules/AppearancePluginUI/src/main/java/org/gephi/ui/appearance/plugin/RankingColorTransformerPanel.java @@ -311,7 +311,7 @@ public class RankingColorTransformerPanel extends javax.swing.JPanel { colorSwatchToolbar.setRollover(true); colorSwatchToolbar.setOpaque(false); - colorSwatchButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/gephi/ui/ranking/plugin/resources/color-swatch.png"))); // NOI18N + colorSwatchButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/gephi/ui/appearance/plugin/resources/color-swatch.png"))); // NOI18N colorSwatchButton.setFocusable(false); colorSwatchButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); colorSwatchButton.setIconTextGap(0); @@ -340,7 +340,7 @@ public class RankingColorTransformerPanel extends javax.swing.JPanel { .addGap(18, 18, 18) .addComponent(upperBoundLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 46, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(rangeSlider, javax.swing.GroupLayout.PREFERRED_SIZE, 162, javax.swing.GroupLayout.PREFERRED_SIZE)))) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 8, Short.MAX_VALUE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(colorSwatchToolbar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) ); layout.setVerticalGroup( @@ -361,7 +361,7 @@ public class RankingColorTransformerPanel extends javax.swing.JPanel { .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(lowerBoundLabel) .addComponent(upperBoundLabel)))) - .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addContainerGap(22, Short.MAX_VALUE)) ); }// //GEN-END:initComponents // Variables declaration - do not modify//GEN-BEGIN:variables diff --git a/modules/AppearancePluginUI/src/main/java/org/gephi/ui/appearance/plugin/RankingElementColorTransformerUI.java b/modules/AppearancePluginUI/src/main/java/org/gephi/ui/appearance/plugin/RankingElementColorTransformerUI.java index 402c4a661..03feb7490 100644 --- a/modules/AppearancePluginUI/src/main/java/org/gephi/ui/appearance/plugin/RankingElementColorTransformerUI.java +++ b/modules/AppearancePluginUI/src/main/java/org/gephi/ui/appearance/plugin/RankingElementColorTransformerUI.java @@ -10,6 +10,8 @@ import org.gephi.appearance.plugin.RankingElementColorTransformer; import org.gephi.appearance.spi.Category; import org.gephi.appearance.spi.RankingTransformer; import org.gephi.appearance.spi.RankingTransformerUI; +import org.gephi.appearance.spi.TransformerUI; +import org.gephi.ui.appearance.plugin.category.DefaultCategory; import org.openide.util.NbBundle; import org.openide.util.lookup.ServiceProvider; @@ -17,7 +19,7 @@ import org.openide.util.lookup.ServiceProvider; * * @author mbastian */ -@ServiceProvider(service = RankingTransformerUI.class) +@ServiceProvider(service = TransformerUI.class, position = 200) public class RankingElementColorTransformerUI implements RankingTransformerUI { private final RankingColorTransformerPanel panel; @@ -28,7 +30,7 @@ public class RankingElementColorTransformerUI implements RankingTransformerUI { @Override public Category[] getCategories() { - return new Category[]{Category.NODE_COLOR, Category.EDGE_COLOR}; + return new Category[]{DefaultCategory.NODE_COLOR, DefaultCategory.EDGE_COLOR}; } @Override @@ -41,6 +43,11 @@ public class RankingElementColorTransformerUI implements RankingTransformerUI { return NbBundle.getMessage(UniqueElementColorTransformerUI.class, "Attribute.name"); } + @Override + public String getDescription() { + return null; + } + @Override public JPanel getPanel(RankingTransformer transformer, Number min, Number max) { panel.setup(transformer); diff --git a/modules/AppearancePluginUI/src/main/java/org/gephi/ui/appearance/plugin/UniqueElementColorTransformerUI.java b/modules/AppearancePluginUI/src/main/java/org/gephi/ui/appearance/plugin/UniqueElementColorTransformerUI.java index 42522244f..d8c837764 100644 --- a/modules/AppearancePluginUI/src/main/java/org/gephi/ui/appearance/plugin/UniqueElementColorTransformerUI.java +++ b/modules/AppearancePluginUI/src/main/java/org/gephi/ui/appearance/plugin/UniqueElementColorTransformerUI.java @@ -10,6 +10,8 @@ import org.gephi.appearance.plugin.UniqueElementColorTransformer; import org.gephi.appearance.spi.Category; import org.gephi.appearance.spi.SimpleTransformer; import org.gephi.appearance.spi.SimpleTransformerUI; +import org.gephi.appearance.spi.TransformerUI; +import org.gephi.ui.appearance.plugin.category.DefaultCategory; import org.openide.util.NbBundle; import org.openide.util.lookup.ServiceProvider; @@ -17,12 +19,12 @@ import org.openide.util.lookup.ServiceProvider; * * @author mbastian */ -@ServiceProvider(service = SimpleTransformerUI.class, position = 100) +@ServiceProvider(service = TransformerUI.class, position = 100) public class UniqueElementColorTransformerUI implements SimpleTransformerUI { @Override public Category[] getCategories() { - return new Category[]{Category.NODE_COLOR, Category.EDGE_COLOR}; + return new Category[]{DefaultCategory.NODE_COLOR, DefaultCategory.EDGE_COLOR}; } @Override @@ -30,6 +32,11 @@ public class UniqueElementColorTransformerUI implements SimpleTransformerUI { return NbBundle.getMessage(UniqueElementColorTransformerUI.class, "Unique.name"); } + @Override + public String getDescription() { + return null; + } + @Override public Icon getIcon() { return null; diff --git a/modules/AppearancePluginUI/src/main/java/org/gephi/ui/appearance/plugin/UniqueNodeSizeTransformerUI.java b/modules/AppearancePluginUI/src/main/java/org/gephi/ui/appearance/plugin/UniqueNodeSizeTransformerUI.java index 600d9f7d7..af45f2260 100644 --- a/modules/AppearancePluginUI/src/main/java/org/gephi/ui/appearance/plugin/UniqueNodeSizeTransformerUI.java +++ b/modules/AppearancePluginUI/src/main/java/org/gephi/ui/appearance/plugin/UniqueNodeSizeTransformerUI.java @@ -10,6 +10,8 @@ import org.gephi.appearance.plugin.UniqueNodeSizeTransformer; import org.gephi.appearance.spi.Category; import org.gephi.appearance.spi.SimpleTransformer; import org.gephi.appearance.spi.SimpleTransformerUI; +import org.gephi.appearance.spi.TransformerUI; +import org.gephi.ui.appearance.plugin.category.DefaultCategory; import org.openide.util.NbBundle; import org.openide.util.lookup.ServiceProvider; @@ -17,12 +19,12 @@ import org.openide.util.lookup.ServiceProvider; * * @author mbastian */ -@ServiceProvider(service = SimpleTransformerUI.class, position = 200) +@ServiceProvider(service = TransformerUI.class, position = 100) public class UniqueNodeSizeTransformerUI implements SimpleTransformerUI { @Override public Category[] getCategories() { - return new Category[]{Category.NODE_SIZE}; + return new Category[]{DefaultCategory.NODE_SIZE}; } @Override @@ -30,6 +32,11 @@ public class UniqueNodeSizeTransformerUI implements SimpleTransformerUI { return NbBundle.getMessage(UniqueElementColorTransformerUI.class, "Unique.name"); } + @Override + public String getDescription() { + return null; + } + @Override public Icon getIcon() { return null; diff --git a/modules/AppearancePluginUI/src/main/java/org/gephi/ui/appearance/plugin/category/DefaultCategory.java b/modules/AppearancePluginUI/src/main/java/org/gephi/ui/appearance/plugin/category/DefaultCategory.java new file mode 100644 index 000000000..483be89e8 --- /dev/null +++ b/modules/AppearancePluginUI/src/main/java/org/gephi/ui/appearance/plugin/category/DefaultCategory.java @@ -0,0 +1,96 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package org.gephi.ui.appearance.plugin.category; + +import javax.swing.Icon; +import javax.swing.ImageIcon; +import org.gephi.appearance.spi.Category; +import org.openide.util.NbBundle; + +/** + * + * @author mbastian + */ +public class DefaultCategory { + + public static Category NODE_SIZE = new Category() { + @Override + public String getName() { + return NbBundle.getMessage(DefaultCategory.class, "Category.NodeSize.name"); + } + + @Override + public Icon getIcon() { + return new ImageIcon(getClass().getResource("/org/gephi/ui/appearance/plugin/resources/size.png")); + } + + @Override + public boolean isNode() { + return true; + } + + @Override + public boolean isEdge() { + return false; + } + + @Override + public String toString() { + return "NODE_SIZE"; + } + }; + public static Category NODE_COLOR = new Category() { + @Override + public String getName() { + return NbBundle.getMessage(DefaultCategory.class, "Category.NodeColor.name"); + } + + @Override + public Icon getIcon() { + return new ImageIcon(getClass().getResource("/org/gephi/ui/appearance/plugin/resources/color.png")); + } + + @Override + public boolean isNode() { + return true; + } + + @Override + public boolean isEdge() { + return false; + } + + @Override + public String toString() { + return "NODE_COLOR"; + } + }; + public static Category EDGE_COLOR = new Category() { + @Override + public String getName() { + return NbBundle.getMessage(DefaultCategory.class, "Category.EdgeColor.name"); + } + + @Override + public Icon getIcon() { + return new ImageIcon(getClass().getResource("/org/gephi/ui/appearance/plugin/resources/color.png")); + } + + @Override + public boolean isNode() { + return false; + } + + @Override + public boolean isEdge() { + return true; + } + + @Override + public String toString() { + return "EDGE_COLOR"; + } + }; +} diff --git a/modules/AppearancePluginUI/src/main/resources/org/gephi/ui/appearance/plugin/Bundle.properties b/modules/AppearancePluginUI/src/main/resources/org/gephi/ui/appearance/plugin/Bundle.properties index ba1e070f2..69697cb79 100644 --- a/modules/AppearancePluginUI/src/main/resources/org/gephi/ui/appearance/plugin/Bundle.properties +++ b/modules/AppearancePluginUI/src/main/resources/org/gephi/ui/appearance/plugin/Bundle.properties @@ -1,3 +1,4 @@ + Unique.name = Unique Attribute.name = Attribute diff --git a/modules/AppearancePluginUI/src/main/resources/org/gephi/ui/appearance/plugin/category/Bundle.properties b/modules/AppearancePluginUI/src/main/resources/org/gephi/ui/appearance/plugin/category/Bundle.properties new file mode 100644 index 000000000..51fe97d2d --- /dev/null +++ b/modules/AppearancePluginUI/src/main/resources/org/gephi/ui/appearance/plugin/category/Bundle.properties @@ -0,0 +1,3 @@ +Category.NodeSize.name = Size +Category.NodeColor.name = Color +Category.EdgeColor.name = Color \ No newline at end of file diff --git a/modules/AppearancePluginUI/src/main/resources/org/gephi/ui/appearance/plugin/resources/color-swatch.png b/modules/AppearancePluginUI/src/main/resources/org/gephi/ui/appearance/plugin/resources/color-swatch.png new file mode 100644 index 0000000000000000000000000000000000000000..85330f2a6b1f9cd0b5868fcd2e90ab0938246875 GIT binary patch literal 359 zcmV-t0hs=YP)ykM~$mA)AM;C}c^+&EKv_M^;T0E74Ad-)KA_Oup;DGiaOVu#wj~LC*yO+m(3`c%b5X&@FSxUU zx~@rX-5pEpPdD^^kK?YyX@9fT2<{|kn#Q)E*@p^3OTgMkphDY%;LaARs`7{khwYuQ z-YvX6u+@p!;!c91D9R{`p8tF_%;j$%{r|tPn&4A_0RW&7uFB?BFf;%F002ovPDHLk FV1oJqoFM=J literal 0 HcmV?d00001 diff --git a/modules/AppearancePluginUI/src/main/resources/org/gephi/ui/partition/plugin/resources/color.png b/modules/AppearancePluginUI/src/main/resources/org/gephi/ui/appearance/plugin/resources/color.png similarity index 100% rename from modules/AppearancePluginUI/src/main/resources/org/gephi/ui/partition/plugin/resources/color.png rename to modules/AppearancePluginUI/src/main/resources/org/gephi/ui/appearance/plugin/resources/color.png diff --git a/modules/AppearancePluginUI/src/main/resources/org/gephi/ui/partition/plugin/resources/labelcolor.png b/modules/AppearancePluginUI/src/main/resources/org/gephi/ui/appearance/plugin/resources/labelcolor.png similarity index 100% rename from modules/AppearancePluginUI/src/main/resources/org/gephi/ui/partition/plugin/resources/labelcolor.png rename to modules/AppearancePluginUI/src/main/resources/org/gephi/ui/appearance/plugin/resources/labelcolor.png diff --git a/modules/AppearancePluginUI/src/main/resources/org/gephi/ui/partition/plugin/resources/labelsize.png b/modules/AppearancePluginUI/src/main/resources/org/gephi/ui/appearance/plugin/resources/labelsize.png similarity index 100% rename from modules/AppearancePluginUI/src/main/resources/org/gephi/ui/partition/plugin/resources/labelsize.png rename to modules/AppearancePluginUI/src/main/resources/org/gephi/ui/appearance/plugin/resources/labelsize.png diff --git a/modules/AppearancePluginUI/src/main/resources/org/gephi/ui/partition/plugin/resources/randomize.png b/modules/AppearancePluginUI/src/main/resources/org/gephi/ui/appearance/plugin/resources/randomize.png similarity index 100% rename from modules/AppearancePluginUI/src/main/resources/org/gephi/ui/partition/plugin/resources/randomize.png rename to modules/AppearancePluginUI/src/main/resources/org/gephi/ui/appearance/plugin/resources/randomize.png diff --git a/modules/AppearancePluginUI/src/main/resources/org/gephi/ui/partition/plugin/resources/size.png b/modules/AppearancePluginUI/src/main/resources/org/gephi/ui/appearance/plugin/resources/size.png similarity index 100% rename from modules/AppearancePluginUI/src/main/resources/org/gephi/ui/partition/plugin/resources/size.png rename to modules/AppearancePluginUI/src/main/resources/org/gephi/ui/appearance/plugin/resources/size.png diff --git a/modules/DesktopAppearance/src/main/java/org/gephi/desktop/appearance/AppearanceToolbar.java b/modules/DesktopAppearance/src/main/java/org/gephi/desktop/appearance/AppearanceToolbar.java index 6a1510dad..223dacf6d 100644 --- a/modules/DesktopAppearance/src/main/java/org/gephi/desktop/appearance/AppearanceToolbar.java +++ b/modules/DesktopAppearance/src/main/java/org/gephi/desktop/appearance/AppearanceToolbar.java @@ -10,7 +10,9 @@ import java.awt.event.ActionListener; import java.beans.PropertyChangeEvent; import java.util.ArrayList; import java.util.Enumeration; +import java.util.LinkedHashMap; import java.util.List; +import java.util.Map; import java.util.MissingResourceException; import javax.swing.AbstractButton; import javax.swing.ButtonGroup; @@ -45,18 +47,6 @@ public class AppearanceToolbar implements AppearanceUIModelListener { controller.addPropertyChangeListener(this); } - public void setup(AppearanceUIModel model) { - this.model = model; - - SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { - categoryToolbar.setup(); - categoryToolbar.refreshTransformers(); - } - }); - } - public JToolBar getCategoryToolbar() { return categoryToolbar; } @@ -67,6 +57,15 @@ public class AppearanceToolbar implements AppearanceUIModelListener { @Override public void propertyChange(PropertyChangeEvent pce) { + if (pce.getPropertyName().equals(AppearanceUIModelEvent.MODEL)) { + setup((AppearanceUIModel) pce.getNewValue()); + } else if (pce.getPropertyName().equals(AppearanceUIModelEvent.SELECTED_ELEMENT_CLASS)) { + refreshSelectedElementClass((String) pce.getNewValue()); + } else if (pce.getPropertyName().equals(AppearanceUIModelEvent.SELECTED_CATEGORY)) { + refreshSelectedCategory((Category) pce.getNewValue()); + } else if (pce.getPropertyName().equals(AppearanceUIModelEvent.SELECTED_TRANSFORMER_UI)) { + refreshSelectedTransformerUI((TransformerUI) pce.getNewValue()); + } // if (pce.getPropertyName().equals(AppearanceUIModelEvent.CURRENT_ELEMENT_TYPE)) { // refreshSelectedElmntGroup((String) pce.getNewValue()); // } @@ -80,6 +79,57 @@ public class AppearanceToolbar implements AppearanceUIModelListener { // } } + private void setup(final AppearanceUIModel model) { + this.model = model; + + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + categoryToolbar.setEnabled(model != null); + categoryToolbar.setup(); + categoryToolbar.refreshSelectedElmntGroup(); + categoryToolbar.refreshTransformers(); + + transformerToolbar.setEnabled(model != null); + transformerToolbar.setup(); + transformerToolbar.refreshTransformers(); + } + }); + } + + private void refreshSelectedElementClass(final String elementClass) { + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + categoryToolbar.refreshSelectedElmntGroup(); + categoryToolbar.refreshTransformers(); + + transformerToolbar.refreshTransformers(); + } + }); + } + + private void refreshSelectedCategory(final Category category) { + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + categoryToolbar.refreshTransformers(); + + transformerToolbar.refreshTransformers(); + } + }); + } + + private void refreshSelectedTransformerUI(final TransformerUI ui) { + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + + transformerToolbar.refreshTransformers(); + } + }); + } + private class AbstractToolbar extends JToolBar { public AbstractToolbar() { @@ -123,7 +173,7 @@ public class AppearanceToolbar implements AppearanceUIModelListener { btn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - model.setSelectedElementClass(elmtType); + controller.setSelectedElementClass(elmtType); } }); elementGroup.add(btn); @@ -160,11 +210,12 @@ public class AppearanceToolbar implements AppearanceUIModelListener { // DecoratedIcon decoratedIcon = getDecoratedIcon(icon, t); // JToggleButton btn = new JToggleButton(decoratedIcon); JToggleButton btn = new JToggleButton(icon); + btn.setToolTipText(c.getName()); btn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { -// model.setCurrentTransformer(t); + controller.setSelectedCategory(c); } }); btn.setName(c.getName()); @@ -181,22 +232,24 @@ public class AppearanceToolbar implements AppearanceUIModelListener { } protected void refreshTransformers() { - //Select the right transformer - int index = 0; - for (String elmtType : AppearanceUIController.ELEMENT_CLASSES) { - ButtonGroup g = buttonGroups.get(index); - boolean active = model == null ? false : model.getSelectedElementClass().equals(elmtType); - g.clearSelection(); - TransformerUI t = model.getCurrentTransformerUI(elmtType); - String selected = model == null ? "" : t.getDisplayName(); - for (Enumeration btns = g.getElements(); btns.hasMoreElements();) { - AbstractButton btn = btns.nextElement(); - btn.setVisible(active); - if (btn.getName().equals(selected)) { - g.setSelected(btn.getModel(), true); + if (model != null) { + //Select the right transformer + int index = 0; + for (String elmtType : AppearanceUIController.ELEMENT_CLASSES) { + ButtonGroup g = buttonGroups.get(index); + boolean active = model.getSelectedElementClass().equals(elmtType); + g.clearSelection(); + Category c = model.getSelectedCategory(); + String selected = c.getName(); + for (Enumeration btns = g.getElements(); btns.hasMoreElements();) { + AbstractButton btn = btns.nextElement(); + btn.setVisible(active); + if (btn.getName().equals(selected)) { + g.setSelected(btn.getModel(), true); + } } + index++; } - index++; } } @@ -218,7 +271,89 @@ public class AppearanceToolbar implements AppearanceUIModelListener { } private class TransformerToolbar extends AbstractToolbar { + + private final List buttonGroups = new ArrayList(); + + public TransformerToolbar() { + } + + private void clear() { + //Clear precent buttons + for (ButtonGroup bg : buttonGroups) { + for (Enumeration btns = bg.getElements(); btns.hasMoreElements();) { + AbstractButton btn = btns.nextElement(); + remove(btn); + } + } + buttonGroups.clear(); + } + + protected void setup() { + clear(); + if (model != null) { + + for (String elmtType : AppearanceUIController.ELEMENT_CLASSES) { + for (Category c : controller.getCategories(elmtType)) { + + ButtonGroup buttonGroup = new ButtonGroup(); + Map titles = new LinkedHashMap(); + for (TransformerUI t : controller.getTransformerUIs(elmtType, c)) { + titles.put(t.getDisplayName(), t); + } + + for (Map.Entry entry : titles.entrySet()) { + //Build button + final TransformerUI value = entry.getValue(); + Icon icon = entry.getValue().getIcon(); +// DecoratedIcon decoratedIcon = getDecoratedIcon(icon, t); +// JToggleButton btn = new JToggleButton(decoratedIcon); + JToggleButton btn = new JToggleButton(icon); + btn.setToolTipText(entry.getValue().getDescription()); + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + controller.setSelectedTransformerUI(value); + } + }); + btn.setName(entry.getKey()); + btn.setText(entry.getKey()); + btn.setFocusPainted(false); + buttonGroup.add(btn); + add(btn); + } + + buttonGroups.add(buttonGroup); + } + } + } + } + + protected void refreshTransformers() { + if (model != null) { + //Select the right transformer + int index = 0; + for (String elmtType : AppearanceUIController.ELEMENT_CLASSES) { + for (Category c : controller.getCategories(elmtType)) { + ButtonGroup g = buttonGroups.get(index); + + boolean active = model.getSelectedElementClass().equals(elmtType) && model.getSelectedCategory().equals(c); + g.clearSelection(); + TransformerUI t = model.getSelectedTransformerUI(); + + for (Enumeration btns = g.getElements(); btns.hasMoreElements();) { + AbstractButton btn = btns.nextElement(); + btn.setVisible(active); + if (t != null && btn.getName().equals(t.getDisplayName())) { + g.setSelected(btn.getModel(), true); + } + } + index++; + } + } + } + } } +} // private void refreshDecoratedIcons() { // SwingUtilities.invokeLater(new Runnable() { // @Override @@ -245,4 +380,4 @@ public class AppearanceToolbar implements AppearanceUIModelListener { // } // }); // } -} + diff --git a/modules/DesktopAppearance/src/main/java/org/gephi/desktop/appearance/AppearanceTopComponent.form b/modules/DesktopAppearance/src/main/java/org/gephi/desktop/appearance/AppearanceTopComponent.form index 70cee8359..a7d18e3a7 100644 --- a/modules/DesktopAppearance/src/main/java/org/gephi/desktop/appearance/AppearanceTopComponent.form +++ b/modules/DesktopAppearance/src/main/java/org/gephi/desktop/appearance/AppearanceTopComponent.form @@ -51,6 +51,9 @@ + + + @@ -96,6 +99,9 @@ + + + @@ -114,15 +120,15 @@ - - - + + + @@ -133,6 +139,9 @@ + + + @@ -168,6 +177,9 @@ + + + diff --git a/modules/DesktopAppearance/src/main/java/org/gephi/desktop/appearance/AppearanceTopComponent.java b/modules/DesktopAppearance/src/main/java/org/gephi/desktop/appearance/AppearanceTopComponent.java index 8de27149c..af7d019e7 100644 --- a/modules/DesktopAppearance/src/main/java/org/gephi/desktop/appearance/AppearanceTopComponent.java +++ b/modules/DesktopAppearance/src/main/java/org/gephi/desktop/appearance/AppearanceTopComponent.java @@ -227,7 +227,7 @@ public class AppearanceTopComponent extends TopComponent implements Lookup.Provi mainPanel = new javax.swing.JPanel(); categoryToolbar = toolbar.getCategoryToolbar(); - tranformerToolbar = new javax.swing.JToolBar(); + tranformerToolbar = toolbar.getTransformerToolbar(); centerPanel = new javax.swing.JPanel(); southToolbar = new javax.swing.JToolBar(); controlPanel = new javax.swing.JPanel(); @@ -285,6 +285,7 @@ public class AppearanceTopComponent extends TopComponent implements Lookup.Provi controlPanel.setOpaque(false); controlPanel.setLayout(new java.awt.GridBagLayout()); + applyButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/gephi/desktop/appearance/resources/apply.gif"))); // NOI18N org.openide.awt.Mnemonics.setLocalizedText(applyButton, org.openide.util.NbBundle.getMessage(AppearanceTopComponent.class, "AppearanceTopComponent.applyButton.text")); // NOI18N applyButton.setToolTipText(org.openide.util.NbBundle.getMessage(AppearanceTopComponent.class, "AppearanceTopComponent.applyButton.toolTipText")); // NOI18N applyButton.setMargin(new java.awt.Insets(0, 14, 0, 14)); @@ -295,9 +296,9 @@ public class AppearanceTopComponent extends TopComponent implements Lookup.Provi gridBagConstraints.insets = new java.awt.Insets(0, 18, 3, 5); controlPanel.add(applyButton, gridBagConstraints); - splineButton.setClickedColor(new java.awt.Color(0, 51, 255)); org.openide.awt.Mnemonics.setLocalizedText(splineButton, org.openide.util.NbBundle.getMessage(AppearanceTopComponent.class, "AppearanceTopComponent.splineButton.text")); // NOI18N splineButton.setToolTipText(org.openide.util.NbBundle.getMessage(AppearanceTopComponent.class, "AppearanceTopComponent.splineButton.toolTipText")); // NOI18N + splineButton.setClickedColor(new java.awt.Color(0, 51, 255)); splineButton.setFocusPainted(false); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; @@ -305,6 +306,7 @@ public class AppearanceTopComponent extends TopComponent implements Lookup.Provi gridBagConstraints.insets = new java.awt.Insets(0, 5, 0, 0); controlPanel.add(splineButton, gridBagConstraints); + autoApplyButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/gephi/desktop/appearance/resources/apply.gif"))); // NOI18N org.openide.awt.Mnemonics.setLocalizedText(autoApplyButton, org.openide.util.NbBundle.getMessage(AppearanceTopComponent.class, "AppearanceTopComponent.autoApplyButton.text")); // NOI18N autoApplyButton.setToolTipText(org.openide.util.NbBundle.getMessage(AppearanceTopComponent.class, "AppearanceTopComponent.autoApplyButton.toolTipText")); // NOI18N autoApplyButton.setFocusable(false); @@ -322,6 +324,7 @@ public class AppearanceTopComponent extends TopComponent implements Lookup.Provi autoApplyToolbar.setRollover(true); autoApplyToolbar.setOpaque(false); + enableAutoButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/gephi/desktop/appearance/resources/chain.png"))); // NOI18N enableAutoButton.setToolTipText(org.openide.util.NbBundle.getMessage(AppearanceTopComponent.class, "AppearanceTopComponent.enableAutoButton.toolTipText")); // NOI18N enableAutoButton.setFocusable(false); enableAutoButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); diff --git a/modules/DesktopAppearance/src/main/java/org/gephi/desktop/appearance/AppearanceUIController.java b/modules/DesktopAppearance/src/main/java/org/gephi/desktop/appearance/AppearanceUIController.java index cfaa0907e..7dd58e650 100644 --- a/modules/DesktopAppearance/src/main/java/org/gephi/desktop/appearance/AppearanceUIController.java +++ b/modules/DesktopAppearance/src/main/java/org/gephi/desktop/appearance/AppearanceUIController.java @@ -5,6 +5,7 @@ package org.gephi.desktop.appearance; import java.util.Collection; +import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedHashMap; @@ -50,17 +51,21 @@ public class AppearanceUIController { @Override public void select(Workspace workspace) { + AppearanceUIModel oldModel = model; model = workspace.getLookup().lookup(AppearanceUIModel.class); if (model == null) { AppearanceModel appearanceModel = ac.getModel(workspace); model = new AppearanceUIModel(AppearanceUIController.this, appearanceModel); workspace.add(model); } + model.select(); + firePropertyChangeEvent(AppearanceUIModelEvent.MODEL, oldModel, model); } @Override public void unselect(Workspace workspace) { if (model != null) { + model.unselect(); } } @@ -83,7 +88,7 @@ public class AppearanceUIController { } } - listeners = new HashSet(); + listeners = Collections.synchronizedSet(new HashSet()); transformers = new HashMap>>(); for (String ec : ELEMENT_CLASSES) { @@ -121,8 +126,8 @@ public class AppearanceUIController { return transformers.get(elementClass).keySet(); } - public Transformer getTransformer(TransformerUI ui) { - return null; + public Collection getTransformerUIs(String elementClass, Category category) { + return transformers.get(elementClass).get(category); } public AppearanceUIModel getModel() { @@ -130,9 +135,9 @@ public class AppearanceUIController { } public AppearanceUIModel getModel(Workspace workspace) { - final AppearanceController ac = Lookup.getDefault().lookup(AppearanceController.class); AppearanceUIModel m = workspace.getLookup().lookup(AppearanceUIModel.class); if (m == null) { + AppearanceController ac = Lookup.getDefault().lookup(AppearanceController.class); AppearanceModel appearanceModel = ac.getModel(workspace); m = new AppearanceUIModel(this, appearanceModel); workspace.add(m); @@ -144,7 +149,42 @@ public class AppearanceUIController { if (!elementClass.equals(NODE_ELEMENT) && !elementClass.equals(EDGE_ELEMENT)) { throw new RuntimeException("Element class has to be " + NODE_ELEMENT + " or " + EDGE_ELEMENT); } - model.setSelectedElementClass(elementClass); + if (model != null) { + String oldValue = model.getSelectedElementClass(); + if (!oldValue.equals(elementClass)) { + model.setSelectedElementClass(elementClass); + firePropertyChangeEvent(AppearanceUIModelEvent.SELECTED_ELEMENT_CLASS, oldValue, elementClass); + } + } + } + + public void setSelectedCategory(Category category) { + if (model != null) { + Category oldValue = model.getSelectedCategory(); + if (!oldValue.equals(category)) { + model.setSelectedCategory(category); + firePropertyChangeEvent(AppearanceUIModelEvent.SELECTED_CATEGORY, oldValue, category); + } + } + } + + public void setSelectedTransformerUI(TransformerUI ui) { + if (model != null) { + TransformerUI oldValue = model.getSelectedTransformerUI(); + if (!oldValue.equals(ui)) { + model.setSelectedTransformerUI(ui); + firePropertyChangeEvent(AppearanceUIModelEvent.SELECTED_TRANSFORMER_UI, oldValue, ui); + } + } + } + + protected Category getFirstCategory(String elementClass) { + return transformers.get(elementClass).keySet().toArray(new Category[0])[0]; + } + + protected TransformerUI getFirstTransformerUI(String elementClass, Category category) { + Map> e = transformers.get(elementClass); + return e.get(category).toArray(new TransformerUI[0])[0]; } public void addPropertyChangeListener(AppearanceUIModelListener listener) { @@ -157,8 +197,8 @@ public class AppearanceUIController { listeners.remove(listener); } - private void firePropertyChangeEvent(String propertyName, Object beforeValue, Object afterValue) { - AppearanceUIModelEvent event = new AppearanceUIModelEvent(this, propertyName, beforeValue, afterValue); + protected void firePropertyChangeEvent(String propertyName, Object oldValue, Object newValue) { + AppearanceUIModelEvent event = new AppearanceUIModelEvent(model, propertyName, oldValue, newValue); for (AppearanceUIModelListener listener : listeners) { listener.propertyChange(event); } diff --git a/modules/DesktopAppearance/src/main/java/org/gephi/desktop/appearance/AppearanceUIModel.java b/modules/DesktopAppearance/src/main/java/org/gephi/desktop/appearance/AppearanceUIModel.java index 4d6fee1a5..026e7b4ad 100644 --- a/modules/DesktopAppearance/src/main/java/org/gephi/desktop/appearance/AppearanceUIModel.java +++ b/modules/DesktopAppearance/src/main/java/org/gephi/desktop/appearance/AppearanceUIModel.java @@ -4,8 +4,12 @@ */ package org.gephi.desktop.appearance; +import java.util.HashMap; +import java.util.Map; import org.gephi.appearance.api.AppearanceModel; +import org.gephi.appearance.spi.Category; import org.gephi.appearance.spi.TransformerUI; +import static org.gephi.desktop.appearance.AppearanceUIController.ELEMENT_CLASSES; /** * @@ -13,20 +17,58 @@ import org.gephi.appearance.spi.TransformerUI; */ public class AppearanceUIModel { + protected final AppearanceUIController controller; + protected final Map> selectedTransformerUI; + protected final Map selectedCategory; protected String selectedElementClass = AppearanceUIController.NODE_ELEMENT; public AppearanceUIModel(AppearanceUIController controller, AppearanceModel model) { + this.controller = controller; + + //Init categories + selectedCategory = new HashMap(); + for (String ec : ELEMENT_CLASSES) { + selectedCategory.put(ec, controller.getFirstCategory(ec)); + } + + //Init transformers + selectedTransformerUI = new HashMap>(); + for (String ec : ELEMENT_CLASSES) { + Map m = new HashMap(); + selectedTransformerUI.put(ec, m); + for (Category c : controller.getCategories(ec)) { + m.put(c, controller.getFirstTransformerUI(ec, c)); + } + } + } + + public void select() { + } + + public void unselect() { } public String getSelectedElementClass() { return selectedElementClass; } - public void setSelectedElementClass(String selectedElementClass) { + public Category getSelectedCategory() { + return selectedCategory.get(selectedElementClass); + } + + public TransformerUI getSelectedTransformerUI() { + return selectedTransformerUI.get(selectedElementClass).get(getSelectedCategory()); + } + + protected void setSelectedElementClass(String selectedElementClass) { this.selectedElementClass = selectedElementClass; } - public TransformerUI getCurrentTransformerUI(String selectedElementClass) { - return null; + public void setSelectedCategory(Category category) { + selectedCategory.put(selectedElementClass, category); + } + + protected void setSelectedTransformerUI(TransformerUI transformerUI) { + selectedTransformerUI.get(selectedElementClass).put(getSelectedCategory(), transformerUI); } } diff --git a/modules/DesktopAppearance/src/main/java/org/gephi/desktop/appearance/AppearanceUIModelEvent.java b/modules/DesktopAppearance/src/main/java/org/gephi/desktop/appearance/AppearanceUIModelEvent.java index db034fa5d..ea1c8fdb6 100644 --- a/modules/DesktopAppearance/src/main/java/org/gephi/desktop/appearance/AppearanceUIModelEvent.java +++ b/modules/DesktopAppearance/src/main/java/org/gephi/desktop/appearance/AppearanceUIModelEvent.java @@ -14,9 +14,11 @@ public class AppearanceUIModelEvent extends PropertyChangeEvent { public static String MODEL = "model"; public static String SELECTED_ELEMENT_CLASS = "selectedElementClass"; + public static String SELECTED_CATEGORY = "selectedCategory"; + public static String SELECTED_TRANSFORMER_UI = "selectedTransformerUI"; public AppearanceUIModelEvent(Object source, String propertyName, Object oldValue, Object newValue) { - super(source, propertyName, newValue, oldValue); + super(source, propertyName, oldValue, newValue); } } diff --git a/modules/DesktopExport/pom.xml b/modules/DesktopExport/pom.xml index 2c45d8402..3a3339e4b 100644 --- a/modules/DesktopExport/pom.xml +++ b/modules/DesktopExport/pom.xml @@ -5,7 +5,7 @@ gephi-parent org.gephi 0.9-SNAPSHOT - ../.. + ../.. org.gephi diff --git a/modules/FiltersAPI/pom.xml b/modules/FiltersAPI/pom.xml index 5fd5629de..1cbcd54c1 100644 --- a/modules/FiltersAPI/pom.xml +++ b/modules/FiltersAPI/pom.xml @@ -5,7 +5,7 @@ gephi-parent org.gephi 0.9-SNAPSHOT - ../.. + ../.. org.gephi diff --git a/modules/RankingPluginUI/src/main/java/org/gephi/ui/ranking/plugin/RecentPalettes.java b/modules/RankingPluginUI/src/main/java/org/gephi/ui/ranking/plugin/RecentPalettes.java index f35d8d0e2..41eef37ec 100644 --- a/modules/RankingPluginUI/src/main/java/org/gephi/ui/ranking/plugin/RecentPalettes.java +++ b/modules/RankingPluginUI/src/main/java/org/gephi/ui/ranking/plugin/RecentPalettes.java @@ -1,48 +1,47 @@ /* -Copyright 2008-2010 Gephi -Authors : Mathieu Bastian -Website : http://www.gephi.org - -This file is part of Gephi. - -DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - -Copyright 2011 Gephi Consortium. All rights reserved. - -The contents of this file are subject to the terms of either the GNU -General Public License Version 3 only ("GPL") or the Common -Development and Distribution License("CDDL") (collectively, the -"License"). You may not use this file except in compliance with the -License. You can obtain a copy of the License at -http://gephi.org/about/legal/license-notice/ -or /cddl-1.0.txt and /gpl-3.0.txt. See the License for the -specific language governing permissions and limitations under the -License. When distributing the software, include this License Header -Notice in each file and include the License files at -/cddl-1.0.txt and /gpl-3.0.txt. If applicable, add the following below the -License Header, with the fields enclosed by brackets [] replaced by -your own identifying information: -"Portions Copyrighted [year] [name of copyright owner]" - -If you wish your version of this file to be governed by only the CDDL -or only the GPL Version 3, indicate your decision by adding -"[Contributor] elects to include this software in this distribution -under the [CDDL or GPL Version 3] license." If you do not indicate a -single choice of license, a recipient has the option to distribute -your version of this file under either the CDDL, the GPL Version 3 or -to extend the choice of license to its licensees as provided above. -However, if you add GPL Version 3 code and therefore, elected the GPL -Version 3 license, then the option applies only if the new code is -made subject to such option by the copyright holder. - -Contributor(s): - -Portions Copyrighted 2011 Gephi Consortium. + Copyright 2008-2010 Gephi + Authors : Mathieu Bastian + Website : http://www.gephi.org + + This file is part of Gephi. + + DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + + Copyright 2011 Gephi Consortium. All rights reserved. + + The contents of this file are subject to the terms of either the GNU + General Public License Version 3 only ("GPL") or the Common + Development and Distribution License("CDDL") (collectively, the + "License"). You may not use this file except in compliance with the + License. You can obtain a copy of the License at + http://gephi.org/about/legal/license-notice/ + or /cddl-1.0.txt and /gpl-3.0.txt. See the License for the + specific language governing permissions and limitations under the + License. When distributing the software, include this License Header + Notice in each file and include the License files at + /cddl-1.0.txt and /gpl-3.0.txt. If applicable, add the following below the + License Header, with the fields enclosed by brackets [] replaced by + your own identifying information: + "Portions Copyrighted [year] [name of copyright owner]" + + If you wish your version of this file to be governed by only the CDDL + or only the GPL Version 3, indicate your decision by adding + "[Contributor] elects to include this software in this distribution + under the [CDDL or GPL Version 3] license." If you do not indicate a + single choice of license, a recipient has the option to distribute + your version of this file under either the CDDL, the GPL Version 3 or + to extend the choice of license to its licensees as provided above. + However, if you add GPL Version 3 code and therefore, elected the GPL + Version 3 license, then the option applies only if the new code is + made subject to such option by the copyright holder. + + Contributor(s): + + Portions Copyrighted 2011 Gephi Consortium. */ package org.gephi.ui.ranking.plugin; import java.awt.Color; -import java.beans.XMLEncoder; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInputStream; @@ -59,21 +58,21 @@ import org.openide.util.NbPreferences; * @author Mathieu Bastian */ public class RecentPalettes { - + protected static String DEFAULT_NODE_NAME = "prefs"; public static final String COLORS = "PaletteColors"; public static final String POSITIONS = "PalettePositions"; private List gradients; private int maxSize; protected String nodeName = null; - + public RecentPalettes() { nodeName = "recentpalettes"; maxSize = 14; gradients = new ArrayList(maxSize); retrieve(); } - + public void add(LinearGradient gradient) { //Remove the old gradients.remove(gradient); @@ -83,14 +82,14 @@ public class RecentPalettes { while (gradients.size() > maxSize) { gradients.remove(gradients.size() - 1); } - + store(); } - + public LinearGradient[] getPalettes() { return gradients.toArray(new LinearGradient[0]); } - + protected void store() { Preferences prefs = getPreferences(); @@ -99,7 +98,7 @@ public class RecentPalettes { prefs.clear(); } catch (BackingStoreException ex) { } - + for (int i = 0; i < gradients.size(); i++) { LinearGradient gradient = gradients.get(i); try { @@ -110,11 +109,11 @@ public class RecentPalettes { } } } - + protected void retrieve() { gradients.clear(); Preferences prefs = getPreferences(); - + for (int i = 0; i < maxSize; i++) { byte[] cols = prefs.getByteArray(COLORS + i, null); byte[] poss = prefs.getByteArray(POSITIONS + i, null); @@ -133,7 +132,9 @@ public class RecentPalettes { } } - /** Return the backing store Preferences + /** + * Return the backing store Preferences + * * @return Preferences */ protected final Preferences getPreferences() { @@ -141,12 +142,12 @@ public class RecentPalettes { if (nodeName != null) { name = nodeName; } - + Preferences prefs = NbPreferences.forModule(this.getClass()).node("options").node(name); - + return prefs; } - + private byte[] serializePositions(float[] positions) throws Exception { ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutputStream out = new ObjectOutputStream(bos); @@ -154,7 +155,7 @@ public class RecentPalettes { out.close(); return bos.toByteArray(); } - + private float[] deserializePositions(byte[] positions) throws Exception { ByteArrayInputStream bis = new ByteArrayInputStream(positions); ObjectInputStream in = new ObjectInputStream(bis); @@ -162,7 +163,7 @@ public class RecentPalettes { in.close(); return array; } - + private byte[] serializeColors(Color[] colors) throws Exception { ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutputStream out = new ObjectOutputStream(bos); @@ -170,7 +171,7 @@ public class RecentPalettes { out.close(); return bos.toByteArray(); } - + private Color[] deserializeColors(byte[] colors) throws Exception { ByteArrayInputStream bis = new ByteArrayInputStream(colors); ObjectInputStream in = new ObjectInputStream(bis); -- GitLab