SlideShare a Scribd company logo
Make a plugin of Random Clustering


               2012. 4




        http://www.mongkie.org


                                     1/33
CONTENTS

     CONTENTS
          • Objectives
          • Structure of Random Clustering Plugin
          • make a plugin
                  Package
                         – org.mongkie.clustering.plugins.random

                  Classes
                         – Random.java
                         – RandomBuilder.java
                         – RandomSettingUI.java

                  Others
                         – Bundle.properties

          • Build and Run

http://www.mongkie.org                                             2/33
Objectives

     Objectives
          • make a plugin of random clustering (add random algorithm)




                         Add Random Algorithm




http://www.mongkie.org                                                  3/33
Clutering Plugins

     Structure of Random Clustering
          • org.mongkie.clustering.plugins.random
                     Bundle.properties

                     Random.java

                     RandomBuilder.java

                     RandomSettingUI.java
                Clustering API                      Clustering Plugins                                 Clustering Plugins
          org.mongkie.clustering        org.mongkie.clustering.plugins                           org.mongkie.ui.clustering
          -ClusteringController                                                                  -ClusteringTopComponent
          -CluteringModel               org.mongkie.clustering.plugins.clustermaker
          -ClusteringModelListener                                                               org.mongkie.ui.clustering.explorer
          -DefaultClusterImpl           org.mongkie.clustering.plugins.clustermaker.converters   -ClusterChildFactory
                                                                                                 -ClusterNode
          org.mongkie.clustering.impl   org.mongkie.clustering.plugins.clustermaker.mcl          -ClusteringResultView
          -ClusteringControllerImpl
          -ClusteringModelImpl          org.mongkie.clustering.plugins.mcl                       org.mongkie.ui.clustering.explorer.actions
                                                                                                 -GroupAction
          org.mongkie.clustering.spi    org.mongkie.clustering.plugins.mcode                     -UngroupAction
          -Cluster
          -Clustering                                                                            org.mongkie.ui.clustering.resources
          -CluteringBuilder                                                                      - Image Files



http://www.mongkie.org                                                                                                                        4/33
Make a plugin - Package

     [New] –[Java Package]




http://www.mongkie.org        5/33
Make a plugin - Package

     Create a random pacakge
          • org.mongkie.clustering.plugins.random




http://www.mongkie.org                              6/33
Make a plugin - Package

     Create a random pacakge
          • org.mongkie.clustering.plugins.random




http://www.mongkie.org                              7/33
Make a plugin - Random

     Create a random class
          • Random.java




http://www.mongkie.org        8/33
Make a plugin - Random

     Create a random class
          • Random.java




http://www.mongkie.org        9/33
Make a plugin - Random

     Create a random class
          • Random.java




http://www.mongkie.org        10/33
Make a plugin - Random

     Random.java
          • Source Code

         package org.mongkie.clustering.plugins.random;

         import java.util.ArrayList;
         import java.util.Collection;
         import java.util.Collections;
         import java.util.Iterator;
         import java.util.List;
         import org.mongkie.clustering.spi.Cluster;
         import org.mongkie.clustering.DefaultClusterImpl;
         import org.mongkie.clustering.spi.Clustering;
         import org.mongkie.clustering.spi.ClusteringBuilder;
         import org.openide.util.Exceptions;
         import prefuse.data.Graph;
         import prefuse.data.Node;




http://www.mongkie.org                                          11/33
Make a plugin - Random

     Random.java
          • implements
                  Clustering

          • variables (global)
                  private final RandomBuilder builder;

                  private int clusterSize;

                  static final int MIN_CLUSTER_SIZE = 3;

                  private List<Cluster> clusters = new ArrayList<Cluster>();

          • Constructor
                Random(RandomBuilder builder) {
                  this.builder = builder;
                  this.clusterSize = MIN_CLUSTER_SIZE;
                }

http://www.mongkie.org                                                          12/33
Make a plugin - Random

     Random.java
              • source code
        public void execute(Graph g) {
            clearClusters();
            List<Node> nodes = new ArrayList<Node>(g.getNodeCount());
            Iterator<Node> nodesIter = g.nodes();
            while (nodesIter.hasNext()) {
                Node n = nodesIter.next();
                nodes.add(n);
            }
            Collections.shuffle(nodes);
            int i = 1, j = 1;
            DefaultClusterImpl c = new DefaultClusterImpl(g, "Random " + j);
            c.setRank(j - 1);
            for (Node n : nodes) {
                c.addNode(n);
                if (i >= clusterSize) {
                    clusters.add(c);
                    c = new DefaultClusterImpl(g, "Random " + ++j);
                    c.setRank(j - 1);
                    i = 1;
                } else {
                    i++;
                }
            }
            if (c.getNodesCount() > 0) {
                clusters.add(c);
            }

              try {
                 synchronized (this) {
                    wait(1000);
                 }
              } catch (InterruptedException ex) {
                 Exceptions.printStackTrace(ex);
              }
          }


http://www.mongkie.org                                                         13/33
Make a plugin - Random

     Random.java
           • source code
        int getClusterSize() {
             return clusterSize;
          }

        void setClusterSize(int clusterSize) {
            this.clusterSize = clusterSize < MIN_CLUSTER_SIZE ? MIN_CLUSTER_SIZE : clusterSize;
          }

        public boolean cancel() {
            synchronized (this) {
               clearClusters();
               notifyAll();
            }
            return true;
          }

          @Override
          public Collection<Cluster> getClusters() {
            return clusters;
          }

          @Override
          public void clearClusters() {
            clusters.clear();
          }

          @Override
          public ClusteringBuilder getBuilder() {
            return builder;
          }




http://www.mongkie.org                                                                            14/33
Make a plugin - RandomBuilder

     RandomBuilder.java




http://www.mongkie.org            15/33
Make a plugin - RandomBuilder

     RandomBuilder




http://www.mongkie.org            16/33
Make a plugin - RandomBuilder

     RandomBuilder




http://www.mongkie.org            17/33
Make a plugin - RandomBuilder

     RandomBuilder




http://www.mongkie.org            18/33
Make a plugin - RandomBuilder

     RandomBuilder
          • implements
                  ClusteringBuilder

          • variable(Global)
                  private final Random random = new Random(this);

                  private final SettingUI settings = new RandomSettingUI();




http://www.mongkie.org                                                         19/33
Make a plugin - RandomBuilder

     RandomBuilder
           • source code
        package org.mongkie.clustering.plugins.random;

        import org.mongkie.clustering.spi.Clustering;
        import org.mongkie.clustering.spi.ClusteringBuilder;
        import org.mongkie.clustering.spi.ClusteringBuilder.SettingUI;
        import org.openide.util.NbBundle;
        import org.openide.util.lookup.ServiceProvider;




http://www.mongkie.org                                                   20/33
Make a plugin - RandomBuilder

     RandomBuilder
             • source code
        @ServiceProvider(service = ClusteringBuilder.class)
        public class RandomBuilder implements ClusteringBuilder {

            private final Random random = new Random(this);
            private final SettingUI settings = new RandomSettingUI();

            @Override
            public Clustering getClustering() {
              return random;
            }

            @Override
            public String getName() {
              return NbBundle.getMessage(RandomBuilder.class, "name");
            }

            @Override
            public String getDescription() {
              return NbBundle.getMessage(RandomBuilder.class, "description");
            }

            @Override
            public SettingUI getSettingUI() {
              return settings;
            }

            @Override
            public String toString() {
              return getName();
            }
        }




http://www.mongkie.org                                                          21/33
Make a plugin - RandomSettingUI

     RandomSettingUI




http://www.mongkie.org              22/33
Make a plugin - RandomSettingUI

     RandomSettingUI




http://www.mongkie.org              23/33
Make a plugin - RandomSettingUI

     RandomSettingUI




http://www.mongkie.org              24/33
Make a plugin - RandomSettingUI

     RandomSettingUI




http://www.mongkie.org              25/33
Make a plugin - RandomSettingUI

     RandomSettingUI
          • extends
                  javax.swing.JPanel

          • implements
                  ClusteringBuilder.SettingUI<Random>

          • variable(Global)
                  private SpinnerModel clusterSizeSpinnerModel;

          • Constructor
           RandomSettingUI() {
              clusterSizeSpinnerModel = new SpinnerNumberModel(
                   Integer.valueOf(Random.MIN_CLUSTER_SIZE),
                   Integer.valueOf(Random.MIN_CLUSTER_SIZE), null,
                   Integer.valueOf(1));
              initComponents();
           }


http://www.mongkie.org                                               26/33
Make a plugin - RandomSettingUI

     RandomSettingUI
           • source code
        package org.mongkie.clustering.plugins.random;

        import javax.swing.JPanel;
        import javax.swing.SpinnerModel;
        import javax.swing.SpinnerNumberModel;
        import org.mongkie.clustering.spi.ClusteringBuilder;

        public class RandomSettingUI extends javax.swing.JPanel implements ClusteringBuilder.SettingUI<Random> {

          private SpinnerModel clusterSizeSpinnerModel;

          /** Creates new form RandomSettingUI */
          RandomSettingUI() {
             clusterSizeSpinnerModel = new SpinnerNumberModel(
                  Integer.valueOf(Random.MIN_CLUSTER_SIZE),
                  Integer.valueOf(Random.MIN_CLUSTER_SIZE), null,
                  Integer.valueOf(1));
             initComponents();
          }
         @Override
          public JPanel getPanel() {
             return this;
          }
          @Override
          public void setup(Random random) {
             clusterSizeSpinner.setValue(random.getClusterSize());
          }
          @Override
          public void apply(Random random) {
             random.setClusterSize((Integer) clusterSizeSpinner.getValue());
          }
          // Variables declaration - do not modify
          private javax.swing.JLabel clusterSizeLabel;
          private javax.swing.JSpinner clusterSizeSpinner;
          // End of variables declaration
        }

http://www.mongkie.org                                                                                             27/33
Make a plugin - RandomSettingUI

     RandomSettingUI
           • source code
        private void initComponents() {

            clusterSizeLabel = new javax.swing.JLabel();
            clusterSizeSpinner = new javax.swing.JSpinner();

            clusterSizeLabel.setText(org.openide.util.NbBundle.getMessage(RandomSettingUI.class, "RandomSettingUI.clusterSizeLabel.text")); // NOI18N

            clusterSizeSpinner.setModel(clusterSizeSpinnerModel);
            clusterSizeSpinner.setPreferredSize(new java.awt.Dimension(50, 26));

            javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
            this.setLayout(layout);
            layout.setHorizontalGroup(
               layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
               .addGroup(layout.createSequentialGroup()
                  .addContainerGap()
                  .addComponent(clusterSizeLabel)
                  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                  .addComponent(clusterSizeSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFER
        RED_SIZE)
                  .addContainerGap(16, Short.MAX_VALUE))
            );
            layout.setVerticalGroup(
               layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
               .addGroup(layout.createSequentialGroup()
                  .addContainerGap()
                  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                     .addComponent(clusterSizeLabel)
                     .addComponent(clusterSizeSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFE
        RRED_SIZE))
                  .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            );
          }



http://www.mongkie.org                                                                                                                                        28/33
Make a plugin - Bundle.properties

     Bundle.properties

       name=Random
       description=Clusterize nodes randomly according to given size of a cluster
       RandomSettingUI.clusterSizeLabel.text=Size of a cluster :




http://www.mongkie.org                                                              29/33
Build and Run

     Clean and Build




http://www.mongkie.org   30/33
Build and Run

     Run




http://www.mongkie.org   31/33
Build and Run

     Run




http://www.mongkie.org   32/33
Q&A
Homepage : http://www.mongkie.org
  Forum : http://forum.mongkie.org
    wiki : http://wiki.mongkie.org




                                     33/33

More Related Content

PDF
JCConf 2015 - 輕鬆學google的雲端開發 - Google App Engine入門(上)
PDF
Google I/O 2021 Recap
PDF
JJUG CCC 2011 Spring
PDF
Fun Teaching MongoDB New Tricks
PDF
Scala Frustrations
PDF
Understanding Source Code Differences by Separating Refactoring Effects
PDF
BDD - Behavior Driven Development Webapps mit Groovy Spock und Geb
PDF
node.js Module Development
JCConf 2015 - 輕鬆學google的雲端開發 - Google App Engine入門(上)
Google I/O 2021 Recap
JJUG CCC 2011 Spring
Fun Teaching MongoDB New Tricks
Scala Frustrations
Understanding Source Code Differences by Separating Refactoring Effects
BDD - Behavior Driven Development Webapps mit Groovy Spock und Geb
node.js Module Development

What's hot (20)

KEY
Backbone intro
PDF
Got Logs? Get Answers with Elasticsearch ELK - PuppetConf 2014
PDF
JavaScript APIs - The Web is the Platform - .toster conference, Moscow
PDF
Node.js in action
PPTX
Sequelize
PDF
Spock and Geb in Action
PDF
Spring 3.0 dependancy injection
DOCX
DOCX
Ejemplo radio
PDF
Aligning Continuous Integration Deployment: Automated Validation of OpenStack...
PDF
Real Time Web with Node
PDF
Node Powered Mobile
PDF
Elastic search 검색
PDF
Deep Dive into Zone.JS
PDF
[Hatsune Miku] Shoot Frieza with Amazon Kinesis ! [EN]
PPTX
Mythbusting: Understanding How We Measure the Performance of MongoDB
PDF
groovy databases
PDF
JavaScript & HTML5 - Brave New World
PDF
연구자 및 교육자를 위한 계산 및 분석 플랫폼 설계 - PyCon KR 2015
PDF
Advanced GORM - Performance, Customization and Monitoring
Backbone intro
Got Logs? Get Answers with Elasticsearch ELK - PuppetConf 2014
JavaScript APIs - The Web is the Platform - .toster conference, Moscow
Node.js in action
Sequelize
Spock and Geb in Action
Spring 3.0 dependancy injection
Ejemplo radio
Aligning Continuous Integration Deployment: Automated Validation of OpenStack...
Real Time Web with Node
Node Powered Mobile
Elastic search 검색
Deep Dive into Zone.JS
[Hatsune Miku] Shoot Frieza with Amazon Kinesis ! [EN]
Mythbusting: Understanding How We Measure the Performance of MongoDB
groovy databases
JavaScript & HTML5 - Brave New World
연구자 및 교육자를 위한 계산 및 분석 플랫폼 설계 - PyCon KR 2015
Advanced GORM - Performance, Customization and Monitoring
Ad

Viewers also liked (10)

PDF
Farw
PPSX
Available paintings 2012
PPTX
netbeansplatform overview
PPTX
20120315 netbeansplatform overview
PPTX
201204 cloning a repository from github
PPTX
201204 create a project and module
PPTX
201204quickstartguide
PPTX
201204 cloning a repository from github
PDF
ATS Overview For Linked In
PDF
Hype vs. Reality: The AI Explainer
Farw
Available paintings 2012
netbeansplatform overview
20120315 netbeansplatform overview
201204 cloning a repository from github
201204 create a project and module
201204quickstartguide
201204 cloning a repository from github
ATS Overview For Linked In
Hype vs. Reality: The AI Explainer
Ad

Recently uploaded (20)

PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PDF
Computing-Curriculum for Schools in Ghana
PDF
Complications of Minimal Access Surgery at WLH
PDF
Anesthesia in Laparoscopic Surgery in India
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PDF
Microbial disease of the cardiovascular and lymphatic systems
PPTX
master seminar digital applications in india
PDF
Insiders guide to clinical Medicine.pdf
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PDF
RMMM.pdf make it easy to upload and study
PPTX
Pharma ospi slides which help in ospi learning
PDF
O7-L3 Supply Chain Operations - ICLT Program
PPTX
Cell Types and Its function , kingdom of life
human mycosis Human fungal infections are called human mycosis..pptx
Pharmacology of Heart Failure /Pharmacotherapy of CHF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
Computing-Curriculum for Schools in Ghana
Complications of Minimal Access Surgery at WLH
Anesthesia in Laparoscopic Surgery in India
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
FourierSeries-QuestionsWithAnswers(Part-A).pdf
Microbial disease of the cardiovascular and lymphatic systems
master seminar digital applications in india
Insiders guide to clinical Medicine.pdf
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
102 student loan defaulters named and shamed – Is someone you know on the list?
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
RMMM.pdf make it easy to upload and study
Pharma ospi slides which help in ospi learning
O7-L3 Supply Chain Operations - ICLT Program
Cell Types and Its function , kingdom of life

201204 random clustering

  • 1. Make a plugin of Random Clustering 2012. 4 http://www.mongkie.org 1/33
  • 2. CONTENTS  CONTENTS • Objectives • Structure of Random Clustering Plugin • make a plugin  Package – org.mongkie.clustering.plugins.random  Classes – Random.java – RandomBuilder.java – RandomSettingUI.java  Others – Bundle.properties • Build and Run http://www.mongkie.org 2/33
  • 3. Objectives  Objectives • make a plugin of random clustering (add random algorithm) Add Random Algorithm http://www.mongkie.org 3/33
  • 4. Clutering Plugins  Structure of Random Clustering • org.mongkie.clustering.plugins.random  Bundle.properties  Random.java  RandomBuilder.java  RandomSettingUI.java Clustering API Clustering Plugins Clustering Plugins org.mongkie.clustering org.mongkie.clustering.plugins org.mongkie.ui.clustering -ClusteringController -ClusteringTopComponent -CluteringModel org.mongkie.clustering.plugins.clustermaker -ClusteringModelListener org.mongkie.ui.clustering.explorer -DefaultClusterImpl org.mongkie.clustering.plugins.clustermaker.converters -ClusterChildFactory -ClusterNode org.mongkie.clustering.impl org.mongkie.clustering.plugins.clustermaker.mcl -ClusteringResultView -ClusteringControllerImpl -ClusteringModelImpl org.mongkie.clustering.plugins.mcl org.mongkie.ui.clustering.explorer.actions -GroupAction org.mongkie.clustering.spi org.mongkie.clustering.plugins.mcode -UngroupAction -Cluster -Clustering org.mongkie.ui.clustering.resources -CluteringBuilder - Image Files http://www.mongkie.org 4/33
  • 5. Make a plugin - Package  [New] –[Java Package] http://www.mongkie.org 5/33
  • 6. Make a plugin - Package  Create a random pacakge • org.mongkie.clustering.plugins.random http://www.mongkie.org 6/33
  • 7. Make a plugin - Package  Create a random pacakge • org.mongkie.clustering.plugins.random http://www.mongkie.org 7/33
  • 8. Make a plugin - Random  Create a random class • Random.java http://www.mongkie.org 8/33
  • 9. Make a plugin - Random  Create a random class • Random.java http://www.mongkie.org 9/33
  • 10. Make a plugin - Random  Create a random class • Random.java http://www.mongkie.org 10/33
  • 11. Make a plugin - Random  Random.java • Source Code package org.mongkie.clustering.plugins.random; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.Iterator; import java.util.List; import org.mongkie.clustering.spi.Cluster; import org.mongkie.clustering.DefaultClusterImpl; import org.mongkie.clustering.spi.Clustering; import org.mongkie.clustering.spi.ClusteringBuilder; import org.openide.util.Exceptions; import prefuse.data.Graph; import prefuse.data.Node; http://www.mongkie.org 11/33
  • 12. Make a plugin - Random  Random.java • implements  Clustering • variables (global)  private final RandomBuilder builder;  private int clusterSize;  static final int MIN_CLUSTER_SIZE = 3;  private List<Cluster> clusters = new ArrayList<Cluster>(); • Constructor Random(RandomBuilder builder) { this.builder = builder; this.clusterSize = MIN_CLUSTER_SIZE; } http://www.mongkie.org 12/33
  • 13. Make a plugin - Random  Random.java • source code public void execute(Graph g) { clearClusters(); List<Node> nodes = new ArrayList<Node>(g.getNodeCount()); Iterator<Node> nodesIter = g.nodes(); while (nodesIter.hasNext()) { Node n = nodesIter.next(); nodes.add(n); } Collections.shuffle(nodes); int i = 1, j = 1; DefaultClusterImpl c = new DefaultClusterImpl(g, "Random " + j); c.setRank(j - 1); for (Node n : nodes) { c.addNode(n); if (i >= clusterSize) { clusters.add(c); c = new DefaultClusterImpl(g, "Random " + ++j); c.setRank(j - 1); i = 1; } else { i++; } } if (c.getNodesCount() > 0) { clusters.add(c); } try { synchronized (this) { wait(1000); } } catch (InterruptedException ex) { Exceptions.printStackTrace(ex); } } http://www.mongkie.org 13/33
  • 14. Make a plugin - Random  Random.java • source code int getClusterSize() { return clusterSize; } void setClusterSize(int clusterSize) { this.clusterSize = clusterSize < MIN_CLUSTER_SIZE ? MIN_CLUSTER_SIZE : clusterSize; } public boolean cancel() { synchronized (this) { clearClusters(); notifyAll(); } return true; } @Override public Collection<Cluster> getClusters() { return clusters; } @Override public void clearClusters() { clusters.clear(); } @Override public ClusteringBuilder getBuilder() { return builder; } http://www.mongkie.org 14/33
  • 15. Make a plugin - RandomBuilder  RandomBuilder.java http://www.mongkie.org 15/33
  • 16. Make a plugin - RandomBuilder  RandomBuilder http://www.mongkie.org 16/33
  • 17. Make a plugin - RandomBuilder  RandomBuilder http://www.mongkie.org 17/33
  • 18. Make a plugin - RandomBuilder  RandomBuilder http://www.mongkie.org 18/33
  • 19. Make a plugin - RandomBuilder  RandomBuilder • implements  ClusteringBuilder • variable(Global)  private final Random random = new Random(this);  private final SettingUI settings = new RandomSettingUI(); http://www.mongkie.org 19/33
  • 20. Make a plugin - RandomBuilder  RandomBuilder • source code package org.mongkie.clustering.plugins.random; import org.mongkie.clustering.spi.Clustering; import org.mongkie.clustering.spi.ClusteringBuilder; import org.mongkie.clustering.spi.ClusteringBuilder.SettingUI; import org.openide.util.NbBundle; import org.openide.util.lookup.ServiceProvider; http://www.mongkie.org 20/33
  • 21. Make a plugin - RandomBuilder  RandomBuilder • source code @ServiceProvider(service = ClusteringBuilder.class) public class RandomBuilder implements ClusteringBuilder { private final Random random = new Random(this); private final SettingUI settings = new RandomSettingUI(); @Override public Clustering getClustering() { return random; } @Override public String getName() { return NbBundle.getMessage(RandomBuilder.class, "name"); } @Override public String getDescription() { return NbBundle.getMessage(RandomBuilder.class, "description"); } @Override public SettingUI getSettingUI() { return settings; } @Override public String toString() { return getName(); } } http://www.mongkie.org 21/33
  • 22. Make a plugin - RandomSettingUI  RandomSettingUI http://www.mongkie.org 22/33
  • 23. Make a plugin - RandomSettingUI  RandomSettingUI http://www.mongkie.org 23/33
  • 24. Make a plugin - RandomSettingUI  RandomSettingUI http://www.mongkie.org 24/33
  • 25. Make a plugin - RandomSettingUI  RandomSettingUI http://www.mongkie.org 25/33
  • 26. Make a plugin - RandomSettingUI  RandomSettingUI • extends  javax.swing.JPanel • implements  ClusteringBuilder.SettingUI<Random> • variable(Global)  private SpinnerModel clusterSizeSpinnerModel; • Constructor RandomSettingUI() { clusterSizeSpinnerModel = new SpinnerNumberModel( Integer.valueOf(Random.MIN_CLUSTER_SIZE), Integer.valueOf(Random.MIN_CLUSTER_SIZE), null, Integer.valueOf(1)); initComponents(); } http://www.mongkie.org 26/33
  • 27. Make a plugin - RandomSettingUI  RandomSettingUI • source code package org.mongkie.clustering.plugins.random; import javax.swing.JPanel; import javax.swing.SpinnerModel; import javax.swing.SpinnerNumberModel; import org.mongkie.clustering.spi.ClusteringBuilder; public class RandomSettingUI extends javax.swing.JPanel implements ClusteringBuilder.SettingUI<Random> { private SpinnerModel clusterSizeSpinnerModel; /** Creates new form RandomSettingUI */ RandomSettingUI() { clusterSizeSpinnerModel = new SpinnerNumberModel( Integer.valueOf(Random.MIN_CLUSTER_SIZE), Integer.valueOf(Random.MIN_CLUSTER_SIZE), null, Integer.valueOf(1)); initComponents(); } @Override public JPanel getPanel() { return this; } @Override public void setup(Random random) { clusterSizeSpinner.setValue(random.getClusterSize()); } @Override public void apply(Random random) { random.setClusterSize((Integer) clusterSizeSpinner.getValue()); } // Variables declaration - do not modify private javax.swing.JLabel clusterSizeLabel; private javax.swing.JSpinner clusterSizeSpinner; // End of variables declaration } http://www.mongkie.org 27/33
  • 28. Make a plugin - RandomSettingUI  RandomSettingUI • source code private void initComponents() { clusterSizeLabel = new javax.swing.JLabel(); clusterSizeSpinner = new javax.swing.JSpinner(); clusterSizeLabel.setText(org.openide.util.NbBundle.getMessage(RandomSettingUI.class, "RandomSettingUI.clusterSizeLabel.text")); // NOI18N clusterSizeSpinner.setModel(clusterSizeSpinnerModel); clusterSizeSpinner.setPreferredSize(new java.awt.Dimension(50, 26)); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addComponent(clusterSizeLabel) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(clusterSizeSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFER RED_SIZE) .addContainerGap(16, Short.MAX_VALUE)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(clusterSizeLabel) .addComponent(clusterSizeSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFE RRED_SIZE)) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); } http://www.mongkie.org 28/33
  • 29. Make a plugin - Bundle.properties  Bundle.properties name=Random description=Clusterize nodes randomly according to given size of a cluster RandomSettingUI.clusterSizeLabel.text=Size of a cluster : http://www.mongkie.org 29/33
  • 30. Build and Run  Clean and Build http://www.mongkie.org 30/33
  • 31. Build and Run  Run http://www.mongkie.org 31/33
  • 32. Build and Run  Run http://www.mongkie.org 32/33
  • 33. Q&A Homepage : http://www.mongkie.org Forum : http://forum.mongkie.org wiki : http://wiki.mongkie.org 33/33