vv.repaint();
}
});
vertLabelPosComboBox.setSelectedItem(Renderer.VertexLabel.Position.AUTO);
GroupLayout jPanel1Layout = new GroupLayout(labelsPanel);
labelsPanel.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(jPanel1Layout
.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout
.createSequentialGroup()
.addGroup(jPanel1Layout
.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(vertLabelCheckBox)
.addGroup(jPanel1Layout
.createSequentialGroup()
.addComponent(vertLabelPos)
.addPreferredGap(
javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(vertLabelPosComboBox, 0, 127,
Short.MAX_VALUE)).addComponent(
edgeLabelCheckBox).addComponent(
showExploredCheckBox)).addContainerGap()));
jPanel1Layout.setVerticalGroup(jPanel1Layout
.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout
.createSequentialGroup()
.addComponent(vertLabelCheckBox)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout
.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout
.createParallelGroup(
javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(vertLabelPos)
.addComponent(vertLabelPosComboBox,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout
.createSequentialGroup()
.addGap(25, 25, 25)
.addGroup(jPanel1Layout
.createParallelGroup(
javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(edgeLabelCheckBox))))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 2,
Short.MAX_VALUE).addComponent(showExploredCheckBox)));
layoutTypePanel.setBorder(BorderFactory.createTitledBorder("Layout Type"));
layoutTypeComboBox.setName("layoutTypeComboBox");
layoutTypeComboBox.setModel(new DefaultComboBoxModel(new JUNGHelper.LayoutType[] { JUNGHelper.LayoutType.FR,
JUNGHelper.LayoutType.CIRCLE, JUNGHelper.LayoutType.ISOM, JUNGHelper.LayoutType.KK,
JUNGHelper.LayoutType.SPRING }));
layoutTypeComboBox.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
try {
if (e.getStateChange() == ItemEvent.SELECTED) {
Layout<Object, Object> l = jView_.getLayout((JUNGHelper.LayoutType) e.getItem());
l.setGraph(g);
l.setInitializer(vv.getGraphLayout());
l.setSize(vv.getSize());
LayoutTransition<Object, Object> lt = new LayoutTransition<Object, Object>(vv, vv
.getGraphLayout(), l);
Animator animator = new Animator(lt);
animator.start();
layout = l;
vv.repaint();
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
});
layoutTypeComboBox.setSelectedItem(JUNGHelper.LayoutType.FR);
GroupLayout layoutTypePanelLayout = new GroupLayout(layoutTypePanel);
layoutTypePanel.setLayout(layoutTypePanelLayout);
layoutTypePanelLayout.setHorizontalGroup(layoutTypePanelLayout.createParallelGroup(
GroupLayout.Alignment.LEADING).addComponent(layoutTypeComboBox, 0, 178, Short.MAX_VALUE));
layoutTypePanelLayout.setVerticalGroup(layoutTypePanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(layoutTypePanelLayout.createSequentialGroup().addComponent(layoutTypeComboBox,
GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE).addContainerGap(
GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
mergePanel.setBorder(BorderFactory.createTitledBorder("Merge"));
mergeVerticesButton.setText("Merge states");
mergeVerticesButton.addActionListener(this);
mergeVerticesButton.setActionCommand("mergeVerticesButton");
expandVerticesButton.setText("Expand states");
expandVerticesButton.addActionListener(this);
expandVerticesButton.setActionCommand("expandVerticesButton");
mergeEdgesButton.setText("Merge transitions");
mergeEdgesButton.addActionListener(this);
mergeEdgesButton.setActionCommand("mergeEdgesButton");
expandEdgesButton.setText("Expand transitions");
expandEdgesButton.addActionListener(this);
expandEdgesButton.setActionCommand("expandEdgesButton");
resetButton.setText("Reset");
resetButton.addActionListener(this);
resetButton.setActionCommand("resetButton");
GroupLayout jPanel3Layout = new GroupLayout(mergePanel);
mergePanel.setLayout(jPanel3Layout);
jPanel3Layout.setHorizontalGroup(jPanel3Layout.createParallelGroup(GroupLayout.Alignment.LEADING).addComponent(
expandVerticesButton, GroupLayout.DEFAULT_SIZE, 151, Short.MAX_VALUE).addComponent(
mergeVerticesButton, GroupLayout.DEFAULT_SIZE, 151, Short.MAX_VALUE)
//TODO add these back when the merge edges has been fixed.
//.addComponent(mergeEdgesButton, GroupLayout.DEFAULT_SIZE, 151, Short.MAX_VALUE)
//.addComponent(expandEdgesButton, GroupLayout.DEFAULT_SIZE, 151, Short.MAX_VALUE)
.addComponent(resetButton, GroupLayout.DEFAULT_SIZE, 151, Short.MAX_VALUE));
jPanel3Layout.setVerticalGroup(jPanel3Layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(
jPanel3Layout.createSequentialGroup().addComponent(mergeVerticesButton).addPreferredGap(
LayoutStyle.ComponentPlacement.RELATED).addComponent(expandVerticesButton)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
// TODO add these back when the merge edges has been fixed.
//.addComponent(mergeEdgesButton)
//.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 7, Short.MAX_VALUE)
//.addComponent(expandEdgesButton)
//.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addComponent(resetButton).addContainerGap()));
animationPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Animation"));
//Create the label table
Hashtable<Integer, JLabel> labelTable = new Hashtable<Integer, JLabel>();
labelTable.put(new Integer(100), new JLabel("Fast"));
labelTable.put(new Integer(1000), new JLabel("Normal"));
labelTable.put(new Integer(3000), new JLabel("Slow"));
animationSlider.setLabelTable(labelTable);
animationSlider.setPaintLabels(true);
animationSlider.setMajorTickSpacing(500);
animationSlider.setMaximum(3000);
animationSlider.setMinimum(100);
animationSlider.setValue(300);
animationSlider.setPaintTicks(true);
animationSlider.setToolTipText("Use this slider to control the speed of the animation");
animationSlider.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent evt) {
JSlider slider = (JSlider) evt.getSource();
if (!slider.getValueIsAdjusting()) {
animationSleepTime_ = slider.getValue();
}
}
});
animationSleepTime_ = animationSlider.getValue();
animationButton.setText("Stop");
animationButton.addActionListener(this);
animationButton.setActionCommand("animationButton");
animationCheckBox.setText("Show animation");
animationCheckBox.setSelected(true);
animationCheckBox.addActionListener(this);
animationCheckBox.setActionCommand("animationCheckBox");
animationToggleButton.setText("Pause");
animationToggleButton.addActionListener(this);
animationToggleButton.setActionCommand("animationToggleButton");
javax.swing.GroupLayout animationPanelLayout = new javax.swing.GroupLayout(animationPanel);
animationPanel.setLayout(animationPanelLayout);
animationPanelLayout
.setHorizontalGroup(animationPanelLayout
.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(animationPanelLayout
.createSequentialGroup()
.addContainerGap()
.addGroup(animationPanelLayout
.createParallelGroup(
javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(animationSlider,
javax.swing.GroupLayout.Alignment.TRAILING,
javax.swing.GroupLayout.DEFAULT_SIZE,
157, Short.MAX_VALUE)
.addGroup(animationPanelLayout
.createParallelGroup(
javax.swing.GroupLayout.Alignment.TRAILING,
false)
.addGroup(animationPanelLayout
.createSequentialGroup()
.addComponent(animationToggleButton,
GroupLayout.DEFAULT_SIZE,
GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)
.addPreferredGap(
LayoutStyle.ComponentPlacement.RELATED)
.addComponent(animationButton,
GroupLayout.DEFAULT_SIZE,
GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE))
.addComponent(animationCheckBox,
javax.swing.GroupLayout.Alignment.LEADING)))
.addContainerGap()));
animationPanelLayout.setVerticalGroup(animationPanelLayout.createParallelGroup(
javax.swing.GroupLayout.Alignment.LEADING).addGroup(
animationPanelLayout.createSequentialGroup().addComponent(animationCheckBox).addPreferredGap(
javax.swing.LayoutStyle.ComponentPlacement.RELATED).addGroup(
animationPanelLayout.createParallelGroup(
javax.swing.GroupLayout.Alignment.BASELINE).addComponent(
animationToggleButton).addComponent(animationButton))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(animationSlider, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE).addContainerGap(21,
Short.MAX_VALUE)));
capturePanel.setBorder(BorderFactory.createTitledBorder("Capture"));
captureButton.setText("Save as image");
captureButton.addActionListener(this);
captureButton.setActionCommand("captureButton");
GroupLayout jPanel4Layout = new GroupLayout(capturePanel);
capturePanel.setLayout(jPanel4Layout);
jPanel4Layout.setHorizontalGroup(jPanel4Layout.createParallelGroup(GroupLayout.Alignment.LEADING).addComponent(
captureButton, GroupLayout.DEFAULT_SIZE, 151, Short.MAX_VALUE));
jPanel4Layout.setVerticalGroup(jPanel4Layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(
jPanel4Layout.createSequentialGroup().addComponent(captureButton).addContainerGap(
GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
GroupLayout layout = new GroupLayout(panel);
panel.setLayout(layout);
layout.setHorizontalGroup(layout
.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(layoutTypePanel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)
.addComponent(labelsPanel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(mergePanel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(capturePanel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(animationPanel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE));
layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(
layout.createSequentialGroup().addComponent(labelsPanel, GroupLayout.PREFERRED_SIZE,
GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE).addPreferredGap(
LayoutStyle.ComponentPlacement.RELATED).addComponent(layoutTypePanel,
GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
GroupLayout.PREFERRED_SIZE).addPreferredGap(
LayoutStyle.ComponentPlacement.RELATED).addComponent(mergePanel,