Commit c62f3584 authored by Krzysztof Nowinski's avatar Krzysztof Nowinski

Surface components module generalized to accept all types of irregular input...

Surface components module generalized to accept all types of irregular input fields and renamed to connected components
parent ddf35735
......@@ -102,7 +102,7 @@
<core package="pl.edu.icm.visnow.lib.basic.mappers.Isosurface"/>
<core package="pl.edu.icm.visnow.lib.basic.mappers.Isovolume"/>
<core package="pl.edu.icm.visnow.lib.basic.mappers.LineSlice"/>
<core package="pl.edu.icm.visnow.lib.basic.mappers.SurfaceComponents"/>
<core package="pl.edu.icm.visnow.lib.basic.mappers.ConnectedComponents"/>
<core package="pl.edu.icm.visnow.lib.basic.mappers.VolumeRenderer"/>
<core package="pl.edu.icm.visnow.lib.basic.mappers.PlanarSlice"/>
<core package="pl.edu.icm.visnow.lib.basic.mappers.RegularFieldSlice"/>
......
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.5" maxVersion="1.5" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<Properties>
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[180, 390]"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[200, 395]"/>
</Property>
<Property name="verifyInputWhenFocusTarget" type="boolean" value="false"/>
</Properties>
<AuxValues>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
<AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,-117,0,0,0,-25"/>
</AuxValues>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
<SubComponents>
<Container class="javax.swing.JPanel" name="jPanel2">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
<TitledBorder title="minimum vertices in shown component">
<Font PropertyName="font" name="Dialog" size="10" style="0"/>
</TitledBorder>
</Border>
</Property>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="0" gridY="0" gridWidth="1" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="17" weightX="1.0" weightY="0.0"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
<SubComponents>
<Component class="javax.swing.JSlider" name="minSizeSlider">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="8" style="0"/>
</Property>
<Property name="majorTickSpacing" type="int" value="1"/>
<Property name="maximum" type="int" value="12"/>
<Property name="paintLabels" type="boolean" value="true"/>
<Property name="paintTicks" type="boolean" value="true"/>
<Property name="value" type="int" value="3"/>
</Properties>
<Events>
<EventHandler event="stateChanged" listener="javax.swing.event.ChangeListener" parameters="javax.swing.event.ChangeEvent" handler="minSizeSliderStateChanged"/>
</Events>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
<BorderConstraints direction="Center"/>
</Constraint>
</Constraints>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="jPanel4">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
<TitledBorder title="individual cell sets">
<Font PropertyName="font" name="Dialog" size="10" style="0"/>
</TitledBorder>
</Border>
</Property>
</Properties>
<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="1" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
<SubComponents>
<Component class="javax.swing.JSlider" name="separateSlider">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="8" style="0"/>
</Property>
<Property name="majorTickSpacing" type="int" value="10"/>
<Property name="maximum" type="int" value="50"/>
<Property name="minorTickSpacing" type="int" value="2"/>
<Property name="paintLabels" type="boolean" value="true"/>
<Property name="paintTicks" type="boolean" value="true"/>
<Property name="value" type="int" value="20"/>
</Properties>
<Events>
<EventHandler event="stateChanged" listener="javax.swing.event.ChangeListener" parameters="javax.swing.event.ChangeEvent" handler="separateSliderStateChanged"/>
</Events>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
<BorderConstraints direction="Center"/>
</Constraint>
</Constraints>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JScrollPane" name="jScrollPane1">
<AuxValues>
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
</AuxValues>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="0" gridY="4" gridWidth="1" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="1.0" weightY="1.0"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
<SubComponents>
<Component class="javax.swing.JTable" name="componentTable">
<Properties>
<Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.editors2.TableModelEditor">
<Table columnCount="2" rowCount="4">
<Column editable="true" title="component name" type="java.lang.Object"/>
<Column editable="true" title="size" type="java.lang.Object"/>
</Table>
</Property>
<Property name="columnModel" type="javax.swing.table.TableColumnModel" editor="org.netbeans.modules.form.editors2.TableColumnModelEditor">
<TableColumnModel selectionModel="0">
<Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true">
<Title/>
<Editor/>
<Renderer/>
</Column>
<Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true">
<Title/>
<Editor/>
<Renderer/>
</Column>
</TableColumnModel>
</Property>
<Property name="tableHeader" type="javax.swing.table.JTableHeader" editor="org.netbeans.modules.form.editors2.JTableHeaderEditor">
<TableHeader reorderingAllowed="true" resizingAllowed="true"/>
</Property>
</Properties>
</Component>
</SubComponents>
</Container>
<Component class="javax.swing.JButton" name="jButton1">
<Properties>
<Property name="text" type="java.lang.String" value="run"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton1ActionPerformed"/>
</Events>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="0" gridY="3" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/>
</Constraint>
</Constraints>
</Component>
<Component class="javax.swing.JCheckBox" name="colorByComponentsBox">
<Properties>
<Property name="text" type="java.lang.String" value="color by components"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="colorByComponentsBoxActionPerformed"/>
</Events>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="0" gridY="2" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="17" weightX="0.0" weightY="0.0"/>
</Constraint>
</Constraints>
</Component>
</SubComponents>
</Form>
/* VisNow
Copyright (C) 2006-2013 University of Warsaw, ICM
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
University of Warsaw, Interdisciplinary Centre for Mathematical and
Computational Modelling, Pawinskiego 5a, 02-106 Warsaw, Poland.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
package pl.edu.icm.visnow.lib.basic.filters.SurfaceComponents;
import java.util.Hashtable;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import pl.edu.icm.jscic.IrregularField;
import pl.edu.icm.visnow.lib.utils.SwingInstancer;
/**
*
* @author Krzysztof S. Nowinski, University of Warsaw, ICM
*/
public class GUI extends JPanel
{
private Params params = null;
private Hashtable<Integer, JLabel> downLabels = new Hashtable<Integer, JLabel>();
private int[] scale = {0, 5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000};
private String[] downTexts = {"0", "", "10", "", "", "100", "", "", "1000", "", "", "10000"};
private static final String[] tableHeader = new String[]{"component name", "size"};
private static final Class[] tableTypes = new Class[]{String.class, Integer.class};
private Object[][] tableContent = null;
private ProcessComponents pc = null;
/**
* Creates new form SkeletonizerUI
*/
public GUI()
{
initComponents();
componentTable.getColumnModel().getColumn(1).setPreferredWidth(40);
for (int i = 0; i < downTexts.length; i++) {
downLabels.put(i, new JLabel(downTexts[i]));
downLabels.get(i).setFont(new java.awt.Font("Dialog", 0, 8));
}
minSizeSlider.setLabelTable(downLabels);
}
/**
* This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
java.awt.GridBagConstraints gridBagConstraints;
jPanel2 = new javax.swing.JPanel();
minSizeSlider = new javax.swing.JSlider();
jPanel4 = new javax.swing.JPanel();
separateSlider = new javax.swing.JSlider();
jScrollPane1 = new javax.swing.JScrollPane();
componentTable = new javax.swing.JTable();
jButton1 = new javax.swing.JButton();
colorByComponentsBox = new javax.swing.JCheckBox();
setMinimumSize(new java.awt.Dimension(180, 390));
setPreferredSize(new java.awt.Dimension(200, 395));
setVerifyInputWhenFocusTarget(false);
setLayout(new java.awt.GridBagLayout());
jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "minimum vertices in shown component", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Dialog", 0, 10))); // NOI18N
jPanel2.setLayout(new java.awt.BorderLayout());
minSizeSlider.setFont(new java.awt.Font("Dialog", 0, 8));
minSizeSlider.setMajorTickSpacing(1);
minSizeSlider.setMaximum(12);
minSizeSlider.setPaintLabels(true);
minSizeSlider.setPaintTicks(true);
minSizeSlider.setValue(3);
minSizeSlider.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
minSizeSliderStateChanged(evt);
}
});
jPanel2.add(minSizeSlider, java.awt.BorderLayout.CENTER);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.weightx = 1.0;
add(jPanel2, gridBagConstraints);
jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "individual cell sets", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Dialog", 0, 10))); // NOI18N
jPanel4.setLayout(new java.awt.BorderLayout());
separateSlider.setFont(new java.awt.Font("Dialog", 0, 8));
separateSlider.setMajorTickSpacing(10);
separateSlider.setMaximum(50);
separateSlider.setMinorTickSpacing(2);
separateSlider.setPaintLabels(true);
separateSlider.setPaintTicks(true);
separateSlider.setValue(20);
separateSlider.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
separateSliderStateChanged(evt);
}
});
jPanel4.add(separateSlider, java.awt.BorderLayout.CENTER);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 1;
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
add(jPanel4, gridBagConstraints);
componentTable.setModel(new javax.swing.table.DefaultTableModel(
new Object[][] {
{ null, null },
{ null, null },
{ null, null },
{ null, null }
},
new String[] {
"component name", "size"
}
));
jScrollPane1.setViewportView(componentTable);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 4;
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints.weightx = 1.0;
gridBagConstraints.weighty = 1.0;
add(jScrollPane1, gridBagConstraints);
jButton1.setText("run");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 3;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
add(jButton1, gridBagConstraints);
colorByComponentsBox.setText("color by components");
colorByComponentsBox.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
colorByComponentsBoxActionPerformed(evt);
}
});
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
add(colorByComponentsBox, gridBagConstraints);
}// </editor-fold>//GEN-END:initComponents
private void minSizeSliderStateChanged(javax.swing.event.ChangeEvent evt)//GEN-FIRST:event_minSizeSliderStateChanged
{//GEN-HEADEREND:event_minSizeSliderStateChanged
if (params != null) {
params.setMinComponentSize(scale[minSizeSlider.getValue()]);
updateComponentTable();
}
}//GEN-LAST:event_minSizeSliderStateChanged
private void separateSliderStateChanged(javax.swing.event.ChangeEvent evt)//GEN-FIRST:event_separateSliderStateChanged
{//GEN-HEADEREND:event_separateSliderStateChanged
if (params != null)
params.setSeparateComponents(separateSlider.getValue());
}//GEN-LAST:event_separateSliderStateChanged
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jButton1ActionPerformed
{//GEN-HEADEREND:event_jButton1ActionPerformed
if (params != null)
params.fireStateChanged();
}//GEN-LAST:event_jButton1ActionPerformed
private void colorByComponentsBoxActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_colorByComponentsBoxActionPerformed
{//GEN-HEADEREND:event_colorByComponentsBoxActionPerformed
if (params != null)
params.setColorByComponents(colorByComponentsBox.isSelected());
}//GEN-LAST:event_colorByComponentsBoxActionPerformed
public void setParams(Params params)
{
params.setActive(false);
this.params = params;
}
private void updateComponentTable()
{
if (pc == null)
return;
IrregularField inField = pc.getInField();
int[][] cellSetComponentSizes = pc.getCellSetComponentSizes();
if (inField == null)
return;
int minComponentSize = params.getMinComponentSize();
int nComponents = 0;
for (int i = 0, l; i < inField.getNCellSets(); i++)
for (int j = 0; j < cellSetComponentSizes[i].length; j += 2)
if (cellSetComponentSizes[i][j] >= minComponentSize)
nComponents += 1;
tableContent = new Object[nComponents][2];
for (int i = 0, l = 0; i < inField.getNCellSets(); i++)
for (int j = 0; j < cellSetComponentSizes[i].length; j += 2)
if (cellSetComponentSizes[i][j] >= minComponentSize) {
tableContent[l][0] = inField.getCellSet(i).getName() + cellSetComponentSizes[i][j + 1];
tableContent[l][1] = "" + cellSetComponentSizes[i][j];
l += 1;
}
SwingInstancer.swingRunAndWait(new Runnable()
{
public void run()
{
componentTable.setModel(new javax.swing.table.DefaultTableModel(tableContent, tableHeader)
{
@Override
public Class getColumnClass(int columnIndex)
{
return tableTypes[columnIndex];
}
});
}
});
}
ChangeListener newCmpListener = new ChangeListener()
{
public void stateChanged(ChangeEvent evt)
{
pc = (ProcessComponents) evt.getSource();
updateComponentTable();
}
};
public ChangeListener getNewCmpListener()
{
return newCmpListener;
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JCheckBox colorByComponentsBox;
private javax.swing.JTable componentTable;
private javax.swing.JButton jButton1;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel4;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JSlider minSizeSlider;
private javax.swing.JSlider separateSlider;
// End of variables declaration//GEN-END:variables
}
/* VisNow
Copyright (C) 2006-2013 University of Warsaw, ICM
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
University of Warsaw, Interdisciplinary Centre for Mathematical and
Computational Modelling, Pawinskiego 5a, 02-106 Warsaw, Poland.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
package pl.edu.icm.visnow.lib.basic.filters.SurfaceComponents;
import pl.edu.icm.visnow.engine.core.Parameter;
import pl.edu.icm.visnow.engine.core.ParameterEgg;
import pl.edu.icm.visnow.engine.core.ParameterType;
import pl.edu.icm.visnow.engine.core.Parameters;
/**
*
* @author Krzysztof S. Nowinski
* Warsaw University, ICM
*/
public class Params extends Parameters
{
private Parameter<Integer> minComponentSize;
private Parameter<Integer> separateComponents;
private Parameter<Boolean> colorByComponents;
boolean minComponentSizeChanged = false;
@SuppressWarnings("unchecked")
private void initParameters()
{
minComponentSize = getParameter("minComponentSize");
separateComponents = getParameter("separateComponents");
colorByComponents = getParameter("colorByComponents");
colorByComponents.setValue(true);
minComponentSize.setValue(20);
separateComponents.setValue(20);
colorByComponents.setValue(true);
}
private static ParameterEgg[] eggs = new ParameterEgg[]{
new ParameterEgg<Integer>("minComponentSize", ParameterType.dependent),
new ParameterEgg<Integer>("separateComponents", ParameterType.dependent),
new ParameterEgg<Boolean>("colorByComponents", ParameterType.dependent),};
public Params()
{
super(eggs);
initParameters();
}
public int getMinComponentSize()
{
return minComponentSize.getValue();
}
public void setMinComponentSize(int minComponentSize)
{
this.minComponentSize.setValue(minComponentSize);
minComponentSizeChanged = true;
}
public int getSeparateComponents()
{
return separateComponents.getValue();
}
public void setSeparateComponents(int separateComponents)
{
this.separateComponents.setValue(separateComponents);
}
public boolean colorByComponents()
{
return colorByComponents.getValue();
}
public void setColorByComponents(boolean colorByComponents)
{
this.colorByComponents.setValue(colorByComponents);
}
public boolean isMinComponentSizeChanged()
{
boolean t = minComponentSizeChanged;
minComponentSizeChanged = false;
return t;
}
}
/* VisNow
Copyright (C) 2006-2013 University of Warsaw, ICM
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
University of Warsaw, Interdisciplinary Centre for Mathematical and
Computational Modelling, Pawinskiego 5a, 02-106 Warsaw, Poland.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
package pl.edu.icm.visnow.lib.basic.filters.SurfaceComponents;
import java.util.ArrayList;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import org.apache.log4j.Logger;
import pl.edu.icm.jscic.cells.Cell;
import pl.edu.icm.jscic.CellArray;
import pl.edu.icm.jscic.CellSet;
import pl.edu.icm.jscic.dataarrays.DataArray;
import pl.edu.icm.jscic.IrregularField;
import pl.edu.icm.jscic.cells.CellType;
import pl.edu.icm.visnow.gui.events.FloatValueModificationEvent;
import pl.edu.icm.visnow.gui.events.FloatValueModificationListener;
import pl.edu.icm.visnow.lib.utils.numeric.HeapSort;
/**
*
* @author Krzysztof S. Nowinski, University of Warsaw, ICM
*/
public class ProcessComponents
{
private IrregularField inField;
private int[][] cellSetComponents = null;
private int[][] cellSetComponentSizes = null;
private int[] cellSetNComponents = null;
static Logger logger = Logger.getLogger(ProcessComponents.class);
public ProcessComponents()
{
}
public void setInField(IrregularField inField, Params params)
{
this.inField = inField;
cellSetComponents = new int[inField.getNCellSets()][(int) inField.getNNodes()]; //holder for component indices: cellSetComponents[i][j] = k iff node j belongs to kth component of cell set i
cellSetComponentSizes = new int[inField.getNCellSets()][]; //holder for component sizes: cellSetComponentSizes[i][2*j] is number of vertices in jth component of cell set i,
//for sorting purposes: cellSetComponentSizes[i][2*j+1] is component number