List of usage examples for javax.swing JCheckBox JCheckBox
public JCheckBox(Action a)
From source file:edu.snu.leader.discrete.simulator.SimulatorLauncherGUI.java
/** * Create the frame./*from w w w. j a v a 2 s . com*/ */ public SimulatorLauncherGUI() { NumberFormat countFormat = NumberFormat.getNumberInstance(); countFormat.setParseIntegerOnly(true); NumberFormat doubleFormat = NumberFormat.getNumberInstance(); doubleFormat.setMinimumIntegerDigits(1); doubleFormat.setMaximumFractionDigits(10); setTitle("Simulator"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setBounds(100, 100, 515, 340); setResizable(false); contentPane = new JPanel(); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); contentPane.setLayout(new BorderLayout(0, 0)); setContentPane(contentPane); tabbedPane = new JTabbedPane(JTabbedPane.TOP); contentPane.add(tabbedPane, BorderLayout.CENTER); JPanel panelTab1 = new JPanel(); tabbedPane.addTab("Simulator", null, panelTab1, null); JPanel panelAgentCount = new JPanel(); panelTab1.add(panelAgentCount); JLabel lblNewLabel = new JLabel("Agent Count"); panelAgentCount.add(lblNewLabel); sliderAgent = new JSlider(); panelAgentCount.add(sliderAgent); sliderAgent.setValue(10); sliderAgent.setSnapToTicks(true); sliderAgent.setPaintTicks(true); sliderAgent.setPaintLabels(true); sliderAgent.setMinorTickSpacing(10); sliderAgent.setMajorTickSpacing(10); sliderAgent.setMinimum(10); sliderAgent.setMaximum(70); sliderAgent.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent arg0) { Integer spinnerValue = (Integer) spinnerMaxEaten.getValue(); if (spinnerValue > sliderAgent.getValue()) { spinnerValue = sliderAgent.getValue(); } spinnerMaxEaten.setModel(new SpinnerNumberModel(spinnerValue, new Integer(0), new Integer(sliderAgent.getValue()), new Integer(1))); JFormattedTextField tfMaxEaten = ((JSpinner.DefaultEditor) spinnerMaxEaten.getEditor()) .getTextField(); tfMaxEaten.setEditable(false); } }); JPanel panelCommType = new JPanel(); panelTab1.add(panelCommType); JLabel lblNewLabel_1 = new JLabel("Communication Type"); panelCommType.add(lblNewLabel_1); comboBoxCommType = new JComboBox<String>(); panelCommType.add(comboBoxCommType); comboBoxCommType .setModel(new DefaultComboBoxModel<String>(new String[] { "Global", "Topological", "Metric" })); comboBoxCommType.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { String item = (String) comboBoxCommType.getSelectedItem(); if (item.equals("Topological")) { panelNearestNeighborCount.setVisible(true); panelMaxLocationRadius.setVisible(false); } else if (item.equals("Metric")) { panelNearestNeighborCount.setVisible(false); panelMaxLocationRadius.setVisible(true); } else if (item.equals("Global")) { panelNearestNeighborCount.setVisible(false); panelMaxLocationRadius.setVisible(false); } } }); JPanel panelDestinationRadius = new JPanel(); panelTab1.add(panelDestinationRadius); JLabel lblDestinationRadius = new JLabel("Destination Radius"); panelDestinationRadius.add(lblDestinationRadius); frmtdtxtfldDestinationRadius = new JFormattedTextField(doubleFormat); frmtdtxtfldDestinationRadius.setColumns(4); frmtdtxtfldDestinationRadius.setValue((Number) 10); panelDestinationRadius.add(frmtdtxtfldDestinationRadius); JPanel panelResultsOutput = new JPanel(); panelTab1.add(panelResultsOutput); JLabel lblResultsOutput = new JLabel("Results Output"); panelResultsOutput.add(lblResultsOutput); final JCheckBox chckbxEskridge = new JCheckBox("Eskridge"); panelResultsOutput.add(chckbxEskridge); final JCheckBox chckbxConflict = new JCheckBox("Conflict"); panelResultsOutput.add(chckbxConflict); final JCheckBox chckbxPosition = new JCheckBox("Position"); panelResultsOutput.add(chckbxPosition); final JCheckBox chckbxPredationResults = new JCheckBox("Predation"); panelResultsOutput.add(chckbxPredationResults); JPanel panelMisc = new JPanel(); panelTab1.add(panelMisc); JLabel lblNewLabel_3 = new JLabel("Misc"); panelMisc.add(lblNewLabel_3); chckbxGraphical = new JCheckBox("Graphical?"); chckbxGraphical.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { if (chckbxGraphical.isSelected()) { frmtdtxtfldRunCount.setValue((Number) 1); frmtdtxtfldRunCount.setEnabled(false); chckbxEskridge.setSelected(false); chckbxEskridge.setEnabled(false); String agentBuilder = (String) comboBoxAgentBuilder.getSelectedItem(); if (agentBuilder.equals("Default")) { comboBoxAgentBuilder.setSelectedIndex(1); } } else { chckbxEskridge.setEnabled(true); frmtdtxtfldRunCount.setEnabled(true); } } }); panelMisc.add(chckbxGraphical); chckbxRandomSeed = new JCheckBox("Random Seed?"); panelMisc.add(chckbxRandomSeed); chckbxPredationEnable = new JCheckBox("Predation?"); chckbxPredationEnable.setSelected(true); chckbxPredationEnable.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { if (chckbxPredationEnable.isSelected()) { panelPredationStuff.setVisible(true); panelPredationBoxes.setVisible(true); panelPredationConstant.setVisible(true); panelNonMoversSurvive.setVisible(true); } else { panelPredationStuff.setVisible(false); panelPredationBoxes.setVisible(false); panelPredationConstant.setVisible(false); panelNonMoversSurvive.setVisible(false); } } }); panelMisc.add(chckbxPredationEnable); JPanel panelCounts = new JPanel(); panelTab1.add(panelCounts); JLabel lblNewLabel_4 = new JLabel("Run Count"); panelCounts.add(lblNewLabel_4); frmtdtxtfldRunCount = new JFormattedTextField(countFormat); frmtdtxtfldRunCount.setToolTipText("The number of runs. Each run has a different random seed."); panelCounts.add(frmtdtxtfldRunCount); frmtdtxtfldRunCount.setColumns(4); frmtdtxtfldRunCount.setValue((Number) 1); JLabel lblNewLabel_5 = new JLabel("Sim Count"); panelCounts.add(lblNewLabel_5); frmtdtxtfldSimCount = new JFormattedTextField(countFormat); frmtdtxtfldSimCount .setToolTipText("The number of simulations per run. Each simulation uses the same random seed."); frmtdtxtfldSimCount.setColumns(4); frmtdtxtfldSimCount.setValue((Number) 1); panelCounts.add(frmtdtxtfldSimCount); JLabel lblNewLabel_6 = new JLabel("Max Time Steps"); panelCounts.add(lblNewLabel_6); frmtdtxtfldMaxTimeSteps = new JFormattedTextField(countFormat); frmtdtxtfldMaxTimeSteps.setToolTipText("The max number of time steps per simulation."); frmtdtxtfldMaxTimeSteps.setColumns(6); frmtdtxtfldMaxTimeSteps.setValue((Number) 20000); panelCounts.add(frmtdtxtfldMaxTimeSteps); ////////Panel tab 2 JPanel panelTab2 = new JPanel(); tabbedPane.addTab("Parameters", null, panelTab2, null); JPanel panelDecisionCalculator = new JPanel(); panelTab2.add(panelDecisionCalculator); JLabel lblDecisionCalculator = new JLabel("Decision Calculator"); panelDecisionCalculator.add(lblDecisionCalculator); final JComboBox<String> comboBoxDecisionCalculator = new JComboBox<String>(); panelDecisionCalculator.add(comboBoxDecisionCalculator); comboBoxDecisionCalculator.setModel( new DefaultComboBoxModel<String>(new String[] { "Default", "Conflict", "Conflict Uninformed" })); JPanel panelAgentBuilder = new JPanel(); panelTab2.add(panelAgentBuilder); JLabel lblAgentBuilder = new JLabel("Agent Builder"); panelAgentBuilder.add(lblAgentBuilder); comboBoxAgentBuilder = new JComboBox<String>(); panelAgentBuilder.add(comboBoxAgentBuilder); comboBoxAgentBuilder.setModel(new DefaultComboBoxModel<String>(new String[] { "Default", "Simple Angular", "Personality Simple Angular", "Simple Angular Uninformed" })); comboBoxAgentBuilder.setSelectedIndex(1); comboBoxAgentBuilder.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { if (chckbxGraphical.isSelected()) { String agentBuilder = (String) comboBoxAgentBuilder.getSelectedItem(); if (agentBuilder.equals("Default")) { comboBoxAgentBuilder.setSelectedIndex(1); } } } }); JPanel panelModel = new JPanel(); panelTab2.add(panelModel); JLabel lblModel = new JLabel("Model"); panelModel.add(lblModel); comboBoxModel = new JComboBox<String>(); panelModel.add(comboBoxModel); comboBoxModel.setModel(new DefaultComboBoxModel<String>(new String[] { "Sueur", "Gautrais" })); comboBoxModel.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { String item = (String) comboBoxModel.getSelectedItem(); if (item.equals("Sueur")) { panelSueurValues.setVisible(true); panelGautraisValues.setVisible(false); } else if (item.equals("Gautrais")) { panelSueurValues.setVisible(false); panelGautraisValues.setVisible(true); } } }); JPanel panelEnvironment = new JPanel(); panelTab2.add(panelEnvironment); JLabel lblEnvironment = new JLabel("Environment"); panelEnvironment.add(lblEnvironment); comboBoxEnvironment = new JComboBox<String>(); comboBoxEnvironment.setModel( new DefaultComboBoxModel<String>(new String[] { "Minimum", "Medium", "Maximum", "Uninformed" })); comboBoxEnvironment.setSelectedIndex(1); comboBoxEnvironment.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { String item = (String) comboBoxEnvironment.getSelectedItem(); if (!item.equals("Uninformed")) { comboBoxDecisionCalculator.setEnabled(true); comboBoxAgentBuilder.setEnabled(true); } if (item.equals("Medium")) { panelAngle.setVisible(true); panelDistance.setVisible(true); panelPercentage.setVisible(true); panelNumberOfDestinations.setVisible(false); panelInformedCount.setVisible(false); } else if (item.equals("Minimum")) { panelAngle.setVisible(false); panelDistance.setVisible(false); panelPercentage.setVisible(true); panelNumberOfDestinations.setVisible(false); panelInformedCount.setVisible(false); } else if (item.equals("Maximum")) { panelAngle.setVisible(false); panelDistance.setVisible(false); panelPercentage.setVisible(true); panelNumberOfDestinations.setVisible(false); panelInformedCount.setVisible(false); } else if (item.equals("Uninformed")) { panelAngle.setVisible(true); panelDistance.setVisible(true); panelPercentage.setVisible(true); panelNumberOfDestinations.setVisible(false); panelInformedCount.setVisible(true); comboBoxDecisionCalculator.setSelectedIndex(2); comboBoxDecisionCalculator.setEnabled(false); comboBoxAgentBuilder.setSelectedIndex(3); comboBoxAgentBuilder.setEnabled(false); } } }); panelEnvironment.add(comboBoxEnvironment); JPanel panelDefaultConflict = new JPanel(); panelTab2.add(panelDefaultConflict); JLabel lblDefaultConflict = new JLabel("Default Conflict"); panelDefaultConflict.add(lblDefaultConflict); final JSpinner spinnerDefaultConflict = new JSpinner(); panelDefaultConflict.add(spinnerDefaultConflict); spinnerDefaultConflict.setModel( new SpinnerNumberModel(new Float(0.9f), new Float(0.1f), new Float(0.91f), new Float(0.05))); JFormattedTextField tfSpinnerConflict = ((JSpinner.DefaultEditor) spinnerDefaultConflict.getEditor()) .getTextField(); tfSpinnerConflict.setEditable(false); JPanel panelCancelationThreshold = new JPanel(); panelTab2.add(panelCancelationThreshold); JLabel lblCancelationThreshold = new JLabel("Cancelation Threshold"); panelCancelationThreshold.add(lblCancelationThreshold); final JSpinner spinnerCancelationThreshold = new JSpinner(); panelCancelationThreshold.add(spinnerCancelationThreshold); spinnerCancelationThreshold.setModel( new SpinnerNumberModel(new Float(1.0f), new Float(0.0f), new Float(1.01f), new Float(0.05))); JFormattedTextField tfCancelationThreshold = ((JSpinner.DefaultEditor) spinnerCancelationThreshold .getEditor()).getTextField(); tfCancelationThreshold.setEditable(false); JPanel panelStopAnywhere = new JPanel(); panelTab2.add(panelStopAnywhere); final JCheckBox chckbxStopAnywhere = new JCheckBox("Stop Anywhere?"); panelStopAnywhere.add(chckbxStopAnywhere); panelNearestNeighborCount = new JPanel(); panelNearestNeighborCount.setVisible(false); panelTab2.add(panelNearestNeighborCount); JLabel lblNearestNeighborCount = new JLabel("Nearest Neighbor Count"); panelNearestNeighborCount.add(lblNearestNeighborCount); frmtdtxtfldNearestNeighborCount = new JFormattedTextField(countFormat); panelNearestNeighborCount.add(frmtdtxtfldNearestNeighborCount); frmtdtxtfldNearestNeighborCount.setColumns(3); frmtdtxtfldNearestNeighborCount.setValue((Number) 10); panelMaxLocationRadius = new JPanel(); panelMaxLocationRadius.setVisible(false); panelTab2.add(panelMaxLocationRadius); JLabel lblMaxLocationRadius = new JLabel("Max Location Radius"); panelMaxLocationRadius.add(lblMaxLocationRadius); frmtdtxtfldMaxLocationRadius = new JFormattedTextField(doubleFormat); panelMaxLocationRadius.add(frmtdtxtfldMaxLocationRadius); frmtdtxtfldMaxLocationRadius.setColumns(5); frmtdtxtfldMaxLocationRadius.setValue((Number) 10.0); panelPredationBoxes = new JPanel(); panelTab2.add(panelPredationBoxes); final JCheckBox chckbxUsePredationThreshold = new JCheckBox("Use Predation Threshold"); panelPredationBoxes.add(chckbxUsePredationThreshold); final JCheckBox chckbxPopulationIndependent = new JCheckBox("Population Independent"); chckbxPopulationIndependent.setSelected(true); panelPredationBoxes.add(chckbxPopulationIndependent); chckbxPopulationIndependent.setToolTipText( "Select this to allow predation to be independent of population size. Max predation for 10 agents will be the same as for 50 agents. "); panelPredationStuff = new JPanel(); panelTab2.add(panelPredationStuff); JLabel lblPredationMinimum = new JLabel("Predation Minimum"); panelPredationStuff.add(lblPredationMinimum); frmtdtxtfldPredationMinimum = new JFormattedTextField(doubleFormat); frmtdtxtfldPredationMinimum.setColumns(4); frmtdtxtfldPredationMinimum.setValue((Number) 0.0); panelPredationStuff.add(frmtdtxtfldPredationMinimum); JLabel lblPredationThreshold = new JLabel("Predation Threshold"); panelPredationStuff.add(lblPredationThreshold); final JSpinner spinnerPredationThreshold = new JSpinner(); panelPredationStuff.add(spinnerPredationThreshold); spinnerPredationThreshold.setModel( new SpinnerNumberModel(new Float(1.0f), new Float(0.0f), new Float(1.01f), new Float(0.05))); JFormattedTextField tfPredationThreshold = ((JSpinner.DefaultEditor) spinnerPredationThreshold.getEditor()) .getTextField(); tfPredationThreshold.setEditable(false); JLabel lblMaxEaten = new JLabel("Max Eaten"); panelPredationStuff.add(lblMaxEaten); spinnerMaxEaten = new JSpinner(); spinnerMaxEaten.setToolTipText("The max number eaten per time step."); panelPredationStuff.add(spinnerMaxEaten); spinnerMaxEaten.setModel(new SpinnerNumberModel(new Integer(10), new Integer(0), new Integer(sliderAgent.getValue()), new Integer(1))); JFormattedTextField tfMaxEaten = ((JSpinner.DefaultEditor) spinnerMaxEaten.getEditor()).getTextField(); tfMaxEaten.setEditable(false); panelPredationConstant = new JPanel(); panelTab2.add(panelPredationConstant); JLabel lblPredationConstant = new JLabel("Predation Constant"); panelPredationConstant.add(lblPredationConstant); frmtdtxtfldPredationConstant = new JFormattedTextField(doubleFormat); panelPredationConstant.add(frmtdtxtfldPredationConstant); frmtdtxtfldPredationConstant.setToolTipText("Value should be positive. Recommended values are near 0.001"); frmtdtxtfldPredationConstant.setColumns(4); frmtdtxtfldPredationConstant.setValue((Number) 0.001); panelNonMoversSurvive = new JPanel(); panelTab2.add(panelNonMoversSurvive); final JCheckBox chckbxNonMoversSurvive = new JCheckBox("Non-movers Survive?"); chckbxNonMoversSurvive.setSelected(false); panelNonMoversSurvive.add(chckbxNonMoversSurvive); ////////Tab 3 JPanel panelTab3 = new JPanel(); tabbedPane.addTab("Environment", null, panelTab3, null); panelTab3.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5)); panelSueurValues = new JPanel(); panelTab3.add(panelSueurValues); panelSueurValues.setLayout(new BoxLayout(panelSueurValues, BoxLayout.Y_AXIS)); JLabel lblSueurValues = new JLabel("Sueur Values"); lblSueurValues.setHorizontalAlignment(SwingConstants.TRAILING); lblSueurValues.setAlignmentX(Component.CENTER_ALIGNMENT); panelSueurValues.add(lblSueurValues); JPanel panelAlpha = new JPanel(); FlowLayout flowLayout = (FlowLayout) panelAlpha.getLayout(); flowLayout.setAlignment(FlowLayout.RIGHT); panelSueurValues.add(panelAlpha); JLabel lblAlpha = new JLabel("alpha"); lblAlpha.setHorizontalAlignment(SwingConstants.CENTER); panelAlpha.add(lblAlpha); final JFormattedTextField frmtdtxtfldAlpha = new JFormattedTextField(doubleFormat); frmtdtxtfldAlpha.setHorizontalAlignment(SwingConstants.TRAILING); lblAlpha.setLabelFor(frmtdtxtfldAlpha); panelAlpha.add(frmtdtxtfldAlpha); frmtdtxtfldAlpha.setColumns(6); frmtdtxtfldAlpha.setValue((Number) 0.006161429); JPanel panelAlphaC = new JPanel(); FlowLayout flowLayout_2 = (FlowLayout) panelAlphaC.getLayout(); flowLayout_2.setAlignment(FlowLayout.RIGHT); panelSueurValues.add(panelAlphaC); JLabel lblAlphaC = new JLabel("alpha c"); panelAlphaC.add(lblAlphaC); final JFormattedTextField frmtdtxtfldAlphaC = new JFormattedTextField(doubleFormat); frmtdtxtfldAlphaC.setHorizontalAlignment(SwingConstants.TRAILING); lblAlphaC.setLabelFor(frmtdtxtfldAlphaC); panelAlphaC.add(frmtdtxtfldAlphaC); frmtdtxtfldAlphaC.setColumns(6); frmtdtxtfldAlphaC.setValue((Number) 0.009); JPanel panelBeta = new JPanel(); FlowLayout flowLayout_1 = (FlowLayout) panelBeta.getLayout(); flowLayout_1.setAlignment(FlowLayout.RIGHT); panelSueurValues.add(panelBeta); JLabel lblBeta = new JLabel("beta"); panelBeta.add(lblBeta); final JFormattedTextField frmtdtxtfldBeta = new JFormattedTextField(doubleFormat); frmtdtxtfldBeta.setHorizontalAlignment(SwingConstants.TRAILING); panelBeta.add(frmtdtxtfldBeta); frmtdtxtfldBeta.setColumns(6); frmtdtxtfldBeta.setValue((Number) 0.013422819); JPanel panelBetaC = new JPanel(); FlowLayout flowLayout_14 = (FlowLayout) panelBetaC.getLayout(); flowLayout_14.setAlignment(FlowLayout.RIGHT); panelSueurValues.add(panelBetaC); JLabel lblBetaC = new JLabel("beta c"); panelBetaC.add(lblBetaC); final JFormattedTextField frmtdtxtfldBetaC = new JFormattedTextField(doubleFormat); frmtdtxtfldBetaC.setHorizontalAlignment(SwingConstants.TRAILING); panelBetaC.add(frmtdtxtfldBetaC); frmtdtxtfldBetaC.setColumns(6); frmtdtxtfldBetaC.setValue((Number) (-0.009)); JPanel panelS = new JPanel(); FlowLayout flowLayout_3 = (FlowLayout) panelS.getLayout(); flowLayout_3.setAlignment(FlowLayout.RIGHT); panelSueurValues.add(panelS); JLabel lblS = new JLabel("S"); panelS.add(lblS); final JFormattedTextField frmtdtxtfldS = new JFormattedTextField(countFormat); frmtdtxtfldS.setHorizontalAlignment(SwingConstants.TRAILING); panelS.add(frmtdtxtfldS); frmtdtxtfldS.setColumns(6); frmtdtxtfldS.setValue((Number) 2); JPanel panelQ = new JPanel(); FlowLayout flowLayout_4 = (FlowLayout) panelQ.getLayout(); flowLayout_4.setAlignment(FlowLayout.RIGHT); panelSueurValues.add(panelQ); JLabel lblQ = new JLabel("q"); panelQ.add(lblQ); final JFormattedTextField frmtdtxtfldQ = new JFormattedTextField(doubleFormat); frmtdtxtfldQ.setHorizontalAlignment(SwingConstants.TRAILING); panelQ.add(frmtdtxtfldQ); frmtdtxtfldQ.setColumns(6); frmtdtxtfldQ.setValue((Number) 2.3); panelGautraisValues = new JPanel(); panelGautraisValues.setVisible(false); panelTab3.add(panelGautraisValues); panelGautraisValues.setLayout(new BoxLayout(panelGautraisValues, BoxLayout.Y_AXIS)); JLabel label = new JLabel("Gautrais Values"); label.setAlignmentX(Component.CENTER_ALIGNMENT); panelGautraisValues.add(label); JPanel panelTauO = new JPanel(); FlowLayout flowLayout_5 = (FlowLayout) panelTauO.getLayout(); flowLayout_5.setAlignment(FlowLayout.RIGHT); panelGautraisValues.add(panelTauO); JLabel lblTauO = new JLabel("tau o"); panelTauO.add(lblTauO); final JFormattedTextField frmtdtxtfldTaoO = new JFormattedTextField(doubleFormat); frmtdtxtfldTaoO.setHorizontalAlignment(SwingConstants.TRAILING); panelTauO.add(frmtdtxtfldTaoO); frmtdtxtfldTaoO.setColumns(4); frmtdtxtfldTaoO.setValue((Number) 1290); JPanel panelGammaC = new JPanel(); FlowLayout flowLayout_6 = (FlowLayout) panelGammaC.getLayout(); flowLayout_6.setAlignment(FlowLayout.RIGHT); panelGautraisValues.add(panelGammaC); JLabel lblGammaC = new JLabel("gamma c"); panelGammaC.add(lblGammaC); final JFormattedTextField frmtdtxtfldGammaC = new JFormattedTextField(doubleFormat); frmtdtxtfldGammaC.setHorizontalAlignment(SwingConstants.TRAILING); panelGammaC.add(frmtdtxtfldGammaC); frmtdtxtfldGammaC.setColumns(4); frmtdtxtfldGammaC.setValue((Number) 2.0); JPanel panelEpsilonC = new JPanel(); FlowLayout flowLayout_7 = (FlowLayout) panelEpsilonC.getLayout(); flowLayout_7.setAlignment(FlowLayout.RIGHT); panelGautraisValues.add(panelEpsilonC); JLabel lblEpsilonC = new JLabel("epsilon c"); panelEpsilonC.add(lblEpsilonC); final JFormattedTextField frmtdtxtfldEpsilonC = new JFormattedTextField(doubleFormat); frmtdtxtfldEpsilonC.setHorizontalAlignment(SwingConstants.TRAILING); panelEpsilonC.add(frmtdtxtfldEpsilonC); frmtdtxtfldEpsilonC.setColumns(4); frmtdtxtfldEpsilonC.setValue((Number) 2.3); JPanel panelAlphaF = new JPanel(); FlowLayout flowLayout_8 = (FlowLayout) panelAlphaF.getLayout(); flowLayout_8.setAlignment(FlowLayout.RIGHT); panelGautraisValues.add(panelAlphaF); JLabel lblAlphaF = new JLabel("alpha f"); panelAlphaF.add(lblAlphaF); final JFormattedTextField frmtdtxtfldAlphaF = new JFormattedTextField(doubleFormat); frmtdtxtfldAlphaF.setHorizontalAlignment(SwingConstants.TRAILING); panelAlphaF.add(frmtdtxtfldAlphaF); frmtdtxtfldAlphaF.setColumns(4); frmtdtxtfldAlphaF.setValue((Number) 162.3); JPanel panelBetaF = new JPanel(); FlowLayout flowLayout_9 = (FlowLayout) panelBetaF.getLayout(); flowLayout_9.setAlignment(FlowLayout.RIGHT); panelGautraisValues.add(panelBetaF); JLabel lblBetaF = new JLabel("beta f"); panelBetaF.add(lblBetaF); final JFormattedTextField frmtdtxtfldBetaF = new JFormattedTextField(doubleFormat); frmtdtxtfldBetaF.setHorizontalAlignment(SwingConstants.TRAILING); panelBetaF.add(frmtdtxtfldBetaF); frmtdtxtfldBetaF.setColumns(4); frmtdtxtfldBetaF.setValue((Number) 75.4); JPanel panelEnvironmentVariables = new JPanel(); panelTab3.add(panelEnvironmentVariables); panelEnvironmentVariables.setLayout(new BoxLayout(panelEnvironmentVariables, BoxLayout.Y_AXIS)); JLabel lblEnvironmentVariables = new JLabel("Environment Variables"); lblEnvironmentVariables.setAlignmentX(Component.CENTER_ALIGNMENT); panelEnvironmentVariables.add(lblEnvironmentVariables); panelAngle = new JPanel(); FlowLayout flowLayout_10 = (FlowLayout) panelAngle.getLayout(); flowLayout_10.setAlignment(FlowLayout.RIGHT); panelEnvironmentVariables.add(panelAngle); JLabel lblAngle = new JLabel("Angle"); panelAngle.add(lblAngle); final JFormattedTextField frmtdtxtfldAngle = new JFormattedTextField(doubleFormat); frmtdtxtfldAngle.setHorizontalAlignment(SwingConstants.TRAILING); frmtdtxtfldAngle.setToolTipText("Angle between destinations"); panelAngle.add(frmtdtxtfldAngle); frmtdtxtfldAngle.setColumns(3); frmtdtxtfldAngle.setValue((Number) 72.00); panelNumberOfDestinations = new JPanel(); FlowLayout flowLayout_13 = (FlowLayout) panelNumberOfDestinations.getLayout(); flowLayout_13.setAlignment(FlowLayout.RIGHT); panelNumberOfDestinations.setVisible(false); panelEnvironmentVariables.add(panelNumberOfDestinations); JLabel lblNumberOfDestinations = new JLabel("Number of Destinations"); panelNumberOfDestinations.add(lblNumberOfDestinations); JFormattedTextField frmtdtxtfldNumberOfDestinations = new JFormattedTextField(countFormat); frmtdtxtfldNumberOfDestinations.setHorizontalAlignment(SwingConstants.TRAILING); panelNumberOfDestinations.add(frmtdtxtfldNumberOfDestinations); frmtdtxtfldNumberOfDestinations.setColumns(3); frmtdtxtfldNumberOfDestinations.setValue((Number) 2); panelDistance = new JPanel(); FlowLayout flowLayout_11 = (FlowLayout) panelDistance.getLayout(); flowLayout_11.setAlignment(FlowLayout.RIGHT); panelEnvironmentVariables.add(panelDistance); JLabel lblDistance = new JLabel("Distance"); panelDistance.add(lblDistance); frmtdtxtfldDistance = new JFormattedTextField(doubleFormat); frmtdtxtfldDistance.setHorizontalAlignment(SwingConstants.TRAILING); frmtdtxtfldDistance.setToolTipText("Distance the destination is from origin (0,0)"); panelDistance.add(frmtdtxtfldDistance); frmtdtxtfldDistance.setColumns(3); frmtdtxtfldDistance.setValue((Number) 150.0); panelPercentage = new JPanel(); FlowLayout flowLayout_12 = (FlowLayout) panelPercentage.getLayout(); flowLayout_12.setAlignment(FlowLayout.RIGHT); panelEnvironmentVariables.add(panelPercentage); JLabel lblPercentage = new JLabel("Percentage"); panelPercentage.add(lblPercentage); frmtdtxtfldPercentage = new JFormattedTextField(doubleFormat); frmtdtxtfldPercentage.setHorizontalAlignment(SwingConstants.TRAILING); frmtdtxtfldPercentage.setToolTipText( "The percentage moving to one of the two destinations ( The other gets 1 - percentage)."); panelPercentage.add(frmtdtxtfldPercentage); frmtdtxtfldPercentage.setColumns(3); frmtdtxtfldPercentage.setValue((Number) 0.500); panelInformedCount = new JPanel(); panelEnvironmentVariables.add(panelInformedCount); JLabel lblInformedCount = new JLabel("Informed Count"); panelInformedCount.add(lblInformedCount); final JFormattedTextField frmtdtxtfldInformedCount = new JFormattedTextField(countFormat); frmtdtxtfldInformedCount.setHorizontalAlignment(SwingConstants.TRAILING); frmtdtxtfldInformedCount.setColumns(3); frmtdtxtfldInformedCount.setToolTipText( "The number of agents moving toward a preferred destination. This number is duplicated on the southern pole as well."); frmtdtxtfldInformedCount.setValue((Number) 4); panelInformedCount.setVisible(false); panelInformedCount.add(frmtdtxtfldInformedCount); JPanel panelStartButtons = new JPanel(); JButton btnStartSimulation = new JButton("Create Simulator Instance"); btnStartSimulation.setToolTipText("Creates a new simulator instance from the settings provided."); btnStartSimulation.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { boolean isReady = true; ErrorPacketContainer errorPacketContainer = new ErrorPacketContainer(); if (jframeErrorMessages != null && jframeErrorMessages.isVisible()) { jframeErrorMessages.dispose(); } frmtdtxtfldRunCount.setBackground(Color.WHITE); frmtdtxtfldSimCount.setBackground(Color.WHITE); frmtdtxtfldMaxTimeSteps.setBackground(Color.WHITE); frmtdtxtfldPredationMinimum.setBackground(Color.WHITE); frmtdtxtfldPredationConstant.setBackground(Color.WHITE); frmtdtxtfldNearestNeighborCount.setBackground(Color.WHITE); frmtdtxtfldMaxLocationRadius.setBackground(Color.WHITE); frmtdtxtfldPercentage.setBackground(Color.WHITE); frmtdtxtfldDistance.setBackground(Color.WHITE); frmtdtxtfldDestinationRadius.setBackground(Color.WHITE); frmtdtxtfldAngle.setBackground(Color.WHITE); frmtdtxtfldInformedCount.setBackground(Color.WHITE); StringBuilder errorMessages = new StringBuilder(); if (((Number) frmtdtxtfldRunCount.getValue()).intValue() <= 0) { errorMessages.append("Run Count must be positive\n"); frmtdtxtfldRunCount.setBackground(Color.YELLOW); errorPacketContainer.addPacket("Run Count must be positive", frmtdtxtfldRunCount, 0); isReady = false; } if (((Number) frmtdtxtfldSimCount.getValue()).intValue() <= 0) { errorMessages.append("Sim Count must be positive\n"); frmtdtxtfldSimCount.setBackground(Color.YELLOW); errorPacketContainer.addPacket("Sim Count must be positive", frmtdtxtfldSimCount, 0); isReady = false; } if (((Number) frmtdtxtfldMaxTimeSteps.getValue()).intValue() <= 0) { errorMessages.append("Max Time Steps must be positive\n"); frmtdtxtfldMaxTimeSteps.setBackground(Color.YELLOW); errorPacketContainer.addPacket("Max Time Steps must be positive", frmtdtxtfldMaxTimeSteps, 0); isReady = false; } if (((Number) frmtdtxtfldPredationMinimum.getValue()).doubleValue() < 0 && chckbxPredationEnable.isSelected()) { errorMessages.append("Predation Minimum must be positive\n"); frmtdtxtfldPredationMinimum.setBackground(Color.YELLOW); errorPacketContainer.addPacket("Predation Minimum must be positive", frmtdtxtfldPredationMinimum, 1); isReady = false; } if (((Number) frmtdtxtfldPredationConstant.getValue()).doubleValue() <= 0 && chckbxPredationEnable.isSelected()) { errorMessages.append("Predation Constant must be positive\n"); frmtdtxtfldPredationConstant.setBackground(Color.YELLOW); errorPacketContainer.addPacket("Predation Constant must be positive", frmtdtxtfldPredationConstant, 1); isReady = false; } if (((Number) frmtdtxtfldNearestNeighborCount.getValue()).intValue() < 0 && panelNearestNeighborCount.isVisible()) { errorMessages.append("Nearest Neighbor Count must be positive\n"); frmtdtxtfldNearestNeighborCount.setBackground(Color.YELLOW); errorPacketContainer.addPacket("Nearest Neighbor Count must be positive", frmtdtxtfldNearestNeighborCount, 1); isReady = false; } if (((Number) frmtdtxtfldMaxLocationRadius.getValue()).doubleValue() < 0 && panelMaxLocationRadius.isVisible()) { errorMessages.append("Max Location Radius must be positive\n"); frmtdtxtfldMaxLocationRadius.setBackground(Color.YELLOW); errorPacketContainer.addPacket("Max Location Radius must be positive", frmtdtxtfldMaxLocationRadius, 1); isReady = false; } if ((((Number) frmtdtxtfldPercentage.getValue()).doubleValue() < 0.0 || ((Number) frmtdtxtfldPercentage.getValue()).doubleValue() > 1.0) && panelPercentage.isVisible()) { errorMessages.append( "Percentage needs to be greater than or equal to 0 and less than or equal to 1\n"); frmtdtxtfldPercentage.setBackground(Color.YELLOW); errorPacketContainer.addPacket( "Percentage needs to be greater than or equal to 0 and less than or equal to 1", frmtdtxtfldPercentage, 2); isReady = false; } if (((Number) frmtdtxtfldDistance.getValue()).doubleValue() <= 0 && frmtdtxtfldDistance.isVisible()) { errorMessages.append("Distance must be positive\n"); frmtdtxtfldDistance.setBackground(Color.YELLOW); errorPacketContainer.addPacket("Distance must be positive", frmtdtxtfldDistance, 2); isReady = false; } if (((Number) frmtdtxtfldDestinationRadius.getValue()).doubleValue() <= 0) { errorMessages.append("Destination Radius must be positive\n"); frmtdtxtfldDestinationRadius.setBackground(Color.YELLOW); errorPacketContainer.addPacket("Destination Radius must be positive", frmtdtxtfldDestinationRadius, 0); isReady = false; } if (((Number) frmtdtxtfldAngle.getValue()).doubleValue() < 0) { errorMessages.append("Angle must be positive or zero\n"); frmtdtxtfldAngle.setBackground(Color.YELLOW); errorPacketContainer.addPacket("Angle must be positive", frmtdtxtfldAngle, 2); isReady = false; } if (((Number) frmtdtxtfldInformedCount.getValue()).intValue() <= 0) { errorMessages.append("Informed Count must be positive\n"); frmtdtxtfldInformedCount.setBackground(Color.YELLOW); errorPacketContainer.addPacket("Informed Count must be positive", frmtdtxtfldInformedCount, 2); isReady = false; } else if (((Number) frmtdtxtfldInformedCount.getValue()).intValue() * 2 > sliderAgent.getValue()) { errorMessages.append("Informed Count should at most be half the count of total agents\n"); frmtdtxtfldInformedCount.setBackground(Color.YELLOW); errorPacketContainer.addPacket( "Informed Count should at most be half the count of total agents", frmtdtxtfldInformedCount, 2); isReady = false; } if (!isReady) { jframeErrorMessages = createJFrameErrorMessages(errorPacketContainer, tabbedPane); jframeErrorMessages.setVisible(true); } else { _simulatorProperties = new Properties(); _simulatorProperties.put("run-count", String.valueOf(frmtdtxtfldRunCount.getValue())); _simulatorProperties.put("simulation-count", String.valueOf(frmtdtxtfldSimCount.getValue())); _simulatorProperties.put("max-simulation-time-steps", String.valueOf(frmtdtxtfldMaxTimeSteps.getValue())); _simulatorProperties.put("random-seed", String.valueOf(1)); // Doesn't change _simulatorProperties.put("individual-count", String.valueOf(sliderAgent.getValue())); _simulatorProperties.put("run-graphical", String.valueOf(chckbxGraphical.isSelected())); _simulatorProperties.put("pre-calculate-probabilities", String.valueOf(false)); // Doesn't change _simulatorProperties.put("use-random-random-seed", String.valueOf(chckbxRandomSeed.isSelected())); _simulatorProperties.put("can-multiple-initiate", String.valueOf(true)); // Doesn't change _simulatorProperties.put("eskridge-results", String.valueOf(chckbxEskridge.isSelected())); _simulatorProperties.put("conflict-results", String.valueOf(chckbxConflict.isSelected())); _simulatorProperties.put("position-results", String.valueOf(chckbxPosition.isSelected())); _simulatorProperties.put("predation-results", String.valueOf(chckbxPredationResults.isSelected())); _simulatorProperties.put("communication-type", String.valueOf(comboBoxCommType.getSelectedItem()).toLowerCase()); _simulatorProperties.put("nearest-neighbor-count", String.valueOf(frmtdtxtfldNearestNeighborCount.getValue())); _simulatorProperties.put("max-location-radius", String.valueOf(frmtdtxtfldMaxLocationRadius.getValue())); _simulatorProperties.put("destination-size-radius", String.valueOf(frmtdtxtfldDestinationRadius.getValue())); _simulatorProperties.put("max-agents-eaten-per-step", String.valueOf(spinnerMaxEaten.getValue())); _simulatorProperties.put("enable-predator", String.valueOf(chckbxPredationEnable.isSelected())); _simulatorProperties.put("predation-probability-minimum", String.valueOf(frmtdtxtfldPredationMinimum.getValue())); _simulatorProperties.put("predation-multiplier", String.valueOf(frmtdtxtfldPredationConstant.getValue())); _simulatorProperties.put("use-predation-threshold", String.valueOf(chckbxUsePredationThreshold.isSelected())); _simulatorProperties.put("predation-threshold", String.valueOf(spinnerPredationThreshold.getValue())); _simulatorProperties.put("predation-by-population", String.valueOf(chckbxPopulationIndependent.isSelected())); _simulatorProperties.put("count-non-movers-as-survivors", String.valueOf(chckbxNonMoversSurvive.isSelected())); _simulatorProperties.put("stop-at-any-destination", String.valueOf(chckbxStopAnywhere.isSelected())); _simulatorProperties.put("adhesion-time-limit", String.valueOf(frmtdtxtfldMaxTimeSteps.getValue())); _simulatorProperties.put("alpha", String.valueOf(frmtdtxtfldAlpha.getValue())); _simulatorProperties.put("alpha-c", String.valueOf(frmtdtxtfldAlphaC.getValue())); _simulatorProperties.put("beta", String.valueOf(frmtdtxtfldBeta.getValue())); _simulatorProperties.put("beta-c", String.valueOf(frmtdtxtfldBetaC.getValue())); _simulatorProperties.put("S", String.valueOf(frmtdtxtfldS.getValue())); _simulatorProperties.put("q", String.valueOf(frmtdtxtfldQ.getValue())); _simulatorProperties.put("lambda", String.valueOf(0.2)); _simulatorProperties.put("tau-o", String.valueOf(frmtdtxtfldTaoO.getValue())); _simulatorProperties.put("gamma-c", String.valueOf(frmtdtxtfldGammaC.getValue())); _simulatorProperties.put("epsilon-c", String.valueOf(frmtdtxtfldEpsilonC.getValue())); _simulatorProperties.put("alpha-f", String.valueOf(frmtdtxtfldAlphaF.getValue())); _simulatorProperties.put("beta-f", String.valueOf(frmtdtxtfldBetaF.getValue())); _simulatorProperties.put("default-conflict-value", String.valueOf(spinnerDefaultConflict.getValue())); _simulatorProperties.put("cancellation-threshold", String.valueOf(spinnerCancelationThreshold.getValue())); StringBuilder sbAgentBuilder = new StringBuilder(); sbAgentBuilder.append("edu.snu.leader.discrete.simulator.Sueur"); sbAgentBuilder.append(comboBoxAgentBuilder.getSelectedItem().toString().replace(" ", "")); sbAgentBuilder.append("AgentBuilder"); _simulatorProperties.put("agent-builder", String.valueOf(sbAgentBuilder.toString())); StringBuilder sbDecisionCalculator = new StringBuilder(); sbDecisionCalculator.append("edu.snu.leader.discrete.simulator."); sbDecisionCalculator.append(comboBoxModel.getSelectedItem()); // sbDecisionCalculator.append(comboBoxDecisionCalculator.getSelectedItem()); sbDecisionCalculator .append(comboBoxDecisionCalculator.getSelectedItem().toString().replace(" ", "")); sbDecisionCalculator.append("DecisionCalculator"); _simulatorProperties.put("decision-calculator", String.valueOf(sbDecisionCalculator.toString())); StringBuilder sbLocationsFile = new StringBuilder(); sbLocationsFile.append("cfg/sim/locations/metric/valid-metric-loc-"); sbLocationsFile.append(String.format("%03d", sliderAgent.getValue())); sbLocationsFile.append("-seed-00001.dat"); _simulatorProperties.put("locations-file", String.valueOf(sbLocationsFile.toString())); //create destination file DestinationBuilder db = new DestinationBuilder(sliderAgent.getValue(), 1L); StringBuilder sbDestinationsFile = new StringBuilder(); sbDestinationsFile.append("cfg/sim/destinations/destinations-"); switch (comboBoxEnvironment.getSelectedItem().toString()) { case ("Minimum"): sbDestinationsFile.append("diffdis-" + sliderAgent.getValue()); sbDestinationsFile.append("-per-" + frmtdtxtfldPercentage.getValue()); sbDestinationsFile.append("-seed-1.dat"); db.generateDifferentDistance(((Number) frmtdtxtfldPercentage.getValue()).doubleValue(), 200, 100, 75); break; case ("Medium"): sbDestinationsFile.append("split-" + sliderAgent.getValue()); sbDestinationsFile.append("-dis-" + frmtdtxtfldDistance.getValue()); sbDestinationsFile.append("-ang-" + String.format("%.2f", ((Number) frmtdtxtfldAngle.getValue()).doubleValue())); sbDestinationsFile.append("-per-" + String.format("%.3f", ((Number) frmtdtxtfldPercentage.getValue()).doubleValue())); sbDestinationsFile.append("-seed-1.dat"); db.generateSplitNorth(((Number) frmtdtxtfldDistance.getValue()).doubleValue(), ((Number) frmtdtxtfldAngle.getValue()).doubleValue(), ((Number) frmtdtxtfldPercentage.getValue()).doubleValue()); break; case ("Maximum"): sbDestinationsFile.append("poles-" + sliderAgent.getValue()); sbDestinationsFile.append("-per-" + frmtdtxtfldPercentage.getValue()); sbDestinationsFile.append("-seed-1.dat"); db.generatePoles(50, 100, ((Number) frmtdtxtfldPercentage.getValue()).doubleValue()); break; case ("Uninformed"): sbDestinationsFile.append("split-poles-" + frmtdtxtfldInformedCount.getValue()); sbDestinationsFile.append("-dis-" + String.format("%.1f", ((Number) frmtdtxtfldDistance.getValue()).doubleValue())); sbDestinationsFile.append("-ang-" + String.format("%.2f", ((Number) frmtdtxtfldAngle.getValue()).doubleValue())); sbDestinationsFile.append("-per-" + String.format("%.3f", ((Number) frmtdtxtfldPercentage.getValue()).doubleValue())); sbDestinationsFile.append("-seed-1.dat"); db.generateSplitPoles(((Number) frmtdtxtfldDistance.getValue()).doubleValue(), ((Number) frmtdtxtfldAngle.getValue()).doubleValue(), ((Number) frmtdtxtfldPercentage.getValue()).doubleValue(), ((Number) frmtdtxtfldInformedCount.getValue()).intValue()); break; default: //Should never happen break; } _simulatorProperties.put("destinations-file", String.valueOf(sbDestinationsFile.toString())); _simulatorProperties.put("live-delay", String.valueOf(15)); //Doesn't change _simulatorProperties.put("results-dir", "results"); //Doesn't change new Thread(new Runnable() { public void run() { try { runSimulation(); } catch (Exception e) { e.printStackTrace(); } } }).start(); } } }); panelStartButtons.add(btnStartSimulation); JButton btnStartSimulationFrom = new JButton("Run Simulation from Properties File"); btnStartSimulationFrom .setToolTipText("Runs the simulator with the values provided in the properties file."); btnStartSimulationFrom.setEnabled(false); panelStartButtons.add(btnStartSimulationFrom); panelTab3.add(panelStartButtons); }
From source file:com.google.code.facebook.graph.sna.applet.VertexImageShaperDemo.java
public VertexImageShaperDemo() { // create a simple graph for the demo graph = new DirectedSparseGraph<Number, Number>(); createGraph(VERTEX_COUNT);//from ww w. j av a2 s . c o m // a Map for the labels Map<Number, String> map = new HashMap<Number, String>(); for (int i = 0; i < VERTEX_COUNT; i++) { map.put(i, iconNames[i % iconNames.length]); } // a Map for the Icons Map<Number, Icon> iconMap = new HashMap<Number, Icon>(); for (int i = 0; i < VERTEX_COUNT; i++) { String name = "/images/topic" + iconNames[i] + ".gif"; try { Icon icon = new LayeredIcon( new ImageIcon(VertexImageShaperDemo.class.getResource(name)).getImage()); iconMap.put(i, icon); } catch (Exception ex) { System.err.println("You need slashdoticons.jar in your classpath to see the image " + name); } } FRLayout<Number, Number> layout = new FRLayout<Number, Number>(graph); layout.setMaxIterations(100); layout.setInitializer(new RandomLocationTransformer<Number>(new Dimension(400, 400), 0)); vv = new VisualizationViewer<Number, Number>(layout, new Dimension(400, 400)); // This demo uses a special renderer to turn outlines on and off. // you do not need to do this in a real application. // Instead, just let vv use the Renderer it already has vv.getRenderer().setVertexRenderer(new DemoRenderer<Number, Number>()); Transformer<Number, Paint> vpf = new PickableVertexPaintTransformer<Number>(vv.getPickedVertexState(), Color.white, Color.yellow); vv.getRenderContext().setVertexFillPaintTransformer(vpf); vv.getRenderContext().setEdgeDrawPaintTransformer( new PickableEdgePaintTransformer<Number>(vv.getPickedEdgeState(), Color.black, Color.cyan)); vv.setBackground(Color.white); final Transformer<Number, String> vertexStringerImpl = new VertexStringerImpl<Number, String>(map); vv.getRenderContext().setVertexLabelTransformer(vertexStringerImpl); vv.getRenderContext().setVertexLabelRenderer(new DefaultVertexLabelRenderer(Color.cyan)); vv.getRenderContext().setEdgeLabelRenderer(new DefaultEdgeLabelRenderer(Color.cyan)); // vv.getRenderContext().setEdgeLabelTransformer(new Transformer<Number,String>() { // URL url = getClass().getResource("/images/lightning-s.gif"); // public String transform(Number input) { // // return "<html><img src="+url+" height=10 width=21>"+input.toString(); // }}); // For this demo only, I use a special class that lets me turn various // features on and off. For a real application, use VertexIconShapeTransformer instead. final DemoVertexIconShapeTransformer<Number> vertexIconShapeTransformer = new DemoVertexIconShapeTransformer<Number>( new EllipseVertexShapeTransformer<Number>()); final DemoVertexIconTransformer<Number> vertexIconTransformer = new DemoVertexIconTransformer<Number>(); vertexIconShapeTransformer.setIconMap(iconMap); vertexIconTransformer.setIconMap(iconMap); vv.getRenderContext().setVertexShapeTransformer(vertexIconShapeTransformer); vv.getRenderContext().setVertexIconTransformer(vertexIconTransformer); // un-comment for RStar Tree visual testing //vv.addPostRenderPaintable(new BoundingRectanglePaintable(vv.getRenderContext(), vv.getGraphLayout())); // Get the pickedState and add a listener that will decorate the // Vertex images with a checkmark icon when they are picked PickedState<Number> ps = vv.getPickedVertexState(); ps.addItemListener(new PickWithIconListener<Number>(vertexIconTransformer)); vv.addPostRenderPaintable(new VisualizationViewer.Paintable() { int x; int y; Font font; FontMetrics metrics; int swidth; int sheight; String str = "Thank You, slashdot.org, for the images!"; public void paint(Graphics g) { Dimension d = vv.getSize(); if (font == null) { font = new Font(g.getFont().getName(), Font.BOLD, 20); metrics = g.getFontMetrics(font); swidth = metrics.stringWidth(str); sheight = metrics.getMaxAscent() + metrics.getMaxDescent(); x = (d.width - swidth) / 2; y = (int) (d.height - sheight * 1.5); } g.setFont(font); Color oldColor = g.getColor(); g.setColor(Color.lightGray); g.drawString(str, x, y); g.setColor(oldColor); } public boolean useTransform() { return false; } }); // add a listener for ToolTips vv.setVertexToolTipTransformer(new ToStringLabeller<Number>()); Container content = getContentPane(); final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv); content.add(panel); final DefaultModalGraphMouse<Number, Number> graphMouse = new DefaultModalGraphMouse<Number, Number>(); vv.setGraphMouse(graphMouse); vv.addKeyListener(graphMouse.getModeKeyListener()); final ScalingControl scaler = new CrossoverScalingControl(); JButton plus = new JButton("+"); plus.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1.1f, vv.getCenter()); } }); JButton minus = new JButton("-"); minus.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1 / 1.1f, vv.getCenter()); } }); JCheckBox shape = new JCheckBox("Shape"); shape.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { vertexIconShapeTransformer.setShapeImages(e.getStateChange() == ItemEvent.SELECTED); vv.repaint(); } }); shape.setSelected(true); JCheckBox fill = new JCheckBox("Fill"); fill.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { vertexIconTransformer.setFillImages(e.getStateChange() == ItemEvent.SELECTED); vv.repaint(); } }); fill.setSelected(true); JCheckBox drawOutlines = new JCheckBox("Outline"); drawOutlines.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { vertexIconTransformer.setOutlineImages(e.getStateChange() == ItemEvent.SELECTED); vv.repaint(); } }); JComboBox modeBox = graphMouse.getModeComboBox(); JPanel modePanel = new JPanel(); modePanel.setBorder(BorderFactory.createTitledBorder("Mouse Mode")); modePanel.add(modeBox); JPanel scaleGrid = new JPanel(new GridLayout(1, 0)); scaleGrid.setBorder(BorderFactory.createTitledBorder("Zoom")); JPanel labelFeatures = new JPanel(new GridLayout(1, 0)); labelFeatures.setBorder(BorderFactory.createTitledBorder("Image Effects")); JPanel controls = new JPanel(); scaleGrid.add(plus); scaleGrid.add(minus); controls.add(scaleGrid); labelFeatures.add(shape); labelFeatures.add(fill); labelFeatures.add(drawOutlines); controls.add(labelFeatures); controls.add(modePanel); content.add(controls, BorderLayout.SOUTH); }
From source file:demo.VertexImageShaperDemo.java
public VertexImageShaperDemo() { // create a simple graph for the demo graph = new DirectedSparseGraph<Number, Number>(); createGraph(VERTEX_COUNT);/*ww w .ja va 2 s . co m*/ // a Map for the labels Map<Number, String> map = new HashMap<Number, String>(); for (int i = 0; i < VERTEX_COUNT; i++) { map.put(i, iconNames[i % iconNames.length]); } // a Map for the Icons Map<Number, Icon> iconMap = new HashMap<Number, Icon>(); for (int i = 0; i < VERTEX_COUNT; i++) { String name = "/images/topic" + iconNames[i] + ".gif"; try { Icon icon = new LayeredIcon( new ImageIcon(VertexImageShaperDemo.class.getResource(name)).getImage()); //iconMap.put(i, icon); iconMap.put(i, new ImageIcon("transferir.png")); } catch (Exception ex) { System.err.println("You need slashdoticons.jar in your classpath to see the image " + name); } } FRLayout<Number, Number> layout = new FRLayout<Number, Number>(graph); layout.setMaxIterations(100); layout.setInitializer(new RandomLocationTransformer<Number>(new Dimension(400, 400), 0)); vv = new VisualizationViewer<Number, Number>(layout, new Dimension(400, 400)); // This demo uses a special renderer to turn outlines on and off. // you do not need to do this in a real application. // Instead, just let vv use the Renderer it already has vv.getRenderer().setVertexRenderer(new DemoRenderer<Number, Number>()); Transformer<Number, Paint> vpf = new PickableVertexPaintTransformer<Number>(vv.getPickedVertexState(), Color.white, Color.yellow); vv.getRenderContext().setVertexFillPaintTransformer(vpf); vv.getRenderContext().setEdgeDrawPaintTransformer( new PickableEdgePaintTransformer<Number>(vv.getPickedEdgeState(), Color.black, Color.cyan)); vv.setBackground(Color.white); final Transformer<Number, String> vertexStringerImpl = new VertexStringerImpl<Number, String>(map); vv.getRenderContext().setVertexLabelTransformer(vertexStringerImpl); vv.getRenderContext().setVertexLabelRenderer(new DefaultVertexLabelRenderer(Color.cyan)); vv.getRenderContext().setEdgeLabelRenderer(new DefaultEdgeLabelRenderer(Color.cyan)); // vv.getRenderContext().setEdgeLabelTransformer(new Transformer<Number,String>() { // URL url = getClass().getResource("/images/lightning-s.gif"); // public String transform(Number input) { // // return "<html><img src="+url+" height=10 width=21>"+input.toString(); // }}); // For this demo only, I use a special class that lets me turn various // features on and off. For a real application, use VertexIconShapeTransformer instead. final DemoVertexIconShapeTransformer<Number> vertexIconShapeTransformer = new DemoVertexIconShapeTransformer<Number>( new EllipseVertexShapeTransformer<Number>()); final DemoVertexIconTransformer<Number> vertexIconTransformer = new DemoVertexIconTransformer<Number>(); vertexIconShapeTransformer.setIconMap(iconMap); vertexIconTransformer.setIconMap(iconMap); vv.getRenderContext().setVertexShapeTransformer(vertexIconShapeTransformer); vv.getRenderContext().setVertexIconTransformer(vertexIconTransformer); // un-comment for RStar Tree visual testing //vv.addPostRenderPaintable(new BoundingRectanglePaintable(vv.getRenderContext(), vv.getGraphLayout())); // Get the pickedState and add a listener that will decorate the // Vertex images with a checkmark icon when they are picked PickedState<Number> ps = vv.getPickedVertexState(); ps.addItemListener(new PickWithIconListener<Number>(vertexIconTransformer)); vv.addPostRenderPaintable(new VisualizationViewer.Paintable() { int x; int y; Font font; FontMetrics metrics; int swidth; int sheight; String str = "Thank You, slashdot.org, for the images!"; public void paint(Graphics g) { Dimension d = vv.getSize(); if (font == null) { font = new Font(g.getFont().getName(), Font.BOLD, 20); metrics = g.getFontMetrics(font); swidth = metrics.stringWidth(str); sheight = metrics.getMaxAscent() + metrics.getMaxDescent(); x = (d.width - swidth) / 2; y = (int) (d.height - sheight * 1.5); } g.setFont(font); Color oldColor = g.getColor(); g.setColor(Color.lightGray); g.drawString(str, x, y); g.setColor(oldColor); } public boolean useTransform() { return false; } }); // add a listener for ToolTips vv.setVertexToolTipTransformer(new ToStringLabeller<Number>()); Container content = getContentPane(); final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv); content.add(panel); final DefaultModalGraphMouse<Number, Number> graphMouse = new DefaultModalGraphMouse<Number, Number>(); vv.setGraphMouse(graphMouse); vv.addKeyListener(graphMouse.getModeKeyListener()); final ScalingControl scaler = new CrossoverScalingControl(); JButton plus = new JButton("+"); plus.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1.1f, vv.getCenter()); } }); JButton minus = new JButton("-"); minus.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1 / 1.1f, vv.getCenter()); } }); JCheckBox shape = new JCheckBox("Shape"); shape.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { vertexIconShapeTransformer.setShapeImages(e.getStateChange() == ItemEvent.SELECTED); vv.repaint(); } }); shape.setSelected(true); JCheckBox fill = new JCheckBox("Fill"); fill.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { vertexIconTransformer.setFillImages(e.getStateChange() == ItemEvent.SELECTED); vv.repaint(); } }); fill.setSelected(true); JCheckBox drawOutlines = new JCheckBox("Outline"); drawOutlines.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { vertexIconTransformer.setOutlineImages(e.getStateChange() == ItemEvent.SELECTED); vv.repaint(); } }); JComboBox modeBox = graphMouse.getModeComboBox(); JPanel modePanel = new JPanel(); modePanel.setBorder(BorderFactory.createTitledBorder("Mouse Mode")); modePanel.add(modeBox); JPanel scaleGrid = new JPanel(new GridLayout(1, 0)); scaleGrid.setBorder(BorderFactory.createTitledBorder("Zoom")); JPanel labelFeatures = new JPanel(new GridLayout(1, 0)); labelFeatures.setBorder(BorderFactory.createTitledBorder("Image Effects")); JPanel controls = new JPanel(); scaleGrid.add(plus); scaleGrid.add(minus); controls.add(scaleGrid); labelFeatures.add(shape); labelFeatures.add(fill); labelFeatures.add(drawOutlines); controls.add(labelFeatures); controls.add(modePanel); content.add(controls, BorderLayout.SOUTH); }
From source file:org.csa.rstb.dat.toolviews.HaAlphaPlotPanel.java
private JPanel createOptionsPanel() { toggleZoneOverlayCheckBox = new JCheckBox("Show Zones"); toggleZoneOverlayCheckBox.addActionListener(new ActionListener() { @Override/*www .j a v a 2 s . co m*/ public void actionPerformed(ActionEvent e) { updateChartData(); } }); toggleZoneOverlayCheckBox.setEnabled(false); toggleZoneOverlayCheckBox.setSelected(true); final JPanel optionsPanel = GridBagUtils.createPanel(); final GridBagConstraints gbc = GridBagUtils .createConstraints("anchor=NORTHWEST,fill=HORIZONTAL,insets.top=0,weightx=1,gridx=0"); GridBagUtils.addToPanel(optionsPanel, axisRangeControls[X_VAR].getPanel(), gbc, "gridy=0"); GridBagUtils.addToPanel(optionsPanel, axisRangeControls[Y_VAR].getPanel(), gbc, "gridy=2,insets.left=0,insets.right=0"); GridBagUtils.addToPanel(optionsPanel, new JPanel(), gbc, "gridy=4"); GridBagUtils.addToPanel(optionsPanel, new JSeparator(), gbc, "gridy=5,insets.left=4,insets.right=2"); GridBagUtils.addToPanel(optionsPanel, toggleZoneOverlayCheckBox, gbc, "gridy=6,insets.left=0,insets.right=0"); GridBagUtils.addToPanel(optionsPanel, new JLabel("Zones Descriptions:"), gbc, "gridy=8,insets.left=0,insets.right=0"); JTextArea textArea = new JTextArea("Z1 - Dihedral Reflector\n" + "Z2 - Dipole\n" + "Z3 - Bragg Surface\n" + "Z4 - Double Reflection\n" + "Z5 - Anisotropic Particles\n" + "Z6 - Random Surface\n" + "Z7 - Complex Structures\n" + "Z8 - Random Anisotropic Scatterers\n" + "Z9 - Non-feasible"); GridBagUtils.addToPanel(optionsPanel, textArea, gbc, "gridy=9,insets.left=0,insets.right=0"); return optionsPanel; }
From source file:com.fratello.longevity.smooth.AppGUI.java
private void initialize() { LabelMaxSize = 0;//from w w w.j ava 2s.c om ActiveGUI = true; GUI_Start = false; GUI_Pause = true; GUI_Stop = false; ran_at_least_once = false; execute(); initializeFields(); frmFileSystemSearch = new JFrame(); frmFileSystemSearch.setTitle("Smooth Longevity Fratello"); frmFileSystemSearch.setBounds(100, 100, 450, 300); frmFileSystemSearch.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frmFileSystemSearch.setResizable(false); UIManager.put("PopupMenu.border", BorderFactory.createLineBorder(Color.black, 1)); JMenuBar menuBar = new JMenuBar(); frmFileSystemSearch.setJMenuBar(menuBar); JMenu mnNewMenu = new JMenu("File"); menuBar.add(mnNewMenu); JMenuItem mntmFirst = new JMenuItem("Open Directory"); mntmFirst.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { openFileChooserDir(mntmFirst); } }); mnNewMenu.add(mntmFirst); JMenuItem mntmExit = new JMenuItem("Exit"); mntmExit.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { frmFileSystemSearch.dispose(); } }); mnNewMenu.add(mntmExit); JMenu mnHelp = new JMenu("Help"); menuBar.add(mnHelp); JMenuItem mntmAbout = new JMenuItem("About"); mnHelp.add(mntmAbout); JMenuItem mntmTutorials = new JMenuItem("Tutorials"); mnHelp.add(mntmTutorials); JMenuItem mntmCheckForUpdates = new JMenuItem("Check for Updates"); mnHelp.add(mntmCheckForUpdates); String ppallink = "https://www.paypal.com/cgi-bin/webscr" + "?cmd=" + "_donations" + "&business=" + "8YUJNSN6KFV54" + "&lc=" + "US" + "&item_name=" + "Personal%20funds%20for%20programming%20at%20university" + "¤cy_code=" + "USD" + "&bn=" + "PP%2dDonationsBF" + "%3abtn_donateCC_LG%2egif%3aNonHosted"; JButton btnDonate = new JButton("Donate"); btnDonate.setToolTipText("<html>Open default Internet browser <br>(Chrome, FireFox, etc.)</html>"); btnDonate.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { openWebPage(ppallink); } }); btnDonate.setBounds(159, 176, 90, 25); menuBar.add(btnDonate); JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP); frmFileSystemSearch.getContentPane().add(tabbedPane, BorderLayout.CENTER); // ---------------------------- JPanels ------------------------------ JPanel panel = new JPanel(); tabbedPane.addTab("Start Directory", null, panel, null); JPanel panel_1 = new JPanel(); tabbedPane.addTab("Search Setup", null, panel_1, null); panel_1.setLayout(null); JPanel panel_2 = new JPanel(); tabbedPane.addTab("Run Program", null, panel_2, null); panel_2.setLayout(null); JPanel panel_3 = new JPanel(); tabbedPane.addTab("Information", null, panel_3, null); panel_3.setBounds(10, 11, 409, 154); GridBagLayout gbl_panel_3 = new GridBagLayout(); gbl_panel_3.columnWidths = new int[] { 0, 0, 0 }; gbl_panel_3.rowHeights = new int[] { 0, 0, 0 }; gbl_panel_3.columnWeights = new double[] { 1.0, 1.0, 1.0 }; gbl_panel_3.rowWeights = new double[] { 0.0, 0.0, Double.MIN_VALUE }; panel_3.setLayout(gbl_panel_3); // ------------- Dynamic Update - Swingworker Components ------------- SentinelProgressBar = new JProgressBar(); SentinelProgressBar.setMaximumSize(new Dimension(146, 14)); SentinelProgressBar.setMaximum(1000); SentinelProgressBar.setBounds(74, 187, 146, 14); panel_2.add(SentinelProgressBar); SentinelProgressLabel = new JLabel(); SentinelProgressLabel.setToolTipText("Time needed to finish the program in progress"); SentinelProgressLabel.setBounds(333, 181, 86, 20); panel_2.add(SentinelProgressLabel); // ------------------------------------------------------------------- // ------------------------ JPanel Components ------------------------ JLabel lblCurrentDirectory = new JLabel("Current Directory"); panel.add(lblCurrentDirectory); userSelectedDirectories = new JTextField(); panel.add(userSelectedDirectories); userSelectedDirectories.setColumns(35); JButton btnBrowse = new JButton("Browse"); btnBrowse.setToolTipText("Locate directory in system"); btnBrowse.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { openFileChooserDir(btnBrowse); } }); panel.add(btnBrowse); JButton btnClear = new JButton("Clear"); btnClear.setToolTipText("Deletes the current directory shown"); btnClear.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { userSelectedDirectories.setText(""); clearSourceDirectory(); } }); panel.add(btnClear); // ------------------------------------------------------------------- // ----------------------- JPanel_1 Components ----------------------- // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // Extension :: [Check Box] chckbxExt = new JCheckBox("Extension"); chckbxExt.setToolTipText("Check to ignore file extensions"); chckbxExt.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) cf.setUse("Ext", true); else if (e.getStateChange() == ItemEvent.DESELECTED) cf.setUse("Ext", false); } }); chckbxExt.setBounds(8, 15, 97, 23); panel_1.add(chckbxExt); // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // Hash :: [Check Box] chckbxHash = new JCheckBox("Hash"); chckbxHash.setToolTipText("Check to compare by hashing files (FAST)"); chckbxHash.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) cf.setUse("Hash", true); else if (e.getStateChange() == ItemEvent.DESELECTED) cf.setUse("Hash", false); } }); chckbxHash.setBounds(8, 45, 97, 23); panel_1.add(chckbxHash); // Hash :: [Combo Box] comboBoxHash = new JComboBox<String>(); comboBoxHash.setToolTipText( "<html>Hash algorithm to use in file hashing <br>(note - SHA-512 may not be <br>supported by your computer)</html>"); comboBoxHash.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { @SuppressWarnings("unchecked") JComboBox<String> cb = (JComboBox<String>) e.getSource(); String UIselect = (String) cb.getSelectedItem(); cf.setHashString(UIselect); } }); comboBoxHash .setModel(new DefaultComboBoxModel<String>(new String[] { "MD5", "SHA-1", "SHA-256", "SHA-512" })); comboBoxHash.setBounds(150, 44, 75, 25); panel_1.add(comboBoxHash); // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // Name :: [Check Box] chckbxName = new JCheckBox("Name"); chckbxName.setToolTipText("Name tool-tip goes here"); chckbxName.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) cf.setUse("Name", true); else if (e.getStateChange() == ItemEvent.DESELECTED) cf.setUse("Name", false); } }); chckbxName.setBounds(8, 75, 97, 23); panel_1.add(chckbxName); // Name :: [Text Field] namePercentMatchTextField = new JFormattedTextField(new Double(0.0d)); namePercentMatchTextField.setFormatterFactory(new DoubleDocListener(namePercentMatchTextField)); namePercentMatchTextField.getDocument() .addDocumentListener(new DoubleDocListener(namePercentMatchTextField)); namePercentMatchTextField.setToolTipText("Match file names by percentage [00.00-100.00]"); namePercentMatchTextField.setBounds(150, 74, 110, 25); panel_1.add(namePercentMatchTextField); namePercentMatchTextField.setColumns(10); // Name :: [Combo Box] comboBoxNames = new JComboBox<String>(); comboBoxNames.setToolTipText("Algorithm to compare names"); comboBoxNames.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { @SuppressWarnings("unchecked") JComboBox<String> cb = (JComboBox<String>) e.getSource(); String UIselect = (String) cb.getSelectedItem(); cf.setMatchingAlgorithm(UIselect); } }); comboBoxNames.setModel(new DefaultComboBoxModel<String>(new String[] { "Bitap", "Cosine", "DamerauLevenshtein", "DynamicTimeWarpingStandard1", "DynamicTimeWarpingStandard2", "Hamming", "Hirschberg", "JaccardIndex", "JaroWinkler", "Levenshtein", "NeedlemanWunsch", "SmithWaterman", "SorensenSimilarityIndex", "WagnerFischer" })); comboBoxNames.setBounds(265, 74, 150, 25); panel_1.add(comboBoxNames); // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // Size :: [Check Box] chckbxSize = new JCheckBox("Size"); chckbxSize.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) cf.setUse("Size", true); else if (e.getStateChange() == ItemEvent.DESELECTED) cf.setUse("Size", false); } }); chckbxSize.setBounds(8, 105, 97, 23); panel_1.add(chckbxSize); // Size :: [Text Field] sizePercentMatchTextField = new JFormattedTextField(new Double(0.0d)); sizePercentMatchTextField.setFormatterFactory(new DoubleDocListener(sizePercentMatchTextField)); sizePercentMatchTextField.getDocument() .addDocumentListener(new DoubleDocListener(sizePercentMatchTextField)); sizePercentMatchTextField.setToolTipText("Match file sizes by percentage [00.00-100.00]"); sizePercentMatchTextField.setBounds(150, 104, 110, 25); panel_1.add(sizePercentMatchTextField); sizePercentMatchTextField.setColumns(10); // Size :: [Combo Box] comboBoxSize = new JComboBox<String>(); comboBoxSize.setToolTipText("Specify byte grouping"); comboBoxSize.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { @SuppressWarnings("unchecked") JComboBox<String> cb = (JComboBox<String>) e.getSource(); String UIselect = (String) cb.getSelectedItem(); cf.setMetricSize(UIselect); } }); comboBoxSize.setModel( new DefaultComboBoxModel<String>(new String[] { "BYTE", "KILOBYTE", "MEGABYTE", "GIGABYTE" })); comboBoxSize.setBounds(265, 104, 150, 25); panel_1.add(comboBoxSize); // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // Thorough :: [Check Box] chckbxThorough = new JCheckBox("Thorough"); chckbxThorough.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) cf.setUse("Thorough", true); else if (e.getStateChange() == ItemEvent.DESELECTED) cf.setUse("Thorough", false); } }); chckbxThorough.setToolTipText("Check byte by byte"); chckbxThorough.setBounds(8, 135, 97, 23); panel_1.add(chckbxThorough); // Thorough :: [Text Field] thoroughPercentMatchTextField = new JFormattedTextField(new Double(0.0d)); thoroughPercentMatchTextField.setFormatterFactory(new DoubleDocListener(thoroughPercentMatchTextField)); thoroughPercentMatchTextField.getDocument() .addDocumentListener(new DoubleDocListener(thoroughPercentMatchTextField)); thoroughPercentMatchTextField.setToolTipText("Match file sizes by percentage [00.00-100.00]"); thoroughPercentMatchTextField.setBounds(150, 134, 110, 25); panel_1.add(thoroughPercentMatchTextField); thoroughPercentMatchTextField.setColumns(10); // Thorough :: [Check Box] chckbxExitFast = new JCheckBox("Exit Fast"); chckbxExitFast.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) cf.setThoroughExitFirstByteMisMatch(true); else if (e.getStateChange() == ItemEvent.DESELECTED) cf.setThoroughExitFirstByteMisMatch(false); } }); chckbxExitFast.setToolTipText("<html>When the first byte comparison <br>is a mis-match then stop</html>"); chckbxExitFast.setBounds(265, 138, 105, 16); panel_1.add(chckbxExitFast); // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ JButton btnSaveSearchSettings = new JButton("Save Search Settings"); btnSaveSearchSettings.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { pollSearchSettings(); cf.saveObject(); // System.out.println(cf.toString()); // debug } }); btnSaveSearchSettings.setBounds(292, 181, 140, 25); panel_1.add(btnSaveSearchSettings); JButton btnLoadSettings = new JButton("Load Settings"); btnLoadSettings.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { if (!cf.loadObject()) cf.setDefaultSettings(); cacheUpdateGUISettings(); } }); btnLoadSettings.setBounds(148, 181, 140, 25); panel_1.add(btnLoadSettings); JButton btnDefaultSettings = new JButton("Use Default Settings"); btnDefaultSettings.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { cf.setDefaultSettings(); cacheUpdateGUISettings(); } }); btnDefaultSettings.setBounds(4, 181, 140, 25); panel_1.add(btnDefaultSettings); // ------------------------------------------------------------------- // ----------------------- JPanel_2 Components ----------------------- JLabel labelStatus = new JLabel("Progress"); labelStatus.setBounds(10, 187, 54, 14); panel_2.add(labelStatus); JButton btnStart = new JButton("Start"); btnStart.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { pollSearchSettings(); if (!ran_at_least_once) ran_at_least_once = true; else { SentinelProgressBar.setValue(0); SentinelProgressLabel.setText("Waiting..."); } try { if (multiSelection == null) { JOptionPane.showMessageDialog(btnStart, "Please enter at least one directory.", "Press OK to continue", JOptionPane.PLAIN_MESSAGE); return; } setSourceDirectory(multiSelection); GUI_Start = true; } catch (Exception err) { err.printStackTrace(); } } }); btnStart.setBounds(40, 153, 89, 23); panel_2.add(btnStart); JButton btnStop = new JButton("Stop"); btnStop.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { GUI_Stop = true; } }); btnStop.setBounds(169, 153, 89, 23); panel_2.add(btnStop); JButton btnNewButton = new JButton("Pause"); btnNewButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { GUI_Pause = true; } }); btnNewButton.setBounds(298, 153, 89, 23); panel_2.add(btnNewButton); JCheckBox chckbxDeleteDuplicateFiles = new JCheckBox("Delete duplicate files"); chckbxDeleteDuplicateFiles.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { deleteCopyResults = true; } }); chckbxDeleteDuplicateFiles.setBounds(230, 10, 150, 16); panel_2.add(chckbxDeleteDuplicateFiles); JCheckBox chckbxLogDuplicateFiles = new JCheckBox("Save duplicates to file"); chckbxLogDuplicateFiles.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { saveCopyResults = true; } }); chckbxLogDuplicateFiles.setBounds(230, 36, 150, 16); panel_2.add(chckbxLogDuplicateFiles); // ------------------------------------------------------------------- // ----------------------- JPanel_3 Components ----------------------- JLabel lblAbout = new JLabel("About"); GridBagConstraints gbc_lblAbout = new GridBagConstraints(); gbc_lblAbout.insets = new Insets(0, 0, 5, 5); gbc_lblAbout.gridx = 0; gbc_lblAbout.gridy = 0; panel_3.add(lblAbout, gbc_lblAbout); JLabel lblTutorials = new JLabel("Tutorials"); GridBagConstraints gbc_lblTutorials = new GridBagConstraints(); gbc_lblTutorials.insets = new Insets(0, 0, 5, 5); gbc_lblTutorials.gridx = 1; gbc_lblTutorials.gridy = 0; panel_3.add(lblTutorials, gbc_lblTutorials); JLabel lblUpdates = new JLabel("Updates"); GridBagConstraints gbc_lblUpdates = new GridBagConstraints(); gbc_lblUpdates.insets = new Insets(0, 0, 5, 0); gbc_lblUpdates.gridx = 2; gbc_lblUpdates.gridy = 0; panel_3.add(lblUpdates, gbc_lblUpdates); JButton btnInformation = new JButton("Information"); btnInformation.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { openWebPage(ppallink); } }); GridBagConstraints gbc_btnInformation = new GridBagConstraints(); gbc_btnInformation.insets = new Insets(0, 0, 0, 5); gbc_btnInformation.gridx = 0; gbc_btnInformation.gridy = 1; panel_3.add(btnInformation, gbc_btnInformation); JButton btnExamples = new JButton("Examples"); btnExamples.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { openWebPage(ppallink); } }); GridBagConstraints gbc_btnExamples = new GridBagConstraints(); gbc_btnExamples.insets = new Insets(0, 0, 0, 5); gbc_btnExamples.gridx = 1; gbc_btnExamples.gridy = 1; panel_3.add(btnExamples, gbc_btnExamples); JButton btnCheckNow = new JButton("Check Now"); btnCheckNow.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { openWebPage(ppallink); } }); GridBagConstraints gbc_btnCheckNow = new GridBagConstraints(); gbc_btnCheckNow.gridx = 2; gbc_btnCheckNow.gridy = 1; panel_3.add(btnCheckNow, gbc_btnCheckNow); }
From source file:net.pandoragames.far.ui.swing.FindFilePanel.java
private void initFileNamePatternPanel(SwingConfig config, ComponentRepository componentRepository) { JLabel labelPattern = new JLabel(localizer.localize("label.file-name-pattern")); labelPattern.setAlignmentX(Component.LEFT_ALIGNMENT); this.add(labelPattern); listPattern = new JComboBox(config.getFileNamePatternListModel()); listPattern.setEditable(true);//w w w . jav a 2s.co m listPattern .setMaximumSize(new Dimension(SwingConfig.COMPONENT_WIDTH_MAX, config.getStandardComponentHight())); JButton buttonSavePattern = new JButton(localizer.localize("button.save-pattern")); buttonSavePattern.setEnabled(false); TwoComponentsPanel linePattern = new TwoComponentsPanel(listPattern, buttonSavePattern); linePattern.setAlignmentX(Component.LEFT_ALIGNMENT); this.add(linePattern); patternFlag = new JCheckBox(localizer.localize("label.regular-expression")); patternFlag.setAlignmentX(Component.LEFT_ALIGNMENT); patternFlag.setSelected(dataModel.getFileNamePattern().isRegex()); patternFlag.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent event) { dataModel.getFileNamePattern().setRegex((ItemEvent.SELECTED == event.getStateChange())); } }); patternFlag.addItemListener(componentRepository.getSearchBaseListener()); browseButtonListener.setRegexCheckBox(patternFlag); browseButtonListener.addComponentToBeDisabledForSingleFiles(patternFlag); componentRepository.getSearchBaseListener().addToBeEnabled(patternFlag); componentRepository.getResetDispatcher().addToBeEnabled(patternFlag); listPattern.addActionListener(new PatternListListener(patternFlag, componentRepository.getMessageBox())); listPattern.addActionListener(componentRepository.getSearchBaseListener()); ComboBoxEditor comboBoxEditor = new FileNamePatternEditor(buttonSavePattern); listPattern.setEditor(comboBoxEditor); browseButtonListener.setComboBox(listPattern); browseButtonListener.addComponentToBeDisabledForSingleFiles(listPattern); componentRepository.getSearchBaseListener().addToBeEnabled(listPattern); componentRepository.getResetDispatcher().addToBeEnabled(listPattern); buttonSavePattern.addActionListener( new SaveFileNamePatternListener(listPattern, patternFlag, config, componentRepository)); this.add(patternFlag); datePanel = new DateRestrictionPanel(dataModel, componentRepository, config); componentRepository.getResetDispatcher().addResetable(datePanel); datePanel.setAlignmentX(Component.LEFT_ALIGNMENT); this.add(datePanel); this.add(Box.createRigidArea(new Dimension(1, SwingConfig.PADDING))); this.add(Box.createVerticalGlue()); }
From source file:com.net2plan.gui.utils.onlineSimulationPane.OnlineSimulationPane.java
private JPanel configureSimulationControlPanel() { pan_simulationController = new JPanel(new MigLayout("fill, insets 0 0 0 0")); pan_simulationController//from w w w.ja v a2s . com .setBorder(BorderFactory.createTitledBorder(new LineBorder(Color.BLACK), "Simulation controller")); simInfo = new JTextArea(); simInfo.setFont(new JLabel().getFont()); DefaultCaret caret = (DefaultCaret) simInfo.getCaret(); caret.setUpdatePolicy(DefaultCaret.NEVER_UPDATE); toolbar = new JToolBar(); btn_run = new JButton("Run"); btn_run.addActionListener(this); btn_run.setToolTipText("Execute the simulation [CTRL + U]"); btn_step = new JButton("Step"); btn_step.addActionListener(this); btn_step.setToolTipText("Execute the next scheduled event and pause"); btn_pause = new JButton("Pause/Continue"); btn_pause.addActionListener(this); btn_pause.setToolTipText("Pause the simulation (if active) or continue (if paused)"); btn_stop = new JButton("Stop"); btn_stop.addActionListener(this); btn_stop.setToolTipText("Stop the simulation (it cannot be resumed later)"); btn_reset = new JButton("Reset"); btn_reset.addActionListener(this); btn_reset.setToolTipText( "After stopping the simulation, resets the design to the initial simulation design"); chk_refresh = new JCheckBox("Refresh"); chk_refresh.setSelected(true); btn_viewEventList = new JButton("View FEL"); btn_viewEventList.setToolTipText("View future event list (FEL)"); btn_viewEventList.addActionListener(this); toolbar.setFloatable(false); toolbar.setRollover(true); toolbar.add(btn_run); toolbar.add(btn_step); toolbar.add(btn_pause); toolbar.add(btn_stop); toolbar.add(btn_reset); toolbar.addSeparator(); toolbar.add(chk_refresh); toolbar.add(Box.createHorizontalGlue()); toolbar.add(btn_viewEventList); pan_simulationController.add(toolbar, "dock north"); pan_simulationController.add(new JScrollPane(simInfo), "grow"); return pan_simulationController; }
From source file:com.floreantpos.ui.model.MenuItemForm.java
/** This method is called from within the constructor to * initialize the form./*w w w . j a v a 2s .c o m*/ * 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() { lblStockCount = new JLabel(Messages.getString("MenuItemForm.17")); //$NON-NLS-1$ tfStockCount = new DoubleTextField(1); cbDisableStockCount = new JCheckBox(Messages.getString("MenuItemForm.18")); //$NON-NLS-1$ lblButtonColor = new JLabel(Messages.getString("MenuItemForm.19")); //$NON-NLS-1$ tabbedPane = new javax.swing.JTabbedPane(); tabGeneral = new javax.swing.JPanel(); lfname = new javax.swing.JLabel(); lfname.setHorizontalAlignment(SwingConstants.TRAILING); tfName = new com.floreantpos.swing.FixedLengthTextField(20); lgroup = new javax.swing.JLabel(); lgroup.setHorizontalAlignment(SwingConstants.TRAILING); cbGroup = new javax.swing.JComboBox(); cbGroup.setPreferredSize(new Dimension(198, 0)); btnNewGroup = new javax.swing.JButton(); lblPrice = new javax.swing.JLabel(); lblPrice.setHorizontalAlignment(SwingConstants.TRAILING); tfPrice = new DoubleTextField(20); tfPrice.setHorizontalAlignment(javax.swing.JTextField.RIGHT); tfDescription = new JTextArea(new FixedLengthDocument(255)); //tfDescription.setDocument(; tfUnitName = new FixedLengthTextField(20); lTax = new javax.swing.JLabel(); lTax.setHorizontalAlignment(SwingConstants.TRAILING); cbTax = new javax.swing.JComboBox(); btnNewTax = new javax.swing.JButton(); lDiscountRate = new javax.swing.JLabel(); lDiscountRate.setHorizontalAlignment(SwingConstants.TRAILING); lPercentage = new javax.swing.JLabel(); tfDiscountRate = new DoubleTextField(18); tfDiscountRate.setHorizontalAlignment(SwingConstants.TRAILING); chkVisible = new javax.swing.JCheckBox(); tabModifier = new javax.swing.JPanel(); btnNewModifierGroup = new javax.swing.JButton(); btnDeleteModifierGroup = new javax.swing.JButton(); btnEditModifierGroup = new javax.swing.JButton(); jScrollPane1 = new javax.swing.JScrollPane(); tableTicketItemModifierGroups = new javax.swing.JTable(); tabShift = new javax.swing.JPanel(); tabPrice = new javax.swing.JPanel(); tabButtonStyle = new javax.swing.JPanel(); btnDeleteShift = new javax.swing.JButton(); btnAddShift = new javax.swing.JButton(); btnNewPrice = new javax.swing.JButton(); btnUpdatePrice = new javax.swing.JButton(); btnDeletePrice = new javax.swing.JButton(); btnDeleteAll = new javax.swing.JButton(); btnDefaultValue = new javax.swing.JButton(); jScrollPane2 = new javax.swing.JScrollPane(); jScrollPane3 = new javax.swing.JScrollPane(); shiftTable = new javax.swing.JTable(); priceTable = new javax.swing.JTable(); cbPrinterGroup = new JComboBox<PrinterGroup>(new DefaultComboBoxModel<PrinterGroup>( PrinterGroupDAO.getInstance().findAll().toArray(new PrinterGroup[0]))); cbPrinterGroup.setPreferredSize(new Dimension(226, 0)); tfTranslatedName = new FixedLengthTextField(20); tfTranslatedName.setLength(120); lblUnitName = new JLabel(Messages.getString("MenuItemForm.23")); //$NON-NLS-1$ lblKitchenPrinter = new JLabel(Messages.getString("MenuItemForm.27")); //$NON-NLS-1$ lgroup.setText(Messages.getString("LABEL_GROUP")); //$NON-NLS-1$ lfname.setText(Messages.getString("LABEL_NAME")); //$NON-NLS-1$ tfName.setLength(120); lblTranslatedName = new JLabel(Messages.getString("MenuItemForm.lblTranslatedName.text")); //$NON-NLS-1$ tfBarcode = new FixedLengthTextField(20); tfSortOrder = new IntegerTextField(20); lblSortOrder = new JLabel(Messages.getString("MenuItemForm.lblSortOrder.text")); //$NON-NLS-1$ tfSortOrder.setText(""); //$NON-NLS-1$ lblBarcode = new JLabel(Messages.getString("MenuItemForm.lblBarcode.text")); //$NON-NLS-1$ cbTax.setPreferredSize(new Dimension(198, 0)); ///lblButtonColor = new JLabel(Messages.getString("MenuItemForm.lblButtonColor.text")); //$NON-NLS-1$ btnButtonColor = new JButton(); //$NON-NLS-1$ btnButtonColor.setPreferredSize(new Dimension(228, 40)); lblTextColor = new JLabel(Messages.getString("MenuItemForm.lblTextColor.text")); //$NON-NLS-1$ btnTextColor = new JButton(Messages.getString("MenuItemForm.SAMPLE_TEXT")); //$NON-NLS-1$ // btnTextColor.setPreferredSize(new Dimension(228, 40)); cbShowTextWithImage = new JCheckBox(Messages.getString("MenuItemForm.40")); //$NON-NLS-1$ cbShowTextWithImage.setActionCommand(Messages.getString("MenuItemForm.41")); //$NON-NLS-1$ lTax.setText(Messages.getString("LABEL_TAX")); //$NON-NLS-1$ btnNewTax.setText("..."); //$NON-NLS-1$ cbFractionalUnit = new JCheckBox(Messages.getString("MenuItemForm.24")); //$NON-NLS-1$ btnNewGroup.setText("..."); //$NON-NLS-1$ btnNewGroup.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { doCreateNewGroup(evt); } }); if (Application.getInstance().isPriceIncludesTax()) { lblPrice.setText(Messages.getString("LABEL_SALES_PRICE_INCLUDING_TAX")); //$NON-NLS-1$ } else { lblPrice.setText(Messages.getString("LABEL_SALES_PRICE_EXCLUDING_TAX")); //$NON-NLS-1$ } tfPrice.setHorizontalAlignment(javax.swing.JTextField.RIGHT); lTax.setText(Messages.getString("LABEL_TAX")); //$NON-NLS-1$ btnNewTax.setText("..."); //$NON-NLS-1$ btnNewTax.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnNewTaxdoCreateNewTax(evt); } }); lDiscountRate.setText(com.floreantpos.POSConstants.DISCOUNT_RATE + ":"); //$NON-NLS-1$ lPercentage.setText("%"); //$NON-NLS-1$ chkVisible.setText(com.floreantpos.POSConstants.VISIBLE); chkVisible.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); chkVisible.setMargin(new java.awt.Insets(0, 0, 0, 0)); tabbedPane.addTab(com.floreantpos.POSConstants.GENERAL, tabGeneral); tabbedPane.setPreferredSize(new Dimension(750, 470)); btnNewModifierGroup.setText(com.floreantpos.POSConstants.ADD); btnNewModifierGroup.setActionCommand("AddModifierGroup"); //$NON-NLS-1$ btnNewModifierGroup.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnNewModifierGroupActionPerformed(evt); } }); btnDeleteModifierGroup.setText(com.floreantpos.POSConstants.DELETE); btnDeleteModifierGroup.setActionCommand("DeleteModifierGroup"); //$NON-NLS-1$ btnEditModifierGroup.setText(com.floreantpos.POSConstants.EDIT); btnEditModifierGroup.setActionCommand("EditModifierGroup"); //$NON-NLS-1$ menuItemMGListModel = new MenuItemMGListModel(); tableTicketItemModifierGroups.setModel(menuItemMGListModel); btnNewModifierGroup.addActionListener(this); btnEditModifierGroup.addActionListener(this); btnDeleteModifierGroup.addActionListener(this); btnAddShift.addActionListener(this); btnDeleteShift.addActionListener(this); tfDiscountRate.setDocument(new DoubleDocument()); tabGeneral.setLayout(new MigLayout("insets 20", "[][]20px[][]", "[][][][][][][][][][][][][]")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ /*JLabel lblImage = new JLabel(Messages.getString("MenuItemForm.28")); //$NON-NLS-1$ lblImage.setHorizontalAlignment(SwingConstants.TRAILING); tabGeneral.add(lblImage, "cell 0 0,right"); //$NON-NLS-1$ lblImagePreview = new JLabel(""); //$NON-NLS-1$ lblImagePreview.setHorizontalAlignment(JLabel.CENTER); lblImagePreview.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null)); lblImagePreview.setPreferredSize(new Dimension(100, 100)); tabGeneral.add(lblImagePreview, "cell 1 0"); //$NON-NLS-1$ JButton btnSelectImage = new JButton("..."); //$NON-NLS-1$ btnSelectImage.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { doSelectImageFile(); } }); tabGeneral.add(btnSelectImage, "cell 1 0"); //$NON-NLS-1$ btnClearImage = new JButton(Messages.getString("MenuItemForm.34")); //$NON-NLS-1$ btnClearImage.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { doClearImage(); } }); tabGeneral.add(btnClearImage, "cell 1 0"); //$NON-NLS-1$ */ tabGeneral.add(lfname, "cell 0 1 ,right"); //$NON-NLS-1$ tabGeneral.add(tfName, "cell 1 1,grow"); //$NON-NLS-1$ tabGeneral.add(lblTranslatedName, "cell 0 2,right"); //$NON-NLS-1$ tabGeneral.add(tfTranslatedName, "cell 1 2,grow"); //$NON-NLS-1$ /*tabGeneral.add(new JLabel("Description"), "cell 0 3,right"); JScrollPane scrlDescription = new JScrollPane(tfDescription, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); tabGeneral.add(scrlDescription, "cell 1 3");*/ tabGeneral.add(lblUnitName, "cell 0 3,right"); //$NON-NLS-1$ tabGeneral.add(tfUnitName, "cell 1 3,grow"); //$NON-NLS-1$ JLabel lblBuyPrice = new JLabel(Messages.getString("LABEL_BUY_PRICE")); //$NON-NLS-1$ tabGeneral.add(lblBuyPrice, "cell 0 4,alignx right"); //$NON-NLS-1$ tfBuyPrice = new DoubleTextField(20); tfBuyPrice.setHorizontalAlignment(SwingConstants.TRAILING); tabGeneral.add(tfBuyPrice, "cell 1 4,grow"); //$NON-NLS-1$ tabGeneral.add(lblPrice, "cell 0 5,alignx right"); //$NON-NLS-1$ tabGeneral.add(tfPrice, "cell 1 5,grow"); //$NON-NLS-1$ tabGeneral.add(lgroup, "cell 0 6,alignx right"); //$NON-NLS-1$ tabGeneral.add(cbGroup, "cell 1 6"); //$NON-NLS-1$ tabGeneral.add(btnNewGroup, "cell 1 6"); //$NON-NLS-1$ tabGeneral.add(lblBarcode, "cell 0 7,alignx right"); //$NON-NLS-1$ tabGeneral.add(tfBarcode, "cell 1 7,grow"); //$NON-NLS-1$ tabGeneral.add(lblSortOrder, "cell 0 8,alignx right"); //$NON-NLS-1$ tabGeneral.add(tfSortOrder, "cell 1 8,grow"); //$NON-NLS-1$ tabGeneral.add(lblStockCount, "cell 0 9,alignx right"); //$NON-NLS-1$ tabGeneral.add(tfStockCount, "cell 1 9,grow"); //$NON-NLS-1$ //tabGeneral.add(cbShowTextWithImage, "cell 1 8"); //$NON-NLS-1$ tabGeneral.add(chkVisible, "cell 1 10"); //$NON-NLS-1$ tabGeneral.add(cbFractionalUnit, "cell 1 11"); //$NON-NLS-1$ tabGeneral.add(cbDisableStockCount, "cell 1 12"); //$NON-NLS-1$ // right side tabGeneral.add(lblKitchenPrinter, "cell 2 1,right"); //$NON-NLS-1$ tabGeneral.add(cbPrinterGroup, "cell 3 1,grow"); //$NON-NLS-1$ tabGeneral.add(lTax, "cell 2 2,right"); //$NON-NLS-1$ tabGeneral.add(cbTax, "cell 3 2"); //$NON-NLS-1$ tabGeneral.add(btnNewTax, "cell 3 2,grow"); //$NON-NLS-1$ /*tabGeneral.add(lblButtonColor, "cell 2 3,right"); //$NON-NLS-1$ tabGeneral.add(btnButtonColor, "cell 3 3,grow"); //$NON-NLS-1$ tabGeneral.add(lblTextColor, "cell 2 4,right"); //$NON-NLS-1$ tabGeneral.add(btnTextColor, "cell 3 4 3 5"); //$NON-NLS-1$ btnTextColor.setPreferredSize(new Dimension(228, 50));*/ tabGeneral.add(new JLabel(Messages.getString("MenuItemForm.25")), "cell 2 3,,aligny top,alignx right"); //$NON-NLS-1$ //$NON-NLS-2$ orderList = new CheckBoxList(); List<OrderType> orderTypes = Application.getInstance().getOrderTypes(); orderList.setModel(orderTypes); // List<String> orderListM = new ArrayList(); // orderListM.add(OrderType.DINE_IN.toString()); // orderListM.add(OrderType.BAR_TAB.toString()); // orderListM.add(OrderType.DRIVE_THRU.toString()); // orderListM.add(OrderType.HOME_DELIVERY.toString()); // orderListM.add(OrderType.PICKUP.toString()); // orderListM.add(OrderType.RETAIL.toString()); // orderListM.add(OrderType.TAKE_OUT.toString()); // orderList.setModel(orderListM); JScrollPane orderCheckBoxList = new JScrollPane(orderList); orderCheckBoxList.setPreferredSize(new Dimension(228, 100)); tabGeneral.add(orderCheckBoxList, "cell 3 3 3 4"); //$NON-NLS-1$ tfDescription.setWrapStyleWord(true); tfDescription.setLineWrap(true); tabGeneral.add(new JLabel(Messages.getString("MenuItemForm.29")), "cell 2 7,aligny top,alignx right"); //$NON-NLS-1$ //$NON-NLS-2$ JScrollPane scrlDescription = new JScrollPane(tfDescription, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); scrlDescription.setPreferredSize(new Dimension(228, 90)); tabGeneral.add(scrlDescription, "cell 3 7 3 4"); //$NON-NLS-1$ add(tabbedPane); //TODO: addRecepieExtension(); /*btnButtonColor.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Color color = JColorChooser.showDialog(MenuItemForm.this, Messages.getString("MenuItemForm.42"), btnButtonColor.getBackground()); //$NON-NLS-1$ btnButtonColor.setBackground(color); btnTextColor.setBackground(color); } }); btnTextColor.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Color color = JColorChooser.showDialog(MenuItemForm.this, Messages.getString("MenuItemForm.43"), btnTextColor.getForeground()); //$NON-NLS-1$ btnTextColor.setForeground(color); } });*/ jScrollPane1.setViewportView(tableTicketItemModifierGroups); GroupLayout jPanel2Layout = new GroupLayout(tabModifier); jPanel2Layout.setVerticalGroup(jPanel2Layout.createParallelGroup(Alignment.TRAILING) .addGroup(jPanel2Layout.createSequentialGroup().addContainerGap() .addComponent(jScrollPane1, GroupLayout.DEFAULT_SIZE, 412, Short.MAX_VALUE) .addPreferredGap(ComponentPlacement.RELATED) .addGroup(jPanel2Layout.createParallelGroup(Alignment.BASELINE) .addComponent(btnDeleteModifierGroup).addComponent(btnEditModifierGroup) .addComponent(btnNewModifierGroup)) .addContainerGap())); jPanel2Layout.setHorizontalGroup(jPanel2Layout.createParallelGroup(Alignment.TRAILING) .addGroup(jPanel2Layout.createSequentialGroup().addContainerGap().addGroup(jPanel2Layout .createParallelGroup(Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup().addComponent(btnNewModifierGroup) .addPreferredGap(ComponentPlacement.RELATED).addComponent(btnEditModifierGroup) .addPreferredGap(ComponentPlacement.RELATED).addComponent(btnDeleteModifierGroup)) .addComponent(jScrollPane1, GroupLayout.DEFAULT_SIZE, 421, Short.MAX_VALUE)) .addContainerGap())); tabModifier.setLayout(jPanel2Layout); tabbedPane.addTab(com.floreantpos.POSConstants.MODIFIER_GROUPS, tabModifier); btnDeleteShift.setText(com.floreantpos.POSConstants.DELETE_SHIFT); btnAddShift.setText(com.floreantpos.POSConstants.ADD_SHIFT); shiftTable .setModel(new javax.swing.table.DefaultTableModel( new Object[][] { { null, null, null, null }, { null, null, null, null }, { null, null, null, null }, { null, null, null, null } }, new String[] { "Title 1", "Title 2", "Title 3", "Title 4" })); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ jScrollPane2.setViewportView(shiftTable); org.jdesktop.layout.GroupLayout jPanel3Layout = new org.jdesktop.layout.GroupLayout(tabShift); tabShift.setLayout(jPanel3Layout); jPanel3Layout .setHorizontalGroup(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jPanel3Layout.createSequentialGroup().addContainerGap(76, Short.MAX_VALUE) .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(org.jdesktop.layout.GroupLayout.TRAILING, jScrollPane2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 670, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel3Layout.createSequentialGroup().add(btnAddShift).add(5, 5, 5) .add(btnDeleteShift))) .addContainerGap())); jPanel3Layout.setVerticalGroup(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jPanel3Layout.createSequentialGroup() .add(jScrollPane2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 345, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(btnAddShift).add(btnDeleteShift)) .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); tabbedPane.addTab(com.floreantpos.POSConstants.SHIFTS, tabShift); // btnNewPrice.setText(Messages.getString("MenuItemForm.9")); //$NON-NLS-1$ btnNewPrice.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { addNewPrice(); } }); btnUpdatePrice.setText(Messages.getString("MenuItemForm.13")); //$NON-NLS-1$ btnUpdatePrice.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { updatePrice(); } }); btnDeletePrice.setText(Messages.getString("MenuItemForm.14")); //$NON-NLS-1$ btnDeletePrice.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { deletePrice(); } }); btnDeleteAll.setText(Messages.getString("MenuItemForm.15")); //$NON-NLS-1$ btnDeleteAll.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { deleteAll(); } }); btnDefaultValue.setText(Messages.getString("MenuItemForm.7")); //$NON-NLS-1$ /*btnDefaultValue.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { setDefaultValue(); } });*/ priceTable .setModel(new javax.swing.table.DefaultTableModel( new Object[][] { { null, null, null, null }, { null, null, null, null }, { null, null, null, null }, { null, null, null, null } }, new String[] { "Title 1", "Title 2", "Title 3", "Title 4" })); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ jScrollPane3.setViewportView(priceTable); tabPrice.setLayout(new BorderLayout()); tabPrice.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); tabPrice.add(jScrollPane3, BorderLayout.CENTER); JPanel buttonPanel = new JPanel(); buttonPanel.add(btnNewPrice); buttonPanel.add(btnUpdatePrice); //buttonPanel.add(btnDefaultValue); buttonPanel.add(btnDeletePrice); // buttonPanel.add(btnDeleteAll); tabPrice.add(buttonPanel, BorderLayout.SOUTH); tabbedPane.addTab(Messages.getString("MenuItemForm.16"), tabPrice); //$NON-NLS-1$ // tabbedPane.addChangeListener(this); // tabButtonStyle.setLayout(new MigLayout("insets 10", "[][]100[][][][]", "[][][center][][][]")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ JLabel lblImage = new JLabel(Messages.getString("MenuItemForm.28")); //$NON-NLS-1$ lblImage.setHorizontalAlignment(SwingConstants.TRAILING); tabButtonStyle.add(lblImage, "cell 0 0,right"); //$NON-NLS-1$ lblImagePreview = new JLabel(""); //$NON-NLS-1$ lblImagePreview.setHorizontalAlignment(JLabel.CENTER); lblImagePreview.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null)); lblImagePreview.setPreferredSize(new Dimension(100, 100)); tabButtonStyle.add(lblImagePreview, "cell 1 0"); //$NON-NLS-1$ JButton btnSelectImage = new JButton("..."); //$NON-NLS-1$ btnClearImage = new JButton(Messages.getString("MenuItemForm.34")); //$NON-NLS-1$ tabButtonStyle.add(btnClearImage, "cell 1 0"); //$NON-NLS-1$ tabButtonStyle.add(btnSelectImage, "cell 1 0"); //$NON-NLS-1$ tabButtonStyle.add(lblButtonColor, "cell 0 2,right"); //$NON-NLS-1$ tabButtonStyle.add(btnButtonColor, "cell 1 2,grow"); //$NON-NLS-1$ tabButtonStyle.add(lblTextColor, "cell 0 3,right"); //$NON-NLS-1$ tabButtonStyle.add(btnTextColor, "cell 1 3"); //$NON-NLS-1$ tabButtonStyle.add(cbShowTextWithImage, "cell 1 4"); //$NON-NLS-1$ /* tabButtonStyle.add(lblImagePreview, "cell 3 0 3 4"); //$NON-NLS-1$ tabButtonStyle.add(btnClearImage, "cell 3 0,gaptop 40"); //$NON-NLS-1$ tabButtonStyle.add(btnSelectImage, "cell 3 0,gaptop 40"); //$NON-NLS-1$ tabButtonStyle.add(lblImage, "cell 2 0,gaptop 40"); //$NON-NLS-1$ tabButtonStyle.add(lblButtonColor, "cell 0 0,right"); //$NON-NLS-1$ tabButtonStyle.add(btnButtonColor, "cell 1 0,grow"); //$NON-NLS-1$ tabButtonStyle.add(lblTextColor, "cell 0 1,right"); //$NON-NLS-1$ tabButtonStyle.add(btnTextColor, "cell 1 1"); //$NON-NLS-1$ */ btnTextColor.setPreferredSize(new Dimension(228, 50)); btnSelectImage.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { doSelectImageFile(); } }); btnClearImage.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { doClearImage(); } }); btnButtonColor.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Color color = JColorChooser.showDialog(MenuItemForm.this, Messages.getString("MenuItemForm.42"), //$NON-NLS-1$ btnButtonColor.getBackground()); btnButtonColor.setBackground(color); btnTextColor.setBackground(color); } }); btnTextColor.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Color color = JColorChooser.showDialog(MenuItemForm.this, Messages.getString("MenuItemForm.43"), //$NON-NLS-1$ btnTextColor.getForeground()); btnTextColor.setForeground(color); } }); tabbedPane.addTab(Messages.getString("MenuItemForm.26"), tabButtonStyle); //$NON-NLS-1$ }
From source file:edu.uci.ics.jung.samples.PerspectiveVertexImageShaperDemo.java
/** * create an instance of a simple graph with controls to * demo the zoom features./*from w w w . j a v a 2 s . c o m*/ * */ @SuppressWarnings("serial") public PerspectiveVertexImageShaperDemo() { // create a simple graph for the demo graph = new DirectedSparseMultigraph<Number, Number>(); Number[] vertices = createVertices(11); // a Map for the labels Map<Number, String> map = new HashMap<Number, String>(); for (int i = 0; i < vertices.length; i++) { map.put(vertices[i], iconNames[i % iconNames.length]); } // a Map for the Icons Map<Number, Icon> iconMap = new HashMap<Number, Icon>(); for (int i = 0; i < vertices.length; i++) { String name = "/images/topic" + iconNames[i] + ".gif"; try { Icon icon = new LayeredIcon( new ImageIcon(PerspectiveVertexImageShaperDemo.class.getResource(name)).getImage()); iconMap.put(vertices[i], icon); } catch (Exception ex) { System.err.println("You need slashdoticons.jar in your classpath to see the image " + name); } } createEdges(vertices); final VertexStringerImpl<Number> vertexStringerImpl = new VertexStringerImpl<Number>(map); final VertexIconShapeTransformer<Number> vertexImageShapeFunction = new VertexIconShapeTransformer<Number>( new EllipseVertexShapeTransformer<Number>()); FRLayout<Number, Number> layout = new FRLayout<Number, Number>(graph); layout.setMaxIterations(100); vv = new VisualizationViewer<Number, Number>(layout, new Dimension(400, 400)); vv.setBackground(Color.decode("0xffffdd")); final DefaultVertexIconTransformer<Number> vertexIconFunction = new DefaultVertexIconTransformer<Number>(); vertexImageShapeFunction.setIconMap(iconMap); vertexIconFunction.setIconMap(iconMap); vv.getRenderContext().setVertexShapeTransformer(vertexImageShapeFunction); vv.getRenderContext().setVertexIconTransformer(vertexIconFunction); vv.getRenderContext().setVertexLabelTransformer(vertexStringerImpl); PickedState<Number> ps = vv.getPickedVertexState(); ps.addItemListener(new PickWithIconListener(vertexIconFunction)); vv.addPostRenderPaintable(new VisualizationServer.Paintable() { int x; int y; Font font; FontMetrics metrics; int swidth; int sheight; String str = "Thank You, slashdot.org, for the images!"; public void paint(Graphics g) { Dimension d = vv.getSize(); if (font == null) { font = new Font(g.getFont().getName(), Font.BOLD, 20); metrics = g.getFontMetrics(font); swidth = metrics.stringWidth(str); sheight = metrics.getMaxAscent() + metrics.getMaxDescent(); x = (d.width - swidth) / 2; y = (int) (d.height - sheight * 1.5); } g.setFont(font); Color oldColor = g.getColor(); g.setColor(Color.lightGray); g.drawString(str, x, y); g.setColor(oldColor); } public boolean useTransform() { return false; } }); // add a listener for ToolTips vv.setVertexToolTipTransformer(new ToStringLabeller<Number>()); Container content = getContentPane(); final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv); content.add(panel); final DefaultModalGraphMouse<Number, Number> graphMouse = new DefaultModalGraphMouse<Number, Number>(); vv.setGraphMouse(graphMouse); this.viewSupport = new PerspectiveImageLensSupport<Number, Number>(vv); this.layoutSupport = new PerspectiveLayoutTransformSupport<Number, Number>(vv); final ScalingControl scaler = new CrossoverScalingControl(); JButton plus = new JButton("+"); plus.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1.1f, vv.getCenter()); } }); JButton minus = new JButton("-"); minus.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { scaler.scale(vv, 0.9f, vv.getCenter()); } }); final JSlider horizontalSlider = new JSlider(-120, 120, 0) { /* (non-Javadoc) * @see javax.swing.JComponent#getPreferredSize() */ @Override public Dimension getPreferredSize() { return new Dimension(80, super.getPreferredSize().height); } }; final JSlider verticalSlider = new JSlider(-120, 120, 0) { /* (non-Javadoc) * @see javax.swing.JComponent#getPreferredSize() */ @Override public Dimension getPreferredSize() { return new Dimension(super.getPreferredSize().width, 80); } }; verticalSlider.setOrientation(JSlider.VERTICAL); final ChangeListener changeListener = new ChangeListener() { public void stateChanged(ChangeEvent e) { int vval = -verticalSlider.getValue(); int hval = horizontalSlider.getValue(); Dimension d = vv.getSize(); PerspectiveTransform pt = null; pt = PerspectiveTransform.getQuadToQuad(vval, hval, d.width - vval, -hval, d.width + vval, d.height + hval, -vval, d.height - hval, 0, 0, d.width, 0, d.width, d.height, 0, d.height); viewSupport.getPerspectiveTransformer().setPerspectiveTransform(pt); layoutSupport.getPerspectiveTransformer().setPerspectiveTransform(pt); vv.repaint(); } }; horizontalSlider.addChangeListener(changeListener); verticalSlider.addChangeListener(changeListener); JPanel perspectivePanel = new JPanel(new BorderLayout()); JPanel perspectiveCenterPanel = new JPanel(new BorderLayout()); perspectivePanel.setBorder(BorderFactory.createTitledBorder("Perspective Controls")); final JButton center = new JButton("Center"); center.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { horizontalSlider.setValue(0); verticalSlider.setValue(0); } }); final JCheckBox noText = new JCheckBox("No Text"); noText.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { JCheckBox cb = (JCheckBox) e.getSource(); vertexStringerImpl.setEnabled(!cb.isSelected()); vv.repaint(); } }); JPanel centerPanel = new JPanel(); centerPanel.add(noText); ButtonGroup radio = new ButtonGroup(); JRadioButton none = new JRadioButton("None"); none.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { boolean selected = e.getStateChange() == ItemEvent.SELECTED; if (selected) { if (viewSupport != null) { viewSupport.deactivate(); } if (layoutSupport != null) { layoutSupport.deactivate(); } } center.setEnabled(!selected); horizontalSlider.setEnabled(!selected); verticalSlider.setEnabled(!selected); } }); none.setSelected(true); JRadioButton hyperView = new JRadioButton("View"); hyperView.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { viewSupport.activate(e.getStateChange() == ItemEvent.SELECTED); } }); JRadioButton hyperModel = new JRadioButton("Layout"); hyperModel.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { layoutSupport.activate(e.getStateChange() == ItemEvent.SELECTED); } }); radio.add(none); radio.add(hyperView); radio.add(hyperModel); JMenuBar menubar = new JMenuBar(); JMenu modeMenu = graphMouse.getModeMenu(); menubar.add(modeMenu); panel.setCorner(menubar); JPanel scaleGrid = new JPanel(new GridLayout(2, 0)); scaleGrid.setBorder(BorderFactory.createTitledBorder("Zoom")); JPanel controls = new JPanel(new BorderLayout()); scaleGrid.add(plus); scaleGrid.add(minus); controls.add(scaleGrid, BorderLayout.WEST); JPanel lensPanel = new JPanel(new GridLayout(2, 0)); lensPanel.add(none); lensPanel.add(hyperView); lensPanel.add(hyperModel); perspectivePanel.add(lensPanel, BorderLayout.WEST); perspectiveCenterPanel.add(horizontalSlider, BorderLayout.SOUTH); perspectivePanel.add(verticalSlider, BorderLayout.EAST); perspectiveCenterPanel.add(center); perspectivePanel.add(perspectiveCenterPanel); controls.add(perspectivePanel, BorderLayout.EAST); controls.add(centerPanel); content.add(controls, BorderLayout.SOUTH); }
From source file:gov.nij.er.ui.EntityResolutionDemo.java
private void createUIWidgets() { resolvedDataTree = new JTree(); rawDataTree = new JTree(); parametersTable = new JTable(); resolveButton = new JButton("Resolve"); rawRecordCountLabel = new JLabel(); resolvedRecordCountLabel = new JLabel(); filterForSelectedCheckBox = new JCheckBox("Filter Raw Data For Selected"); algorithmComboBox = new JComboBox(); }