Implement category and transformer toolbar system
@@ -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;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -16,6 +16,8 @@ public interface TransformerUI<T extends Transformer> {
|
||||
|
||||
public String getDisplayName();
|
||||
|
||||
public String getDescription();
|
||||
|
||||
public Icon getIcon();
|
||||
|
||||
public Class<? extends T> getTransformerClass();
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
Category.ElementSize.name = Size
|
||||
Category.ElementColor.name = Color
|
||||
Category.NodeSize.name = Size
|
||||
Category.NodeColor.name = Color
|
||||
Category.EdgeColor.name = Color
|
||||
@@ -53,6 +53,7 @@
|
||||
<artifactId>nbm-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<publicPackages>
|
||||
<publicPackage>org.gephi.ui.appearance.plugin.category</publicPackage>
|
||||
</publicPackages>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
@@ -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<Object, Color> 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<Object, Color> entry : nodeColorTransformer.getMap().entrySet()) {
|
||||
//// entry.setValue(Color.BLACK);
|
||||
//// }
|
||||
//// setup(partition, nodeColorTransformer, false);
|
||||
// revalidate();
|
||||
// repaint();
|
||||
// }
|
||||
// });
|
||||
// popupMenu.add(allBlackItem);
|
||||
}
|
||||
|
||||
class ColorChooserRenderer extends JLabel implements TableCellRenderer {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -148,7 +148,7 @@
|
||||
<Component class="javax.swing.JButton" name="colorSwatchButton">
|
||||
<Properties>
|
||||
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
|
||||
<Image iconType="3" name="/org/gephi/ui/ranking/plugin/resources/color-swatch.png"/>
|
||||
<Image iconType="3" name="/org/gephi/ui/appearance/plugin/resources/color-swatch.png"/>
|
||||
</Property>
|
||||
<Property name="focusable" type="boolean" value="false"/>
|
||||
<Property name="horizontalTextPosition" type="int" value="0"/>
|
||||
|
||||
@@ -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))
|
||||
);
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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";
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
|
||||
Unique.name = Unique
|
||||
Attribute.name = Attribute
|
||||
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
Category.NodeSize.name = Size
|
||||
Category.NodeColor.name = Color
|
||||
Category.EdgeColor.name = Color
|
||||
|
Depois Largura: | Altura: | Tamanho: 359 B |
|
Antes Largura: | Altura: | Tamanho: 892 B Depois Largura: | Altura: | Tamanho: 892 B |
|
Antes Largura: | Altura: | Tamanho: 824 B Depois Largura: | Altura: | Tamanho: 824 B |
|
Antes Largura: | Altura: | Tamanho: 809 B Depois Largura: | Altura: | Tamanho: 809 B |
|
Antes Largura: | Altura: | Tamanho: 791 B Depois Largura: | Altura: | Tamanho: 791 B |
|
Antes Largura: | Altura: | Tamanho: 592 B Depois Largura: | Altura: | Tamanho: 592 B |
@@ -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<AbstractButton> 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<AbstractButton> 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<ButtonGroup> buttonGroups = new ArrayList<ButtonGroup>();
|
||||
|
||||
public TransformerToolbar() {
|
||||
}
|
||||
|
||||
private void clear() {
|
||||
//Clear precent buttons
|
||||
for (ButtonGroup bg : buttonGroups) {
|
||||
for (Enumeration<AbstractButton> 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<String, TransformerUI> titles = new LinkedHashMap<String, TransformerUI>();
|
||||
for (TransformerUI t : controller.getTransformerUIs(elmtType, c)) {
|
||||
titles.put(t.getDisplayName(), t);
|
||||
}
|
||||
|
||||
for (Map.Entry<String, TransformerUI> 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<AbstractButton> 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 {
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
@@ -51,6 +51,9 @@
|
||||
<Property name="rollover" type="boolean" value="true"/>
|
||||
<Property name="opaque" type="boolean" value="false"/>
|
||||
</Properties>
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="toolbar.getTransformerToolbar()"/>
|
||||
</AuxValues>
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
|
||||
<GridBagConstraints gridX="0" gridY="1" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="11" weightX="1.0" weightY="0.0"/>
|
||||
@@ -96,6 +99,9 @@
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JButton" name="applyButton">
|
||||
<Properties>
|
||||
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
|
||||
<Image iconType="3" name="/org/gephi/desktop/appearance/resources/apply.gif"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="org/gephi/desktop/appearance/Bundle.properties" key="AppearanceTopComponent.applyButton.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
|
||||
</Property>
|
||||
@@ -114,15 +120,15 @@
|
||||
</Component>
|
||||
<Component class="org.jdesktop.swingx.JXHyperlink" name="splineButton">
|
||||
<Properties>
|
||||
<Property name="clickedColor" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
|
||||
<Color blue="ff" green="33" red="0" type="rgb"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="org/gephi/desktop/appearance/Bundle.properties" key="AppearanceTopComponent.splineButton.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
|
||||
</Property>
|
||||
<Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="org/gephi/desktop/appearance/Bundle.properties" key="AppearanceTopComponent.splineButton.toolTipText" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
|
||||
</Property>
|
||||
<Property name="clickedColor" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
|
||||
<Color blue="ff" green="33" red="0" type="rgb"/>
|
||||
</Property>
|
||||
<Property name="focusPainted" type="boolean" value="false"/>
|
||||
</Properties>
|
||||
<Constraints>
|
||||
@@ -133,6 +139,9 @@
|
||||
</Component>
|
||||
<Component class="javax.swing.JToggleButton" name="autoApplyButton">
|
||||
<Properties>
|
||||
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
|
||||
<Image iconType="3" name="/org/gephi/desktop/appearance/resources/apply.gif"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="org/gephi/desktop/appearance/Bundle.properties" key="AppearanceTopComponent.autoApplyButton.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
|
||||
</Property>
|
||||
@@ -168,6 +177,9 @@
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JToggleButton" name="enableAutoButton">
|
||||
<Properties>
|
||||
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
|
||||
<Image iconType="3" name="/org/gephi/desktop/appearance/resources/chain.png"/>
|
||||
</Property>
|
||||
<Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="org/gephi/desktop/appearance/Bundle.properties" key="AppearanceTopComponent.enableAutoButton.toolTipText" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
|
||||
</Property>
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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<AppearanceUIModelListener>();
|
||||
listeners = Collections.synchronizedSet(new HashSet<AppearanceUIModelListener>());
|
||||
|
||||
transformers = new HashMap<String, Map<Category, Set<TransformerUI>>>();
|
||||
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<TransformerUI> 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<Category, Set<TransformerUI>> 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);
|
||||
}
|
||||
|
||||
@@ -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<String, Map<Category, TransformerUI>> selectedTransformerUI;
|
||||
protected final Map<String, Category> selectedCategory;
|
||||
protected String selectedElementClass = AppearanceUIController.NODE_ELEMENT;
|
||||
|
||||
public AppearanceUIModel(AppearanceUIController controller, AppearanceModel model) {
|
||||
this.controller = controller;
|
||||
|
||||
//Init categories
|
||||
selectedCategory = new HashMap<String, Category>();
|
||||
for (String ec : ELEMENT_CLASSES) {
|
||||
selectedCategory.put(ec, controller.getFirstCategory(ec));
|
||||
}
|
||||
|
||||
//Init transformers
|
||||
selectedTransformerUI = new HashMap<String, Map<Category, TransformerUI>>();
|
||||
for (String ec : ELEMENT_CLASSES) {
|
||||
Map<Category, TransformerUI> m = new HashMap<Category, TransformerUI>();
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<artifactId>gephi-parent</artifactId>
|
||||
<groupId>org.gephi</groupId>
|
||||
<version>0.9-SNAPSHOT</version>
|
||||
<relativePath>../..</relativePath>
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
||||
<groupId>org.gephi</groupId>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<artifactId>gephi-parent</artifactId>
|
||||
<groupId>org.gephi</groupId>
|
||||
<version>0.9-SNAPSHOT</version>
|
||||
<relativePath>../..</relativePath>
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
||||
<groupId>org.gephi</groupId>
|
||||
|
||||
@@ -1,48 +1,47 @@
|
||||
/*
|
||||
Copyright 2008-2010 Gephi
|
||||
Authors : Mathieu Bastian <mathieu.bastian@gephi.org>
|
||||
Website : http://www.gephi.org
|
||||
Copyright 2008-2010 Gephi
|
||||
Authors : Mathieu Bastian <mathieu.bastian@gephi.org>
|
||||
Website : http://www.gephi.org
|
||||
|
||||
This file is part of Gephi.
|
||||
This file is part of Gephi.
|
||||
|
||||
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
|
||||
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
|
||||
|
||||
Copyright 2011 Gephi Consortium. All rights reserved.
|
||||
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]"
|
||||
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.
|
||||
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):
|
||||
Contributor(s):
|
||||
|
||||
Portions Copyrighted 2011 Gephi Consortium.
|
||||
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<LinearGradient> gradients;
|
||||
private int maxSize;
|
||||
protected String nodeName = null;
|
||||
|
||||
|
||||
public RecentPalettes() {
|
||||
nodeName = "recentpalettes";
|
||||
maxSize = 14;
|
||||
gradients = new ArrayList<LinearGradient>(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);
|
||||
|
||||