下面列出了java.awt.GridBagConstraints#PAGE_START 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* Constructor, creating GUI items.
*/
public EditPresentationModeControlPanel() {
setLayout(new GridBagLayout());
// global layout settings
GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.BOTH;
c.anchor = GridBagConstraints.PAGE_START;
c.weightx = 0.5;
c.gridx = 0;
c.gridy = 0;
c.gridheight = 1;
c.gridwidth = 1;
c.insets = new Insets(5,5,5,5);
c.gridx = 0;
//to consume the rest of the space
c.weighty = 1.0;
++c.gridy;
JPanel space = new JPanel();
space.setOpaque(false);
add(space, c);
}
/**
* Creates just an empty panel (shown when deleting a street).
*
* @return the panel
*/
private final JPanel createDeletePanel(){
JPanel deletePanel = new JPanel(new GridBagLayout());
GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.BOTH;
c.anchor = GridBagConstraints.PAGE_START;
c.weightx = 0.5;
c.gridx = 0;
c.gridy = 0;
c.gridheight = 1;
c.gridwidth = 1;
//to consume the rest of the space
c.gridwidth = 1;
c.weighty = 1.0;
++c.gridy;
deletePanel.add(new JPanel(), c);
return deletePanel;
}
/**
* Creates the panel which is shown when mix zones fallback communication mode is enabled.
*
* @return the control panel
*/
private final JPanel createMixFallBackPanel(){
JPanel panel = new JPanel();
panel.setOpaque(false);
panel.setLayout(new GridBagLayout());
GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.BOTH;
c.anchor = GridBagConstraints.PAGE_START;
c.weightx = 1;
c.gridx = 0;
c.gridy = 0;
c.gridheight = 1;
c.insets = new Insets(5,10,5,0);
fallbackInMixZonesFloodingOnlyCheckBox_ = new JCheckBox(Messages.getString("EditSettingsControlPanel.falllbackCommunicationOnlyForFlooding"), true); //$NON-NLS-1$
fallbackInMixZonesFloodingOnlyCheckBox_.addItemListener(this);
panel.add(fallbackInMixZonesFloodingOnlyCheckBox_, c);
return panel;
}
private void createLayout() {
logger.info("Creating layout. @TestResultsPanel");
this.setLayout(new GridBagLayout());
// we want the progress bar to be separate from the scroll panel
GridBagConstraints gbc = new GridBagConstraints();
gbc.gridy = 0;
gbc.gridwidth = 1;
gbc.gridheight = 1;
gbc.weightx = 1.0;
gbc.anchor = GridBagConstraints.PAGE_START;
gbc.fill = GridBagConstraints.HORIZONTAL;
addProgressBar(gbc);
final JScrollPane scrollPane1 = new JBScrollPane();
scrollPane1.setVerticalScrollBarPolicy(JBScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
scrollPane1.setHorizontalScrollBarPolicy(JBScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
gbc.gridy = 1;
gbc.weighty = 1.0;
gbc.anchor = GridBagConstraints.CENTER;
gbc.fill = GridBagConstraints.BOTH;
this.add(scrollPane1, gbc);
resultsList = new JPanel();
resultsList.setLayout(new GridBagLayout());
scrollPane1.setViewportView(resultsList);
}
/**
* Constructor, creating GUI items.
*/
public EditDataAnalysisControlPanel() {
setLayout(new GridBagLayout());
// global layout settings
GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.BOTH;
c.anchor = GridBagConstraints.PAGE_START;
c.weightx = 0.5;
c.gridx = 0;
c.gridy = 0;
c.gridheight = 1;
c.gridwidth = 1;
c.insets = new Insets(5,5,5,5);
c.gridx = 0;
//to consume the rest of the space
c.weighty = 1.0;
++c.gridy;
JPanel space = new JPanel();
space.setOpaque(false);
add(space, c);
}
/**
* Constructor for this control panel.
*/
public AboutControlPanel(){
setLayout(new GridBagLayout());
GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.BOTH;
c.anchor = GridBagConstraints.PAGE_START;
c.weightx = 0.5;
c.weighty = 0;
c.gridx = 0;
c.gridy = 0;
c.gridheight = 1;
c.insets = new Insets(5,5,5,5);
c.gridwidth = 1;
//label for display of credits.
++c.gridy;
add(new JLabel("<html><b>" + Messages.getString("AboutDialog.creditsHeader") + "</b></html>"), c);
++c.gridy;
add(new TextAreaLabel(Messages.getString("AboutDialog.credits")), c);
//to consume the rest of the space
c.weighty = 1.0;
++c.gridy;
JPanel pane = new JPanel();
pane.setOpaque(false);
add(pane, c);
}
/**
* Creates the panel which is shown when beacon sending is enabled.
*
* @return the beacon panel
*/
private final JPanel createBeaconPanel(){
JPanel panel = new JPanel();
panel.setOpaque(false);
panel.setLayout(new GridBagLayout());
GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.BOTH;
c.anchor = GridBagConstraints.PAGE_START;
c.weightx = 1;
c.gridx = 0;
c.gridy = 0;
c.gridheight = 1;
c.insets = new Insets(5,0,5,0);
JLabel jLabel1 = new JLabel(Messages.getString("EditSettingsControlPanel.beaconInterval")); //$NON-NLS-1$
panel.add(jLabel1,c);
beaconInterval_ = new JFormattedTextField(NumberFormat.getIntegerInstance());
beaconInterval_.setPreferredSize(new Dimension(60,20));
beaconInterval_.setValue(240);
beaconInterval_.addPropertyChangeListener("value", this); //$NON-NLS-1$
c.gridx = 1;
c.weightx = 0;
panel.add(beaconInterval_,c);
c.gridx = 0;
c.gridwidth = 2;
++c.gridy;
globalInfrastructureCheckBox_ = new JCheckBox(Messages.getString("EditSettingsControlPanel.enableInfrastructure"), true); //$NON-NLS-1$
globalInfrastructureCheckBox_.addItemListener(this);
// Disabled as it's not yet implemented
// beaconPanel_.add(globalInfrastructureCheckBox_,c);
return panel;
}
/**
* Creates the panel which is shown when mix zones are enabled.
*
* @return the mix zones panel
*/
private final JPanel createMixPanel(){
JPanel panel = new JPanel();
panel.setOpaque(false);
panel.setLayout(new GridBagLayout());
GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.BOTH;
c.anchor = GridBagConstraints.PAGE_START;
c.weightx = 1;
c.gridx = 0;
c.gridy = 0;
c.gridheight = 1;
c.insets = new Insets(5,0,5,0);
JLabel jLabel1 = new JLabel(Messages.getString("EditSettingsControlPanel.mixZoneSize")); //$NON-NLS-1$
panel.add(jLabel1,c);
mixZoneRadius_ = new JFormattedTextField(NumberFormat.getIntegerInstance());
mixZoneRadius_.setPreferredSize(new Dimension(60,20));
mixZoneRadius_.setValue(100);
mixZoneRadius_.addPropertyChangeListener("value", this); //$NON-NLS-1$
c.gridx = 1;
c.weightx = 0;
panel.add(mixZoneRadius_,c);
c.gridx = 0;
c.gridwidth = 2;
++c.gridy;
fallbackInMixZonesCheckBox_ = new JCheckBox(Messages.getString("EditSettingsControlPanel.fallbackCommunicationInMixZones"), true); //$NON-NLS-1$
fallbackInMixZonesCheckBox_.addItemListener(this);
panel.add(fallbackInMixZonesCheckBox_,c);
++c.gridy;
fallbackInMixZonesPanel_ = createMixFallBackPanel();
panel.add(fallbackInMixZonesPanel_,c);
return panel;
}
VariableTab(VariableList data) {
this.data = data;
list.setModel(new VariableListModel(data));
list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
list.addListSelectionListener(myListener);
remove.addActionListener(myListener);
moveUp.addActionListener(myListener);
moveDown.addActionListener(myListener);
add.addActionListener(myListener);
rename.addActionListener(myListener);
field.addActionListener(myListener);
field.getDocument().addDocumentListener(myListener);
JScrollPane listPane = new JScrollPane(list, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
listPane.setPreferredSize(new Dimension(100, 100));
JPanel topPanel = new JPanel(new GridLayout(3, 1));
topPanel.add(remove);
topPanel.add(moveUp);
topPanel.add(moveDown);
JPanel fieldPanel = new JPanel();
fieldPanel.add(rename);
fieldPanel.add(add);
GridBagLayout gb = new GridBagLayout();
GridBagConstraints gc = new GridBagConstraints();
setLayout(gb);
gc.insets = new Insets(10, 10, 0, 10);
gc.fill = GridBagConstraints.BOTH;
gc.weightx = 1.0;
gb.setConstraints(listPane, gc);
add(listPane);
gc.fill = GridBagConstraints.NONE;
gc.anchor = GridBagConstraints.PAGE_START;
gc.weightx = 0.0;
gb.setConstraints(topPanel, gc);
add(topPanel);
gc.gridwidth = GridBagConstraints.REMAINDER;
gc.gridx = 0;
gc.gridy = GridBagConstraints.RELATIVE;
gc.fill = GridBagConstraints.HORIZONTAL;
gb.setConstraints(field, gc);
field.setBorder(BorderFactory.createLineBorder(new Color(130, 135, 144)));
add(field);
gb.setConstraints(fieldPanel, gc);
add(fieldPanel);
gc.fill = GridBagConstraints.HORIZONTAL;
gb.setConstraints(error, gc);
add(error);
if (!data.isEmpty())
list.setSelectedValue(data.get(0), true);
computeEnabled();
}
public void addComponents(JPanel panel)
{
GridBagConstraints gbc = new GridBagConstraints();
gbc.anchor = GridBagConstraints.PAGE_START;
gbc.gridwidth = 1;
gbc.fill = GridBagConstraints.BOTH;
gbc.insets = new Insets(1, 2, 1, 2);
panel.add(label, gbc);
int numComponents = 0;
numComponents += textField.isPresent() ? 1 : 0;
numComponents += combobox.isPresent() ? 1 : 0;
numComponents += trailinglabel.isPresent() ? 1 : 0;
switch (numComponents)
{
case 3:
gbc.weightx = 0.3333;
break;
case 2:
gbc.weightx = 0.5;
break;
default:
gbc.weightx = 1.0;
break;
}
combobox.ifPresent(box -> panel.add(box, gbc));
if (trailinglabel.isEmpty())
{
gbc.gridwidth = GridBagConstraints.REMAINDER;
}
textField.ifPresent(field -> panel.add(field, gbc));
gbc.gridwidth = GridBagConstraints.REMAINDER;
if (trailinglabel.isPresent())
{
panel.add(trailinglabel.get(), gbc);
}
else if (numComponents < 2)
{
//We need a filler component so just use the lightweight Box
panel.add(Box.createHorizontalGlue(), gbc);
}
}
public void addComponents(JPanel panel)
{
GridBagConstraints gbc = new GridBagConstraints();
gbc.anchor = GridBagConstraints.PAGE_START;
gbc.gridwidth = 1;
gbc.fill = GridBagConstraints.BOTH;
gbc.insets = new Insets(1, 2, 1, 2);
panel.add(label, gbc);
int numComponents = 0;
numComponents += textField.isPresent() ? 1 : 0;
numComponents += combobox.isPresent() ? 1 : 0;
numComponents += trailinglabel.isPresent() ? 1 : 0;
switch (numComponents)
{
case 3:
gbc.weightx = 0.3333;
break;
case 2:
gbc.weightx = 0.5;
break;
default:
gbc.weightx = 1.0;
break;
}
combobox.ifPresent(box -> panel.add(box, gbc));
if (trailinglabel.isEmpty())
{
gbc.gridwidth = GridBagConstraints.REMAINDER;
}
textField.ifPresent(field -> panel.add(field, gbc));
gbc.gridwidth = GridBagConstraints.REMAINDER;
if (trailinglabel.isPresent())
{
panel.add(trailinglabel.get(), gbc);
}
else if (numComponents < 2)
{
//We need a filler component so just use the lightweight Box
panel.add(Box.createHorizontalGlue(), gbc);
}
}
public void generalInit(Container c) {
c.setLayout(new BorderLayout());
main = new JPanel();
bkd = new ImageBackgroundPanel();
c.add(bkd, "Center");
//c.add(main, "Center");
//main.add(bckgd);
jbLoadImage = new JButton("Load Images");
jbLoadImage.addActionListener(this);
jbCropImage = new JButton("Crop Images");
jbCropImage.addActionListener(this);
jbCropImage.setEnabled(false);
jbTrain = new JButton("Compute Eigen Vectors");
jbTrain.setEnabled(false);
jbTrain.addActionListener(this);
jbProbe = new JButton("Identify Face");
jbProbe.addActionListener(this);
jbProbe.setEnabled(false);
jbDisplayFeatureSpace = new JButton("Display Result Chart");
jbDisplayFeatureSpace.addActionListener(this);
jbDisplayFeatureSpace.setEnabled(false);
//jlClassthreshold = new JLabel("Factor");
// jtfClassthreshold = new JTextField(""+classthreshold);
//jbClassthreshold = new JButton("Update Threshold");
// jbClassthreshold.addActionListener(this);
faceCandidate = new FaceItem();
faceCandidate.setBorder(BorderFactory.createRaisedBevelBorder());
jlAverageFace = new JLabel();
jlAverageFace.setVerticalTextPosition(JLabel.BOTTOM);
jlAverageFace.setHorizontalTextPosition(JLabel.CENTER);
jlStatus = new JProgressBar(JProgressBar.HORIZONTAL, 0, 100);
jlStatus.setBorder(BorderFactory.createEtchedBorder());
jlStatus.setStringPainted(true);
jlist = new JList();
main.setLayout(new BorderLayout());
JPanel right = new JPanel();
jbLoadImage.setFont(new Font("Verdana", 30, 18));
//jbCropImage.setFont(new Font("Cambria", 20, 28));
jbTrain.setFont(new Font("Verdana", 30, 18));
jbProbe.setFont(new Font("Verdana", 30, 18));
jbDisplayFeatureSpace.setFont(new Font("Verdana", 30, 18));
right.setLayout(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.anchor = GridBagConstraints.PAGE_START;
gbc.gridy = 1;
gbc.gridwidth = 4;
gbc.ipady = 30;
gbc.ipadx = 110;
gbc.insets = new Insets(10, 20, 10, 20);
//JLabel myp = new JLabel("Project ID: PW13A01");
//myp.setFont(new Font("Tahoma", 20, 20));
//right.add(myp);
//gbc.gridy = 3;
try {
String imPath = System.getProperty("user.dir");
imPath = imPath.replace('\\', '/');
BufferedImage myPicture = ImageIO.read(new File(imPath + "/src/src/face.png"));
JLabel picLabel = new JLabel(new ImageIcon(myPicture));
//picLabel.setSize(250, 220);
right.add(picLabel);
} catch (IOException ex) {
System.out.println("Image face.png missing\n" + ex);
}
right.add(jbLoadImage, gbc);
//gbc.gridy = 1; right.add(jbCropImage, gbc);
gbc.gridy = 4;
right.add(jbTrain, gbc);
gbc.gridy = 6;
right.add(jbProbe, gbc);
gbc.gridy = 8;
right.add(jbDisplayFeatureSpace, gbc);
//gbc.gridy = 5; gbc.gridwidth = 1; right.add(jlClassthreshold, gbc);
// gbc.gridy = 5; gbc.gridwidth = 1; right.add(jtfClassthreshold, gbc);
// gbc.gridy = 6; gbc.gridwidth = 2; right.add(jbClassthreshold, gbc);
/* gbc.gridy = 7;
gbc.weighty = 1.0;
gbc.fill = GridBagConstraints.VERTICAL | GridBagConstraints.HORIZONTAL;
right.add(jlAverageFace, gbc); */
c.add(right, BorderLayout.EAST);
//Mark
}
/**
* Instantiates a new map size dialog.
*
* @param mapWidth the initial value in the dialog for the width of the map
* @param mapHeight the initial value in the dialog for the height of the map
* @param regionWidth the initial value in the dialog for the width of a region
* @param regionHeight the initial value in the dialog for the height of a region
* @param barrier a barrier. You should wait on this barrier to get a clean thread synchronization!
*/
public MapSizeDialog(int mapWidth, int mapHeight, int regionWidth, int regionHeight, CyclicBarrier barrier){
super(VanetSimStart.getMainFrame(),Messages.getString("MapSize.title"), true); //$NON-NLS-1$
mapWidth_ = mapWidth;
mapHeight_ = mapHeight;
regionWidth_ = regionWidth;
regionHeight_ = regionHeight;
barrier_ = barrier;
setUndecorated(true);
setLayout(new GridBagLayout());
setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
setModal(true);
//some basic options
GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.BOTH;
c.anchor = GridBagConstraints.PAGE_START;
c.weightx = 0.5;
c.weighty = 0;
c.gridx = 0;
c.gridy = 0;
c.gridheight = 1;
c.insets = new Insets(5,5,5,5);
c.gridwidth = 2;
add(new JLabel(Messages.getString("MapSize.mapCreatedWith")), c); //$NON-NLS-1$
c.gridwidth = 1;
++c.gridy;
add(new JLabel(Messages.getString("MapSize.mapWidth")), c); //$NON-NLS-1$
c.gridx = 1;
widthTextField_.setValue(mapWidth);
add(widthTextField_, c);
c.gridx = 0;
++c.gridy;
add(new JLabel(Messages.getString("MapSize.mapHeight")), c); //$NON-NLS-1$
c.gridx = 1;
heightTextField_.setValue(mapHeight);
add(heightTextField_, c);
c.gridx = 0;
++c.gridy;
add(new JLabel(Messages.getString("MapSize.regionWidth")), c); //$NON-NLS-1$
c.gridx = 1;
regionWidthTextField_.setValue(regionWidth);
add(regionWidthTextField_, c);
c.gridx = 0;
++c.gridy;
add(new JLabel(Messages.getString("MapSize.regionHeight")), c); //$NON-NLS-1$
c.gridx = 1;
regionHeightTextField_.setValue(regionHeight);
add(regionHeightTextField_, c);
c.gridx = 0;
++c.gridy;
c.gridwidth = 2;
add(new JLabel("<html><b>" + Messages.getString("MapSize.notes") + "<ul><li>" + Messages.getString("MapSize.noteSmallerValue")+"</li><li>"+Messages.getString("MapSize.noteRegionPerformance")+"</li><li>"+Messages.getString("MapSize.noteRegionMemory")+"</li></ul>"), c); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$
++c.gridy;
c.fill = GridBagConstraints.NONE;
add(ButtonCreator.getJButton("ok.png", "OK", Messages.getString("MapSize.OK"), this), c); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
pack();
setLocationRelativeTo(VanetSimStart.getMainFrame());
setVisible(true);
}
/**
* Constructor, creating GUI items.
*/
public SlowPanel(){
setLayout(new GridBagLayout());
// global layout settings
GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.BOTH;
c.anchor = GridBagConstraints.PAGE_START;
c.weightx = 0.5;
c.gridx = 0;
c.gridy = 0;
c.gridheight = 1;
c.gridwidth = 2;
c.gridwidth = 1;
c.insets = new Insets(5,5,5,5);
c.gridx = 0;
timeToPseudonymChangeLabel_ = new JLabel(Messages.getString("SlowPanel.timeToPseudonymChange")); //$NON-NLS-1$
++c.gridy;
add(timeToPseudonymChangeLabel_,c);
timeToPseudonymChange_ = new JFormattedTextField(NumberFormat.getIntegerInstance());
timeToPseudonymChange_.setValue(3000);
timeToPseudonymChange_.setPreferredSize(new Dimension(60,20));
c.gridx = 1;
timeToPseudonymChange_.addFocusListener(this);
add(timeToPseudonymChange_,c);
c.gridx = 0;
slowSpeedLimitLabel_ = new JLabel(Messages.getString("SlowPanel.speedLimit")); //$NON-NLS-1$
++c.gridy;
add(slowSpeedLimitLabel_,c);
slowSpeedLimit_ = new JFormattedTextField(NumberFormat.getIntegerInstance());
slowSpeedLimit_.setValue(30);
slowSpeedLimit_.setPreferredSize(new Dimension(60,20));
c.gridx = 1;
slowSpeedLimit_.addFocusListener(this);
add(slowSpeedLimit_,c);
c.gridx = 0;
enableSlowLabel_ = new JLabel(Messages.getString("SlowPanel.enable")); //$NON-NLS-1$
++c.gridy;
add(enableSlowLabel_,c);
enableSlow_ = new JCheckBox();
enableSlow_.setSelected(false);
enableSlow_.setActionCommand("enableSlow"); //$NON-NLS-1$
c.gridx = 1;
enableSlow_.addFocusListener(this);
add(enableSlow_,c);
enableSlow_.addActionListener(this);
//to consume the rest of the space
c.weighty = 1.0;
++c.gridy;
JPanel space = new JPanel();
space.setOpaque(false);
add(space, c);
}
/**
* Constructor. Creating GUI items.
*/
public AboutDialog(){
//some JDialog options
setUndecorated(true);
setLayout(new GridBagLayout());
setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
//WindowAdapter to catch closing event
this.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent event) {
closeDialog();
}
}
);
setModal(true);
//some basic options
GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.BOTH;
c.anchor = GridBagConstraints.PAGE_START;
c.weightx = 0.5;
c.weighty = 0;
c.gridx = 0;
c.gridy = 0;
c.gridheight = 1;
c.gridwidth = 2;
c.insets = new Insets(5,5,5,5);
//start building gui
++c.gridy;
add(new JLabel(Messages.getString("AboutDialog.credits")), c); //$NON-NLS-1$
//to consume the rest of the space
c.weighty = 1.0;
++c.gridy;
JPanel space = new JPanel();
space.setOpaque(false);
add(space, c);
//resize window
pack();
//adjust window size
setLocationRelativeTo(VanetSimStart.getMainFrame());
//show window
setVisible(true);
}
/**
* Constructor, creating GUI items.
*/
public SilentPeriodPanel(){
setLayout(new GridBagLayout());
// global layout settings
GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.BOTH;
c.anchor = GridBagConstraints.PAGE_START;
c.weightx = 0.5;
c.gridx = 0;
c.gridy = 0;
c.gridheight = 1;
c.gridwidth = 2;
c.gridwidth = 1;
c.insets = new Insets(5,5,5,5);
c.gridx = 0;
silentPeriodDurationLabel_ = new JLabel(Messages.getString("SilentPeriodPanel.duration")); //$NON-NLS-1$
++c.gridy;
add(silentPeriodDurationLabel_,c);
silentPeriodDuration_ = new JFormattedTextField(NumberFormat.getIntegerInstance());
silentPeriodDuration_.setValue(3000);
silentPeriodDuration_.setPreferredSize(new Dimension(60,20));
c.gridx = 1;
silentPeriodDuration_.addFocusListener(this);
add(silentPeriodDuration_,c);
c.gridx = 0;
silentPeriodFrequencyLabel_ = new JLabel(Messages.getString("SilentPeriodPanel.frequency")); //$NON-NLS-1$
++c.gridy;
add(silentPeriodFrequencyLabel_,c);
silentPeriodFrequency_ = new JFormattedTextField(NumberFormat.getIntegerInstance());
silentPeriodFrequency_.setValue(10000);
silentPeriodFrequency_.setPreferredSize(new Dimension(60,20));
c.gridx = 1;
silentPeriodFrequency_.addFocusListener(this);
add(silentPeriodFrequency_,c);
c.gridx = 0;
enableSilentPeriodsLabel_ = new JLabel(Messages.getString("SilentPeriodPanel.enable")); //$NON-NLS-1$
++c.gridy;
add(enableSilentPeriodsLabel_,c);
enableSilentPeriods_ = new JCheckBox();
enableSilentPeriods_.setSelected(false);
enableSilentPeriods_.setActionCommand("enableSilentPeriods"); //$NON-NLS-1$
c.gridx = 1;
enableSilentPeriods_.addFocusListener(this);
add(enableSilentPeriods_,c);
enableSilentPeriods_.addActionListener(this);
//to consume the rest of the space
c.weighty = 1.0;
++c.gridy;
JPanel space = new JPanel();
space.setOpaque(false);
add(space, c);
}
/**
* Constructor.
*/
public EditStreetControlPanel(){
setLayout(new GridBagLayout());
// global layout settings
GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.BOTH;
c.anchor = GridBagConstraints.PAGE_START;
c.weightx = 0.5;
c.gridx = 0;
c.gridy = 0;
c.gridheight = 1;
c.gridwidth = 2;
// Radio buttons to select what to do
ButtonGroup group = new ButtonGroup();
JRadioButton addItem = new JRadioButton(Messages.getString("EditStreetControlPanel.add")); //$NON-NLS-1$
addItem.setActionCommand("add"); //$NON-NLS-1$
addItem.addActionListener(this);
addItem.setSelected(true);
group.add(addItem);
++c.gridy;
add(addItem,c);
JRadioButton editItem = new JRadioButton(Messages.getString("EditStreetControlPanel.edit")); //$NON-NLS-1$
editItem.setActionCommand("edit"); //$NON-NLS-1$
editItem.addActionListener(this);
group.add(editItem);
++c.gridy;
add(editItem,c);
JRadioButton deleteItem = new JRadioButton(Messages.getString("EditStreetControlPanel.delete")); //$NON-NLS-1$
deleteItem.setActionCommand("delete"); //$NON-NLS-1$
deleteItem.setSelected(true);
deleteItem.addActionListener(this);
group.add(deleteItem);
++c.gridy;
add(deleteItem,c);
c.gridwidth = 1;
c.insets = new Insets(5,5,5,5);
// all controls for creating a new street
JPanel newPanel = createNewPanel();
JPanel editPanel = createEditPanel();
JPanel deletePanel = createDeletePanel();
cardPanel_ = new JPanel(new CardLayout());
cardPanel_.add(newPanel, "add"); //$NON-NLS-1$
cardPanel_.add(editPanel, "edit"); //$NON-NLS-1$
cardPanel_.add(deletePanel, "delete"); //$NON-NLS-1$
++c.gridy;
add(cardPanel_,c);
TextAreaLabel jlabel1 = new TextAreaLabel(Messages.getString("EditStreetControlPanel.note")); //$NON-NLS-1$
++c.gridy;
add(jlabel1, c);
//to consume the rest of the space
c.gridwidth = 2;
c.weighty = 1.0;
++c.gridy;
JPanel space = new JPanel();
space.setOpaque(false);
add(space, c);
}
/**
* Constructor, creating GUI items.
*/
public EditTrafficModelControlPanel() {
setLayout(new GridBagLayout());
// global layout settings
GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.BOTH;
c.anchor = GridBagConstraints.PAGE_START;
c.weightx = 0.5;
c.gridx = 0;
c.gridy = 0;
c.gridheight = 1;
c.gridwidth = 1;
c.insets = new Insets(5,5,5,5);
c.gridx = 0;
// Radio buttons to select add, edit or delete mode
ButtonGroup group = new ButtonGroup();
selectModel_ = new JRadioButton(Messages.getString("EditTrafficControlPanel.model")); //$NON-NLS-1$
selectModel_.setActionCommand("model"); //$NON-NLS-1$
selectModel_.addActionListener(this);
selectModel_.setSelected(true);
group.add(selectModel_);
++c.gridy;
add(selectModel_,c);
selectTraces_ = new JRadioButton(Messages.getString("EditTrafficControlPanel.traces")); //$NON-NLS-1$
selectTraces_.setActionCommand("traces"); //$NON-NLS-1$
selectTraces_.addActionListener(this);
group.add(selectTraces_);
++c.gridy;
add(selectTraces_,c);
c.gridx = 0;
chooseTrafficModelLabel_ = new JLabel(Messages.getString("EditTrafficControlPanel.comboBoxModel")); //$NON-NLS-1$
++c.gridy;
add(chooseTrafficModelLabel_,c);
chooseTrafficModel_ = new JComboBox<String>();
chooseTrafficModel_.setActionCommand("chooseTrafficModel");
chooseTrafficModel_.addItem("VANETSim classic");
chooseTrafficModel_.addItem("IDM/MOBIL");
chooseTrafficModel_.addActionListener(this);
c.gridx = 1;
add(chooseTrafficModel_, c);
c.gridx = 0;
chooseTracesLabel_ = new JLabel(Messages.getString("EditTrafficControlPanel.comboBoxTraces")); //$NON-NLS-1$
++c.gridy;
add(chooseTracesLabel_,c);
chooseTraces_ = new JComboBox<String>();
chooseTraces_.setActionCommand("chooseTraces");
chooseTraces_.addItem("sjtu taxi traces");
chooseTraces_.addItem("San Francisco traces");
chooseTraces_.addActionListener(this);
c.gridx = 1;
add(chooseTraces_, c);
chooseTraces_.setVisible(false);
chooseTracesLabel_.setVisible(false);
//to consume the rest of the space
c.weighty = 1.0;
++c.gridy;
JPanel space = new JPanel();
space.setOpaque(false);
add(space, c);
}
/**
* Constructor. Creating GUI items.
*/
public RSUPanel(){
setLayout(new GridBagLayout());
// global layout settings
GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.BOTH;
c.anchor = GridBagConstraints.PAGE_START;
c.weightx = 0.5;
c.gridx = 0;
c.gridy = 0;
c.gridheight = 1;
c.gridwidth = 2;
// Radio buttons to select mode
ButtonGroup group = new ButtonGroup();
addRSU_ = new JRadioButton(Messages.getString("RSUPanel.addRSU")); //$NON-NLS-1$
addRSU_.setActionCommand("addRSU"); //$NON-NLS-1$;
addRSU_.setSelected(true);
group.add(addRSU_);
++c.gridy;
add(addRSU_,c);
addRSU_.addActionListener(this);
deleteRSU_ = new JRadioButton(Messages.getString("RSUPanel.deleteRSU")); //$NON-NLS-1$
deleteRSU_.setActionCommand("deleteRSU"); //$NON-NLS-1$
group.add(deleteRSU_);
++c.gridy;
add(deleteRSU_,c);
deleteRSU_.addActionListener(this);
c.gridwidth = 1;
c.insets = new Insets(5,5,5,5);
//textfields
c.gridx = 0;
rsuLabel_ = new JLabel(Messages.getString("RSUPanel.radius")); //$NON-NLS-1$
++c.gridy;
add(rsuLabel_,c);
rsuRadius_ = new JFormattedTextField(NumberFormat.getIntegerInstance());
rsuRadius_.setValue(500);
rsuRadius_.setPreferredSize(new Dimension(60,20));
c.gridx = 1;
add(rsuRadius_,c);
c.gridx = 0;
c.gridwidth = 2;
++c.gridy;
add(ButtonCreator.getJButton("deleteAll.png", "clearRSUs", Messages.getString("RSUPanel.btnClearRSUs"), this),c);
deleteNote_ = new TextAreaLabel(Messages.getString("RSUPanel.noteDelete")); //$NON-NLS-1$
++c.gridy;
c.gridx = 0;
add(deleteNote_, c);
deleteNote_.setVisible(false);
addNote_ = new TextAreaLabel(Messages.getString("RSUPanel.noteAdd")); //$NON-NLS-1$
++c.gridy;
c.gridx = 0;
add(addNote_, c);
addNote_.setVisible(true);
//to consume the rest of the space
c.weighty = 1.0;
++c.gridy;
JPanel space = new JPanel();
space.setOpaque(false);
add(space, c);
}
/**
* Creates the panel which is shown when communication is enabled.
*
* @return the communication panel
*/
private final JPanel createCommunicationPanel(){
JPanel panel = new JPanel();
panel.setOpaque(false);
panel.setLayout(new GridBagLayout());
GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.BOTH;
c.anchor = GridBagConstraints.PAGE_START;
c.weightx = 1;
c.gridx = 0;
c.gridy = 0;
c.gridheight = 1;
c.insets = new Insets(5,0,5,0);
JLabel jLabel1 = new JLabel(Messages.getString("EditSettingsControlPanel.communicationInterval")); //$NON-NLS-1$
panel.add(jLabel1,c);
communicationInterval_ = new JFormattedTextField(NumberFormat.getIntegerInstance());
communicationInterval_.setPreferredSize(new Dimension(60,20));
communicationInterval_.setValue(160);
communicationInterval_.addPropertyChangeListener("value", this); //$NON-NLS-1$
c.gridx = 1;
c.weightx = 0;
panel.add(communicationInterval_,c);
c.gridx = 0;
c.gridwidth = 2;
++c.gridy;
beaconsCheckBox_ = new JCheckBox(Messages.getString("EditSettingsControlPanel.enableBeacons"), true); //$NON-NLS-1$
beaconsCheckBox_.addItemListener(this);
panel.add(beaconsCheckBox_,c);
++c.gridy;
c.insets = new Insets(0,10,0,0);
beaconPanel_ = createBeaconPanel();
panel.add(beaconPanel_,c);
++c.gridy;
c.insets = new Insets(5,0,5,0);
mixZonesCheckBox_ = new JCheckBox(Messages.getString("EditSettingsControlPanel.enableMixZones"), true); //$NON-NLS-1$
mixZonesCheckBox_.addItemListener(this);
panel.add(mixZonesCheckBox_,c);
++c.gridy;
c.insets = new Insets(0,10,0,0);
mixZonePanel_ = createMixPanel();
panel.add(mixZonePanel_,c);
TextAreaLabel jlabel1 = new TextAreaLabel(Messages.getString("EditSettingsControlPanel.intervalNote1") + SimulationMaster.TIME_PER_STEP + Messages.getString("EditSettingsControlPanel.intervalNote2")); //$NON-NLS-1$ //$NON-NLS-2$
++c.gridy;
c.gridx = 0;
c.gridwidth = 2;
c.insets = new Insets(15,0,5,0);
panel.add(jlabel1, c);
return panel;
}