List of usage examples for javax.swing JRadioButton setSelected
public void setSelected(boolean b)
From source file:net.rptools.maptool.launcher.MapToolLauncher.java
private JPanel buildLanguagePanel() { final JPanel langPanel = new JPanel(); langPanel.setLayout(new BorderLayout()); final JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new GridLayout(0, 1)); buttonPanel.setBorder(/* www .jav a2 s . co m*/ new TitledBorder(new LineBorder(Color.BLACK), CopiedFromOtherJars.getText("msg.langPanel.border"))); //$NON-NLS-1$ String[] localeArray = locales.keySet().toArray(new String[0]); Arrays.sort(localeArray); ActionListener localeUpdate = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { mapToolLocale = e.getActionCommand(); // Setting the language won't work without reinitalizing the interface. // Instead, we just save it and use it for MapTool. // CopiedFromOtherJars.setLanguage(mapToolLocale); updateCommand(); } }; // Always set the first button ("Default Locale") to true and let one of the others change it, if needed. JRadioButton jrb = new JRadioButton(CopiedFromOtherJars.getText("msg.info.defaultLocale"), true); jrb.setActionCommand(EMPTY); langGroup.add(jrb); buttonPanel.add(jrb); jrb.addActionListener(localeUpdate); for (String locale : localeArray) { String name = locale + " - " + locales.get(locale); jrb = new JRadioButton(name); jrb.setActionCommand(locale); jrb.addActionListener(localeUpdate); langGroup.add(jrb); buttonPanel.add(jrb); if (mapToolLocale.equalsIgnoreCase(locale)) jrb.setSelected(true); } langPanel.add(buttonPanel, BorderLayout.NORTH); return langPanel; }
From source file:eu.apenet.dpt.standalone.gui.ead2edm.EdmOptionsPanel.java
private void createOptionPanel() { labels = dataPreparationToolGUI.getLabels(); JPanel creativeCommonsPanel = new CreativeCommonsPanel(); JPanel europeanaRightsPanel = new EuropeanaRightsPanel(); JPanel emptyPanel = new JPanel(); JPanel formPanel = new JPanel(new GridLayout(14, 1)); JPanel extraLicenseCardLayoutPanel = new JPanel(new CardLayout()); extraLicenseCardLayoutPanel.add(creativeCommonsPanel, CREATIVE_COMMONS); extraLicenseCardLayoutPanel.add(europeanaRightsPanel, EUROPEANA_RIGHTS_STATEMENTS); extraLicenseCardLayoutPanel.add(emptyPanel, EMPTY_PANEL); CardLayout cardLayout = (CardLayout) extraLicenseCardLayoutPanel.getLayout(); cardLayout.show(extraLicenseCardLayoutPanel, EMPTY_PANEL); JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER)); conversionModeGroup = new ButtonGroup(); JRadioButton radioButton; panel.add(new Label(this.labels.getString("edm.panel.label.choose.mode"))); radioButton = new JRadioButton(this.labels.getString("edm.panel.label.mode.minimal")); radioButton.setActionCommand(MINIMAL); radioButton.setSelected(true); radioButton.addActionListener(new ConversionModeListener()); conversionModeGroup.add(radioButton); panel.add(radioButton);//w w w. j a v a 2s . c om radioButton = new JRadioButton(this.labels.getString("edm.panel.label.mode.full")); radioButton.setActionCommand(FULL); radioButton.addActionListener(new ConversionModeListener()); conversionModeGroup.add(radioButton); panel.add(radioButton); formPanel.add(panel); panel = new JPanel(new FlowLayout(FlowLayout.CENTER)); cLevelIdSourceButtonGroup = new ButtonGroup(); panel.add(new Label(this.labels.getString("edm.generalOptionsForm.identifierSource.header"))); radioButton = new JRadioButton(this.labels.getString("edm.generalOptionsForm.identifierSource.unitid")); radioButton.setActionCommand(UNITID); if (retrieveFromDb.retrieveCIdentifierSource().equals(radioButton.getActionCommand())) { radioButton.setSelected(true); } cLevelIdSourceButtonGroup.add(radioButton); panel.add(radioButton); radioButton = new JRadioButton(this.labels.getString("edm.generalOptionsForm.identifierSource.cid")); radioButton.setActionCommand(CID); if (retrieveFromDb.retrieveCIdentifierSource().equals(radioButton.getActionCommand())) { radioButton.setSelected(true); } cLevelIdSourceButtonGroup.add(radioButton); panel.add(radioButton); formPanel.add(panel); panel = new JPanel(new FlowLayout(FlowLayout.CENTER)); sourceOfFondsTitleGroup = new ButtonGroup(); determineDaoInformation(); panel.add(new Label(this.labels.getString("edm.generalOptionsForm.sourceOfFondsTitle"))); if (!this.batch && StringUtils.isBlank(ead2EdmInformation.getArchdescUnittitle()) && StringUtils.isBlank(ead2EdmInformation.getTitlestmtTitleproper())) { panel.add(new Label( this.labels.getString("edm.generalOptionsForm.sourceOfFondsTitle.noSourceAvailable"))); } else { radioButton = new JRadioButton( this.labels.getString("edm.generalOptionsForm.sourceOfFondsTitle.archdescUnittitle")); radioButton.setActionCommand(ARCHDESC_UNITTITLE); radioButton.setSelected(true); radioButton.addActionListener(new ConversionModeListener()); sourceOfFondsTitleGroup.add(radioButton); panel.add(radioButton); radioButton = new JRadioButton( this.labels.getString("edm.generalOptionsForm.sourceOfFondsTitle.titlestmtTitleproper")); radioButton.setActionCommand(TITLESTMT_TITLEPROPER); radioButton.addActionListener(new ConversionModeListener()); sourceOfFondsTitleGroup.add(radioButton); panel.add(radioButton); } formPanel.add(panel); panel = new JPanel(new GridLayout(2, 2)); landingPageButtonGroup = new ButtonGroup(); panel.add(new Label(this.labels.getString("edm.generalOptionsForm.landingPages.header"))); radioButton = new JRadioButton(this.labels.getString("edm.generalOptionsForm.landingPages.ape")); radioButton.setActionCommand(APE); if (retrieveFromDb.retrieveLandingPageBase().equals(APE_BASE)) { radioButton.setSelected(true); } landingPageButtonGroup.add(radioButton); panel.add(radioButton); panel.add(new Label()); JPanel otherPanel = new JPanel(new GridLayout(1, 2)); radioButton = new JRadioButton(this.labels.getString("edm.generalOptionsForm.landingPages.other")); radioButton.setActionCommand(OTHER); landingPageButtonGroup.add(radioButton); otherPanel.add(radioButton); landingPageTextArea = new JTextArea(); landingPageTextArea.setLineWrap(true); landingPageTextArea.setWrapStyleWord(true); if (!retrieveFromDb.retrieveLandingPageBase().equals(APE_BASE)) { radioButton.setSelected(true); landingPageTextArea.setText(retrieveFromDb.retrieveLandingPageBase()); } JScrollPane lptaScrollPane = new JScrollPane(landingPageTextArea); lptaScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); otherPanel.add(lptaScrollPane); panel.add(otherPanel); formPanel.add(panel); panel = new JPanel(new GridLayout(1, 1)); panel.add(new Label(labels.getString("ese.mandatoryFieldsInfo"))); panel.add(new Label("")); panel.setBorder(BLACK_LINE); formPanel.add(panel); panel = new JPanel(new GridLayout(1, 3)); panel.add(new Label(labels.getString("ese.dataProvider") + ":" + "*")); dataProviderTextArea = new JTextArea(); dataProviderTextArea.setLineWrap(true); dataProviderTextArea.setWrapStyleWord(true); JScrollPane dptaScrollPane = new JScrollPane(dataProviderTextArea); dptaScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); panel.add(dptaScrollPane); useExistingRepoCheckbox = new JCheckBox(labels.getString("ese.takeFromFileRepository")); useExistingRepoCheckbox.setSelected(true); useExistingRepoCheckbox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { //empty method on purpose } }); JPanel panel2 = new JPanel(new GridLayout(1, 1)); panel2.add(useExistingRepoCheckbox); if (!batch) { String repository = ead2EdmInformation.getRepository(); if (repository != null && !repository.equals("")) { dataProviderTextArea.setText(repository); } else { if (archdescRepository != null) { dataProviderTextArea.setText(archdescRepository); } else { useExistingRepoCheckbox.setSelected(false); } } } panel.add(panel2); panel.setBorder(BLACK_LINE); formPanel.add(panel); /* panel = new JPanel(new GridLayout(1, 3)); panel.add(new Label(labels.getString("ese.provider") + ":" + "*")); providerTextArea = new JTextArea(); providerTextArea.setLineWrap(true); providerTextArea.setWrapStyleWord(true); JScrollPane ptaScrollPane = new JScrollPane(providerTextArea); ptaScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); panel.add(ptaScrollPane); panel.add(new Label("")); panel.setBorder(BLACK_LINE); formPanel.add(panel); */ panel = new JPanel(new GridLayout(5, 3)); typeGroup = new ButtonGroup(); panel.add(new Label(labels.getString("ese.type") + ":" + "*")); String currentRoleType; if (batch) { currentRoleType = ""; } else { currentRoleType = ead2EdmInformation.getRoleType(); } radioButton = new JRadioButton(this.labels.getString("edm.panel.dao.role.text")); if (currentRoleType.equals(EdmOptionsPanel.TEXT)) { radioButton.setSelected(true); } radioButton.setActionCommand(TEXT); radioButton.addActionListener(new ConversionModeListener()); typeGroup.add(radioButton); panel.add(radioButton); panel.add(new JLabel("")); panel.add(new JLabel("")); radioButton = new JRadioButton(this.labels.getString("edm.panel.dao.role.image")); if (currentRoleType.equals(EdmOptionsPanel.IMAGE)) { radioButton.setSelected(true); } radioButton.setActionCommand(IMAGE); radioButton.addActionListener(new ConversionModeListener()); typeGroup.add(radioButton); panel.add(radioButton); panel.add(new JLabel("")); panel.add(new JLabel("")); radioButton = new JRadioButton(this.labels.getString("edm.panel.dao.role.video")); if (currentRoleType.equals(EdmOptionsPanel.VIDEO)) { radioButton.setSelected(true); } radioButton.setActionCommand(VIDEO); radioButton.addActionListener(new ConversionModeListener()); typeGroup.add(radioButton); panel.add(radioButton); useExistingDaoRoleCheckbox = new JCheckBox(labels.getString("ese.takeFromFileDaoRole")); useExistingDaoRoleCheckbox.setSelected(true); useExistingDaoRoleCheckbox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { } }); panel.add(useExistingDaoRoleCheckbox); panel.add(new JLabel("")); radioButton = new JRadioButton(this.labels.getString("edm.panel.dao.role.sound")); if (currentRoleType.equals(EdmOptionsPanel.SOUND)) { radioButton.setSelected(true); } radioButton.setActionCommand(SOUND); radioButton.addActionListener(new ConversionModeListener()); typeGroup.add(radioButton); panel.add(radioButton); panel.add(new JLabel("")); panel.add(new JLabel("")); radioButton = new JRadioButton(this.labels.getString("edm.panel.dao.role.threed")); if (currentRoleType.equals(EdmOptionsPanel.THREE_D)) { radioButton.setSelected(true); } radioButton.setActionCommand(THREE_D); radioButton.addActionListener(new ConversionModeListener()); typeGroup.add(radioButton); panel.add(radioButton); panel.add(new JLabel("")); panel.setBorder(GREY_LINE); formPanel.add(panel); if (this.batch) { panel = new JPanel(new GridLayout(1, 3)); panel.add(new Label(labels.getString("ese.selectLanguage") + ":" + "*")); panel.add(languageBoxPanel); useExistingLanguageCheckbox = new JCheckBox(labels.getString("ese.takeFromFileLanguage")); useExistingLanguageCheckbox.setSelected(true); useExistingLanguageCheckbox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { //empty method on purpose } }); panel.add(useExistingLanguageCheckbox); panel.setBorder(BLACK_LINE); formPanel.add(panel); } else { inheritLanguagePanel = new JPanel(new GridLayout(1, 3)); inheritLanguagePanel.add(new Label(labels.getString("ese.inheritLanguage") + ":" + "*")); JPanel rbPanel = new JPanel(new GridLayout(4, 1)); inheritLanguageGroup = new ButtonGroup(); inhLanYesRadioButton = new JRadioButton(labels.getString("ese.yes")); inhLanYesRadioButton.setActionCommand(YES); inhLanYesRadioButton.addActionListener(new ChangePanelActionListener(languageBoxPanel)); inheritLanguageGroup.add(inhLanYesRadioButton); rbPanel.add(inhLanYesRadioButton); inhLanNoRadioButton = new JRadioButton(labels.getString("ese.no"), true); inhLanNoRadioButton.setActionCommand(NO); inhLanNoRadioButton.addActionListener(new ChangePanelActionListener(languageBoxPanel)); inheritLanguageGroup.add(inhLanNoRadioButton); rbPanel.add(inhLanNoRadioButton); inhLanProvideRadioButton = new JRadioButton(labels.getString("ese.provide")); inhLanProvideRadioButton.setActionCommand(PROVIDE); inhLanProvideRadioButton.addActionListener(new ChangePanelActionListener(languageBoxPanel)); inheritLanguageGroup.add(inhLanProvideRadioButton); rbPanel.add(inhLanProvideRadioButton); useExistingLanguageCheckbox = new JCheckBox(labels.getString("ese.takeFromFileLanguage")); useExistingLanguageCheckbox.setSelected(true); useExistingLanguageCheckbox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { //empty method on purpose } }); rbPanel.add(useExistingLanguageCheckbox); inheritLanguagePanel.add(rbPanel, BorderLayout.WEST); languageBoxPanel.setVisible(true); inheritLanguagePanel.add(languageBoxPanel, BorderLayout.EAST); inheritLanguagePanel.setBorder(BLACK_LINE); inheritLanguagePanel.setVisible(true); formPanel.add(inheritLanguagePanel); } // if (this.batch) { panel = new JPanel(new GridLayout(1, 3)); panel.add(new JLabel(labels.getString("edm.panel.license.inheritLicense") + ":" + "*")); useExistingRightsInfoCheckbox = new JCheckBox(labels.getString("ese.takeFromFileLicense")); useExistingRightsInfoCheckbox.setSelected(true); useExistingRightsInfoCheckbox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { //empty method on purpose } }); panel.add(useExistingRightsInfoCheckbox); panel.add(new JLabel()); panel.setBorder(BLACK_LINE); panel.setVisible(true); formPanel.add(panel); // } else { // panel = new JPanel(new GridLayout(3, 3)); // inheritLicenseGroup = new ButtonGroup(); // // panel.add(new Label(labels.getString("edm.panel.license.inheritLicense") + ":" + "*")); // inhLicYesRadioButton = new JRadioButton(labels.getString("ese.yes")); // inhLicYesRadioButton.setActionCommand(YES); //// inhLicYesRadioButton.addActionListener(new ChangePanelActionListener(languageBoxPanel)); // inheritLicenseGroup.add(inhLicYesRadioButton); // panel.add(inhLicYesRadioButton); // panel.add(new JLabel()); // // panel.add(new JLabel()); // inhLicNoRadioButton = new JRadioButton(labels.getString("ese.no"), true); // inhLicNoRadioButton.setActionCommand(NO); //// inhLicNoRadioButton.addActionListener(new ChangePanelActionListener(languageBoxPanel)); // inheritLicenseGroup.add(inhLicNoRadioButton); // panel.add(inhLicNoRadioButton); // useExistingRightsInfoCheckbox = new JCheckBox(labels.getString("ese.takeFromFileLicense")); // useExistingRightsInfoCheckbox.setSelected(true); // useExistingRightsInfoCheckbox.addItemListener(new ItemListener() { // @Override // public void itemStateChanged(ItemEvent e) { // //empty method on purpose // } // }); // // panel.add(useExistingRightsInfoCheckbox); // // panel.add(new JLabel()); // inhLicProvideRadioButton = new JRadioButton(labels.getString("ese.provide")); // inhLicProvideRadioButton.setActionCommand(PROVIDE); //// inhLicProvideRadioButton.addActionListener(new ChangePanelActionListener(languageBoxPanel)); // inheritLicenseGroup.add(inhLicProvideRadioButton); // panel.add(inhLicProvideRadioButton); // panel.add(new JLabel()); // // panel.setBorder(BLACK_LINE); // panel.setVisible(true); // formPanel.add(panel); // } JPanel mainLicensePanel = new JPanel(new BorderLayout()); panel = new JPanel(new GridLayout(5, 2)); licenseGroup = new ButtonGroup(); // String currentRightsInformation; // if (batch) { // currentRightsInformation = ""; // } else { // currentRightsInformation = ead2EdmInformation.getArchdescLicenceType(); // } panel.add(new Label(labels.getString("ese.specifyLicense") + ":" + "*")); radioButton = new JRadioButton(this.labels.getString("edm.panel.label.cc")); // if (currentRightsInformation.equals(EdmOptionsPanel.CREATIVE_COMMONS)) { // radioButton.setSelected(true); // } radioButton.setActionCommand(CREATIVE_COMMONS); radioButton.addActionListener(new ChangePanelActionListener(extraLicenseCardLayoutPanel)); licenseGroup.add(radioButton); panel.add(radioButton); panel.add(new JLabel("")); radioButton = new JRadioButton(this.labels.getString("edm.panel.label.cc.zero")); // if (currentRightsInformation.equals(EdmOptionsPanel.CREATIVE_COMMONS_CC0)) { // radioButton.setSelected(true); // } radioButton.setActionCommand(CREATIVE_COMMONS_CC0); radioButton.addActionListener(new ChangePanelActionListener(extraLicenseCardLayoutPanel)); licenseGroup.add(radioButton); panel.add(radioButton); panel.add(new JLabel("")); radioButton = new JRadioButton(this.labels.getString("edm.panel.label.cc.public")); // if (currentRightsInformation.equals(EdmOptionsPanel.CREATIVE_COMMONS_PUBLIC_DOMAIN_MARK)) { // radioButton.setSelected(true); // } radioButton.setActionCommand(CREATIVE_COMMONS_PUBLIC_DOMAIN_MARK); radioButton.addActionListener(new ChangePanelActionListener(extraLicenseCardLayoutPanel)); licenseGroup.add(radioButton); panel.add(radioButton); panel.add(new JLabel("")); radioButton = new JRadioButton(this.labels.getString("edm.panel.label.europeana.rights")); // if (currentRightsInformation.equals(EdmOptionsPanel.EUROPEANA_RIGHTS_STATEMENTS)) { // radioButton.setSelected(true); // } radioButton.setActionCommand(EUROPEANA_RIGHTS_STATEMENTS); radioButton.addActionListener(new ChangePanelActionListener(extraLicenseCardLayoutPanel)); licenseGroup.add(radioButton); panel.add(radioButton); panel.add(new JLabel("")); radioButton = new JRadioButton(this.labels.getString("edm.panel.label.out.copyright")); // if (currentRightsInformation.equals(EdmOptionsPanel.OUT_OF_COPYRIGHT)) { // radioButton.setSelected(true); // } radioButton.setActionCommand(EdmOptionsPanel.OUT_OF_COPYRIGHT); radioButton.addActionListener(new ChangePanelActionListener(extraLicenseCardLayoutPanel)); licenseGroup.add(radioButton); panel.add(radioButton); mainLicensePanel.add(panel, BorderLayout.WEST); mainLicensePanel.add(extraLicenseCardLayoutPanel, BorderLayout.EAST); // if (currentRightsInformation.equals(EdmOptionsPanel.EUROPEANA_RIGHTS_STATEMENTS) || currentRightsInformation.equals(EdmOptionsPanel.CREATIVE_COMMONS)) { // cardLayout.show(extraLicenseCardLayoutPanel, currentRightsInformation); // if (currentRightsInformation.equals(EdmOptionsPanel.EUROPEANA_RIGHTS_STATEMENTS)) { // if (ead2EdmInformation.getArchdescLicenceLink().endsWith("rr-f/")) { // europeanaRightsComboBox.setSelectedIndex(0); // } else if (ead2EdmInformation.getArchdescLicenceLink().endsWith("orphan-work-eu/")) { // europeanaRightsComboBox.setSelectedIndex(1); // } else if (ead2EdmInformation.getArchdescLicenceLink().endsWith("rr-p/")) { // europeanaRightsComboBox.setSelectedIndex(2); // } else { // europeanaRightsComboBox.setSelectedIndex(3); // } // } else if (currentRightsInformation.equals(EdmOptionsPanel.CREATIVE_COMMONS)) { // // get respective items from EAD2EDMInfo and set panel items appropriately // } // } mainLicensePanel.setBorder(BLACK_LINE); formPanel.add(mainLicensePanel); panel = new JPanel(new GridLayout(1, 1)); panel.add(new Label(labels.getString("ese.specifyAdditionalRightsInfo") + ":")); additionalRightsTextArea = new JTextArea(); additionalRightsTextArea.setLineWrap(true); additionalRightsTextArea.setWrapStyleWord(true); JScrollPane artaScrollPane = new JScrollPane(additionalRightsTextArea); artaScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); panel.add(artaScrollPane); panel.setBorder(GREY_LINE); formPanel.add(panel); inheritParentPanel = new JPanel(new GridLayout(2, 3)); inheritParentCheckbox = new JCheckBox(labels.getString("ese.inheritParent") + ":" + "*"); inheritParentCheckbox.setSelected(true); inheritParentCheckbox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { inhParYesRadioButton.setEnabled(true); inhParNoRadioButton.setEnabled(true); } if (e.getStateChange() == ItemEvent.DESELECTED) { inhParYesRadioButton.setEnabled(false); inhParNoRadioButton.setEnabled(false); } } }); inheritParentPanel.add(inheritParentCheckbox); inheritParentGroup = new ButtonGroup(); inhParYesRadioButton = new JRadioButton(labels.getString("ese.yes")); inhParYesRadioButton.setActionCommand(YES); inheritParentGroup.add(inhParYesRadioButton); inheritParentPanel.add(inhParYesRadioButton); inheritParentPanel.add(new JLabel("")); inhParNoRadioButton = new JRadioButton(labels.getString("ese.no"), true); inhParNoRadioButton.setActionCommand(NO); inheritParentGroup.add(inhParNoRadioButton); inheritParentPanel.add(inhParNoRadioButton); inheritParentPanel.setBorder(GREY_LINE); inheritParentPanel.setVisible(false); formPanel.add(inheritParentPanel); inheritOriginationPanel = new JPanel(new GridLayout(2, 3)); inheritOriginationCheckbox = new JCheckBox(labels.getString("ese.inheritOrigination") + ":" + "*"); inheritOriginationCheckbox.setSelected(true); inheritOriginationCheckbox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { inhOriYesRadioButton.setEnabled(true); inhOriNoRadioButton.setEnabled(true); } if (e.getStateChange() == ItemEvent.DESELECTED) { inhOriYesRadioButton.setEnabled(false); inhOriNoRadioButton.setEnabled(false); } } }); inheritOriginationPanel.add(inheritOriginationCheckbox); inheritOriginationGroup = new ButtonGroup(); inhOriYesRadioButton = new JRadioButton(labels.getString("ese.yes")); inhOriYesRadioButton.setActionCommand(YES); inheritOriginationGroup.add(inhOriYesRadioButton); inheritOriginationPanel.add(inhOriYesRadioButton); inheritOriginationPanel.add(new JLabel("")); inhOriNoRadioButton = new JRadioButton(labels.getString("ese.no"), true); inhOriNoRadioButton.setActionCommand(NO); inheritOriginationGroup.add(inhOriNoRadioButton); inheritOriginationPanel.add(inhOriNoRadioButton); inheritOriginationPanel.setBorder(BLACK_LINE); inheritOriginationPanel.setVisible(false); formPanel.add(inheritOriginationPanel); inheritUnittitlePanel = new JPanel(new GridLayout(2, 3)); inheritUnittitleCheckbox = new JCheckBox(labels.getString("ese.inheritUnittitle") + ":" + "*"); inheritUnittitleCheckbox.setSelected(true); inheritUnittitleCheckbox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { inhTitleYesRadioButton.setEnabled(true); inhTitleNoRadioButton.setEnabled(true); } if (e.getStateChange() == ItemEvent.DESELECTED) { inhTitleYesRadioButton.setEnabled(false); inhTitleNoRadioButton.setEnabled(false); } } }); inheritUnittitlePanel.add(inheritUnittitleCheckbox); inheritUnittitleGroup = new ButtonGroup(); inhTitleYesRadioButton = new JRadioButton(labels.getString("ese.yes")); inhTitleYesRadioButton.setActionCommand(YES); inheritUnittitleGroup.add(inhTitleYesRadioButton); inheritUnittitlePanel.add(inhTitleYesRadioButton); inheritUnittitlePanel.add(new JLabel("")); inhTitleNoRadioButton = new JRadioButton(labels.getString("ese.no"), true); inhTitleNoRadioButton.setActionCommand(NO); inheritUnittitleGroup.add(inhTitleNoRadioButton); inheritUnittitlePanel.add(inhTitleNoRadioButton); inheritUnittitlePanel.setBorder(BLACK_LINE); inheritUnittitlePanel.setVisible(false); formPanel.add(inheritUnittitlePanel); JButton createEdmBtn = new JButton(labels.getString("ese.createEseBtn")); JButton cancelBtn = new JButton(labels.getString("ese.cancelBtn")); createEdmBtn.addActionListener(new CreateEdmActionListener()); cancelBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { for (Map.Entry<String, FileInstance> entry : fileInstances.entrySet()) { FileInstance fileInstance = entry.getValue(); fileInstance.setEdm(false); } dataPreparationToolGUI.enableEdmConversionBtn(); if (batch) { dataPreparationToolGUI.enableAllBatchBtns(); } dataPreparationToolGUI.enableRadioButtons(); close(); } }); JPanel buttonPanel = new JPanel(new GridLayout(1, 5)); buttonPanel.add(new JLabel("")); buttonPanel.add(cancelBtn); buttonPanel.add(new JLabel("")); buttonPanel.add(createEdmBtn); buttonPanel.add(new JLabel("")); add(formPanel, BorderLayout.CENTER); add(buttonPanel, BorderLayout.SOUTH); }
From source file:com.google.code.facebook.graph.sna.applet.LensDemo.java
/** * create an instance of a simple graph with controls to * demo the zoomand hyperbolic features. * //from w w w . j a v a2 s .co m */ public LensDemo() { // create a simple graph for the demo graph = TestGraphs.getOneComponentGraph(); graphLayout = new FRLayout<String, Number>(graph); ((FRLayout) graphLayout).setMaxIterations(1000); Dimension preferredSize = new Dimension(600, 600); Map<String, Point2D> map = new HashMap<String, Point2D>(); Transformer<String, Point2D> vlf = TransformerUtils.mapTransformer(map); grid = this.generateVertexGrid(map, preferredSize, 25); gridLayout = new StaticLayout<String, Number>(grid, vlf, preferredSize); final VisualizationModel<String, Number> visualizationModel = new DefaultVisualizationModel<String, Number>( graphLayout, preferredSize); vv = new VisualizationViewer<String, Number>(visualizationModel, preferredSize); PickedState<String> ps = vv.getPickedVertexState(); PickedState<Number> pes = vv.getPickedEdgeState(); vv.getRenderContext().setVertexFillPaintTransformer( new PickableVertexPaintTransformer<String>(ps, Color.red, Color.yellow)); vv.getRenderContext().setEdgeDrawPaintTransformer( new PickableEdgePaintTransformer<Number>(pes, Color.black, Color.cyan)); vv.setBackground(Color.white); vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller()); final Transformer<String, Shape> ovals = vv.getRenderContext().getVertexShapeTransformer(); final Transformer<String, Shape> squares = new ConstantTransformer(new Rectangle2D.Float(-10, -10, 20, 20)); // add a listener for ToolTips vv.setVertexToolTipTransformer(new ToStringLabeller()); Container content = getContentPane(); GraphZoomScrollPane gzsp = new GraphZoomScrollPane(vv); content.add(gzsp); /** * the regular graph mouse for the normal view */ final DefaultModalGraphMouse graphMouse = new DefaultModalGraphMouse(); vv.setGraphMouse(graphMouse); vv.addKeyListener(graphMouse.getModeKeyListener()); hyperbolicViewSupport = new ViewLensSupport<String, Number>(vv, new HyperbolicShapeTransformer(vv, vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.VIEW)), new ModalLensGraphMouse()); hyperbolicLayoutSupport = new LayoutLensSupport<String, Number>(vv, new HyperbolicTransformer(vv, vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT)), new ModalLensGraphMouse()); magnifyViewSupport = new ViewLensSupport<String, Number>(vv, new MagnifyShapeTransformer(vv, vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.VIEW)), new ModalLensGraphMouse(new LensMagnificationGraphMousePlugin(1.f, 6.f, .2f))); magnifyLayoutSupport = new LayoutLensSupport<String, Number>(vv, new MagnifyTransformer(vv, vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT)), new ModalLensGraphMouse(new LensMagnificationGraphMousePlugin(1.f, 6.f, .2f))); hyperbolicLayoutSupport.getLensTransformer() .setLensShape(hyperbolicViewSupport.getLensTransformer().getLensShape()); magnifyViewSupport.getLensTransformer() .setLensShape(hyperbolicLayoutSupport.getLensTransformer().getLensShape()); magnifyLayoutSupport.getLensTransformer() .setLensShape(magnifyViewSupport.getLensTransformer().getLensShape()); 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()); } }); ButtonGroup radio = new ButtonGroup(); JRadioButton normal = new JRadioButton("None"); normal.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { if (hyperbolicViewSupport != null) { hyperbolicViewSupport.deactivate(); } if (hyperbolicLayoutSupport != null) { hyperbolicLayoutSupport.deactivate(); } if (magnifyViewSupport != null) { magnifyViewSupport.deactivate(); } if (magnifyLayoutSupport != null) { magnifyLayoutSupport.deactivate(); } } } }); final JRadioButton hyperView = new JRadioButton("Hyperbolic View"); hyperView.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { hyperbolicViewSupport.activate(e.getStateChange() == ItemEvent.SELECTED); } }); final JRadioButton hyperModel = new JRadioButton("Hyperbolic Layout"); hyperModel.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { hyperbolicLayoutSupport.activate(e.getStateChange() == ItemEvent.SELECTED); } }); final JRadioButton magnifyView = new JRadioButton("Magnified View"); magnifyView.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { magnifyViewSupport.activate(e.getStateChange() == ItemEvent.SELECTED); } }); final JRadioButton magnifyModel = new JRadioButton("Magnified Layout"); magnifyModel.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { magnifyLayoutSupport.activate(e.getStateChange() == ItemEvent.SELECTED); } }); JLabel modeLabel = new JLabel(" Mode Menu >>"); modeLabel.setUI(new VerticalLabelUI(false)); radio.add(normal); radio.add(hyperModel); radio.add(hyperView); radio.add(magnifyModel); radio.add(magnifyView); normal.setSelected(true); graphMouse.addItemListener(hyperbolicLayoutSupport.getGraphMouse().getModeListener()); graphMouse.addItemListener(hyperbolicViewSupport.getGraphMouse().getModeListener()); graphMouse.addItemListener(magnifyLayoutSupport.getGraphMouse().getModeListener()); graphMouse.addItemListener(magnifyViewSupport.getGraphMouse().getModeListener()); ButtonGroup graphRadio = new ButtonGroup(); JRadioButton graphButton = new JRadioButton("Graph"); graphButton.setSelected(true); graphButton.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { visualizationModel.setGraphLayout(graphLayout); vv.getRenderContext().setVertexShapeTransformer(ovals); vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller()); vv.repaint(); } } }); JRadioButton gridButton = new JRadioButton("Grid"); gridButton.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { visualizationModel.setGraphLayout(gridLayout); vv.getRenderContext().setVertexShapeTransformer(squares); vv.getRenderContext().setVertexLabelTransformer(new ConstantTransformer(null)); vv.repaint(); } } }); graphRadio.add(graphButton); graphRadio.add(gridButton); JPanel modePanel = new JPanel(new GridLayout(3, 1)); modePanel.setBorder(BorderFactory.createTitledBorder("Display")); modePanel.add(graphButton); modePanel.add(gridButton); JMenuBar menubar = new JMenuBar(); menubar.add(graphMouse.getModeMenu()); gzsp.setCorner(menubar); Box controls = Box.createHorizontalBox(); JPanel zoomControls = new JPanel(new GridLayout(2, 1)); zoomControls.setBorder(BorderFactory.createTitledBorder("Zoom")); JPanel hyperControls = new JPanel(new GridLayout(3, 2)); hyperControls.setBorder(BorderFactory.createTitledBorder("Examiner Lens")); zoomControls.add(plus); zoomControls.add(minus); hyperControls.add(normal); hyperControls.add(new JLabel()); hyperControls.add(hyperModel); hyperControls.add(magnifyModel); hyperControls.add(hyperView); hyperControls.add(magnifyView); controls.add(zoomControls); controls.add(hyperControls); controls.add(modePanel); controls.add(modeLabel); content.add(controls, BorderLayout.SOUTH); }
From source file:edu.uci.ics.jung.samples.LensDemo.java
/** * create an instance of a simple graph with controls to * demo the zoomand hyperbolic features. * // w ww .j av a 2 s .c o m */ @SuppressWarnings({ "rawtypes", "unchecked" }) public LensDemo() { // create a simple graph for the demo graph = TestGraphs.getOneComponentGraph(); graphLayout = new FRLayout<String, Number>(graph); ((FRLayout) graphLayout).setMaxIterations(1000); Dimension preferredSize = new Dimension(600, 600); Map<String, Point2D> map = new HashMap<String, Point2D>(); Transformer<String, Point2D> vlf = TransformerUtils.mapTransformer(map); grid = this.generateVertexGrid(map, preferredSize, 25); gridLayout = new StaticLayout<String, Number>(grid, vlf, preferredSize); final VisualizationModel<String, Number> visualizationModel = new DefaultVisualizationModel<String, Number>( graphLayout, preferredSize); vv = new VisualizationViewer<String, Number>(visualizationModel, preferredSize); PickedState<String> ps = vv.getPickedVertexState(); PickedState<Number> pes = vv.getPickedEdgeState(); vv.getRenderContext().setVertexFillPaintTransformer( new PickableVertexPaintTransformer<String>(ps, Color.red, Color.yellow)); vv.getRenderContext().setEdgeDrawPaintTransformer( new PickableEdgePaintTransformer<Number>(pes, Color.black, Color.cyan)); vv.setBackground(Color.white); vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller()); final Transformer<String, Shape> ovals = vv.getRenderContext().getVertexShapeTransformer(); final Transformer<String, Shape> squares = new ConstantTransformer(new Rectangle2D.Float(-10, -10, 20, 20)); // add a listener for ToolTips vv.setVertexToolTipTransformer(new ToStringLabeller()); Container content = getContentPane(); GraphZoomScrollPane gzsp = new GraphZoomScrollPane(vv); content.add(gzsp); /** * the regular graph mouse for the normal view */ final DefaultModalGraphMouse graphMouse = new DefaultModalGraphMouse(); vv.setGraphMouse(graphMouse); vv.addKeyListener(graphMouse.getModeKeyListener()); hyperbolicViewSupport = new ViewLensSupport<String, Number>(vv, new HyperbolicShapeTransformer(vv, vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.VIEW)), new ModalLensGraphMouse()); hyperbolicLayoutSupport = new LayoutLensSupport<String, Number>(vv, new HyperbolicTransformer(vv, vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT)), new ModalLensGraphMouse()); magnifyViewSupport = new ViewLensSupport<String, Number>(vv, new MagnifyShapeTransformer(vv, vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.VIEW)), new ModalLensGraphMouse(new LensMagnificationGraphMousePlugin(1.f, 6.f, .2f))); magnifyLayoutSupport = new LayoutLensSupport<String, Number>(vv, new MagnifyTransformer(vv, vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT)), new ModalLensGraphMouse(new LensMagnificationGraphMousePlugin(1.f, 6.f, .2f))); hyperbolicLayoutSupport.getLensTransformer() .setLensShape(hyperbolicViewSupport.getLensTransformer().getLensShape()); magnifyViewSupport.getLensTransformer() .setLensShape(hyperbolicLayoutSupport.getLensTransformer().getLensShape()); magnifyLayoutSupport.getLensTransformer() .setLensShape(magnifyViewSupport.getLensTransformer().getLensShape()); 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()); } }); ButtonGroup radio = new ButtonGroup(); JRadioButton normal = new JRadioButton("None"); normal.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { if (hyperbolicViewSupport != null) { hyperbolicViewSupport.deactivate(); } if (hyperbolicLayoutSupport != null) { hyperbolicLayoutSupport.deactivate(); } if (magnifyViewSupport != null) { magnifyViewSupport.deactivate(); } if (magnifyLayoutSupport != null) { magnifyLayoutSupport.deactivate(); } } } }); final JRadioButton hyperView = new JRadioButton("Hyperbolic View"); hyperView.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { hyperbolicViewSupport.activate(e.getStateChange() == ItemEvent.SELECTED); } }); final JRadioButton hyperModel = new JRadioButton("Hyperbolic Layout"); hyperModel.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { hyperbolicLayoutSupport.activate(e.getStateChange() == ItemEvent.SELECTED); } }); final JRadioButton magnifyView = new JRadioButton("Magnified View"); magnifyView.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { magnifyViewSupport.activate(e.getStateChange() == ItemEvent.SELECTED); } }); final JRadioButton magnifyModel = new JRadioButton("Magnified Layout"); magnifyModel.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { magnifyLayoutSupport.activate(e.getStateChange() == ItemEvent.SELECTED); } }); JLabel modeLabel = new JLabel(" Mode Menu >>"); modeLabel.setUI(new VerticalLabelUI(false)); radio.add(normal); radio.add(hyperModel); radio.add(hyperView); radio.add(magnifyModel); radio.add(magnifyView); normal.setSelected(true); graphMouse.addItemListener(hyperbolicLayoutSupport.getGraphMouse().getModeListener()); graphMouse.addItemListener(hyperbolicViewSupport.getGraphMouse().getModeListener()); graphMouse.addItemListener(magnifyLayoutSupport.getGraphMouse().getModeListener()); graphMouse.addItemListener(magnifyViewSupport.getGraphMouse().getModeListener()); ButtonGroup graphRadio = new ButtonGroup(); JRadioButton graphButton = new JRadioButton("Graph"); graphButton.setSelected(true); graphButton.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { visualizationModel.setGraphLayout(graphLayout); vv.getRenderContext().setVertexShapeTransformer(ovals); vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller()); vv.repaint(); } } }); JRadioButton gridButton = new JRadioButton("Grid"); gridButton.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { visualizationModel.setGraphLayout(gridLayout); vv.getRenderContext().setVertexShapeTransformer(squares); vv.getRenderContext().setVertexLabelTransformer(new ConstantTransformer(null)); vv.repaint(); } } }); graphRadio.add(graphButton); graphRadio.add(gridButton); JPanel modePanel = new JPanel(new GridLayout(3, 1)); modePanel.setBorder(BorderFactory.createTitledBorder("Display")); modePanel.add(graphButton); modePanel.add(gridButton); JMenuBar menubar = new JMenuBar(); menubar.add(graphMouse.getModeMenu()); gzsp.setCorner(menubar); Box controls = Box.createHorizontalBox(); JPanel zoomControls = new JPanel(new GridLayout(2, 1)); zoomControls.setBorder(BorderFactory.createTitledBorder("Zoom")); JPanel hyperControls = new JPanel(new GridLayout(3, 2)); hyperControls.setBorder(BorderFactory.createTitledBorder("Examiner Lens")); zoomControls.add(plus); zoomControls.add(minus); hyperControls.add(normal); hyperControls.add(new JLabel()); hyperControls.add(hyperModel); hyperControls.add(magnifyModel); hyperControls.add(hyperView); hyperControls.add(magnifyView); controls.add(zoomControls); controls.add(hyperControls); controls.add(modePanel); controls.add(modeLabel); content.add(controls, BorderLayout.SOUTH); }
From source file:edu.ucla.stat.SOCR.chart.Chart.java
public void initMapPanel() { listIndex = new int[dataTable.getColumnCount()]; for (int j = 0; j < listIndex.length; j++) listIndex[j] = 1;//from w w w. ja va 2 s . co m bPanel = new JPanel(new BorderLayout()); // topPanel = new JPanel(new FlowLayout()); //bottomPanel = new JPanel(new FlowLayout()); mapPanel = new JPanel(new GridLayout(2, 3, 50, 50)); // bPanel.add(new JPanel(),BorderLayout.EAST); // bPanel.add(new JPanel(),BorderLayout.WEST); // bPanel.add(new JPanel(),BorderLayout.SOUTH); bPanel.add(mapPanel, BorderLayout.CENTER); // bPanel.add(new JPanel(),BorderLayout.NORTH); addButton1.addActionListener(this); addButton2.addActionListener(this); removeButton1.addActionListener(this); removeButton2.addActionListener(this); lModelAdded = new DefaultListModel(); lModelDep = new DefaultListModel(); lModelIndep = new DefaultListModel(); //JLabel depLabel = new JLabel(DEPENDENT); //JLabel indLabel = new JLabel(INDEPENDENT); //JLabel varLabel = new JLabel(VARIABLE); int cellWidth = 10; listAdded = new JList(lModelAdded); listAdded.setSelectedIndex(0); listDepRemoved = new JList(lModelDep); listIndepRemoved = new JList(lModelIndep); paintMappingLists(listIndex); listAdded.setFixedCellWidth(cellWidth); listDepRemoved.setFixedCellWidth(cellWidth); listIndepRemoved.setFixedCellWidth(cellWidth); tools1 = new JToolBar(JToolBar.VERTICAL); tools2 = new JToolBar(JToolBar.VERTICAL); if (mapDep) { tools1.add(depLabel); tools1.add(addButton1); tools1.add(removeButton1); } if (mapIndep) { tools2.add(indLabel); tools2.add(addButton2); tools2.add(removeButton2); } tools1.setFloatable(false); tools2.setFloatable(false); /* topPanel.add(listAdded); topPanel.add(addButton); topPanel.add(listDepRemoved); bottomPanel.add(listIndepRemoved); bottomPanel.add(addButton2); bottomPanel.add(list4); */ JRadioButton legendPanelOnSwitch; JRadioButton legendPanelOffSwitch; // JPanel choicesPanel = new JPanel(); choicesPanel.setLayout(new BoxLayout(choicesPanel, BoxLayout.Y_AXIS)); legendPanelOnSwitch = new JRadioButton("On"); legendPanelOnSwitch.addActionListener(this); legendPanelOnSwitch.setActionCommand(LEGENDON); legendPanelOnSwitch.setSelected(false); legendPanelOn = false; legendPanelOffSwitch = new JRadioButton("Off"); legendPanelOffSwitch.addActionListener(this); legendPanelOffSwitch.setActionCommand(LEGENDOFF); legendPanelOffSwitch.setSelected(true); ButtonGroup group = new ButtonGroup(); group.add(legendPanelOnSwitch); group.add(legendPanelOffSwitch); choicesPanel.add(new JLabel("Turn the legend panel:")); choicesPanel.add(legendPanelOnSwitch); choicesPanel.add(legendPanelOffSwitch); choicesPanel.setPreferredSize(new Dimension(200, 100)); mapPanel.add(new JScrollPane(listAdded)); JPanel emptyPanel = new JPanel(); JPanel emptyPanel2 = new JPanel(); JPanel emptyPanel3 = new JPanel(); if (mapDep) { mapPanel.add(tools1); mapPanel.add(new JScrollPane(listDepRemoved)); if (LEGEND_SWITCH) mapPanel.add(choicesPanel); else mapPanel.add(emptyPanel); if (mapIndep) { mapPanel.add(tools2); mapPanel.add(new JScrollPane(listIndepRemoved)); } else { mapPanel.add(emptyPanel2); mapPanel.add(emptyPanel3); } } else { mapPanel.add(emptyPanel); mapPanel.add(emptyPanel2); if (LEGEND_SWITCH) mapPanel.add(emptyPanel3); else mapPanel.add(choicesPanel); if (mapIndep) { mapPanel.add(tools2); mapPanel.add(new JScrollPane(listIndepRemoved)); } } }
From source file:graph.jung2.MyLensDemo.java
public void init() { // create a simple graph for the demo TemporalNetworkOfWikipediaNodes net = null; try {/* w ww . j ava 2 s.co m*/ // net = new TemporalNetworkOfWikipediaNodes(null, null); net = new TemporalNetworkOfWikipediaNodes(r, level); graph = net.createSampleNetwork(); //getCC_EDIT_Graph(); } catch (Exception ex) { Logger.getLogger(MyLensDemo.class.getName()).log(Level.SEVERE, null, ex); } // if ( net == null ) { // graph = TemporalNetworkOfWikipediaNodes.createSampleNetwork(); // } // else { // graph = net.getGraph(); // } graphLayout = new FRLayout<String, Number>(graph); ((FRLayout) graphLayout).setMaxIterations(1000); Dimension preferredSize = new Dimension(600, 600); Map<String, Point2D> map = new HashMap<String, Point2D>(); Transformer<String, Point2D> vlf = TransformerUtils.mapTransformer(map); grid = this.generateVertexGrid(map, preferredSize, 25); gridLayout = new StaticLayout<String, Number>(grid, vlf, preferredSize); final VisualizationModel<String, Number> visualizationModel = new DefaultVisualizationModel<String, Number>( graphLayout, preferredSize); vv = new VisualizationViewer<String, Number>(visualizationModel, preferredSize); PickedState<String> ps = vv.getPickedVertexState(); PickedState<Number> pes = vv.getPickedEdgeState(); vv.getRenderContext().setVertexFillPaintTransformer( new PickableVertexPaintTransformer<String>(ps, Color.red, Color.yellow)); vv.getRenderContext().setEdgeDrawPaintTransformer( new PickableEdgePaintTransformer<Number>(pes, Color.black, Color.cyan)); vv.setBackground(Color.white); vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller()); final Transformer<String, Shape> ovals = vv.getRenderContext().getVertexShapeTransformer(); final Transformer<String, Shape> squares = new ConstantTransformer(new Rectangle2D.Float(-10, -10, 20, 20)); // add a listener for ToolTips vv.setVertexToolTipTransformer(new ToStringLabeller()); Container content = getContentPane(); GraphZoomScrollPane gzsp = new GraphZoomScrollPane(vv); content.add(gzsp); /** * the regular graph mouse for the normal view */ final DefaultModalGraphMouse graphMouse = new DefaultModalGraphMouse(); vv.setGraphMouse(graphMouse); vv.addKeyListener(graphMouse.getModeKeyListener()); hyperbolicViewSupport = new ViewLensSupport<String, Number>(vv, new HyperbolicShapeTransformer(vv, vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.VIEW)), new ModalLensGraphMouse()); hyperbolicLayoutSupport = new LayoutLensSupport<String, Number>(vv, new HyperbolicTransformer(vv, vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT)), new ModalLensGraphMouse()); magnifyViewSupport = new ViewLensSupport<String, Number>(vv, new MagnifyShapeTransformer(vv, vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.VIEW)), new ModalLensGraphMouse(new LensMagnificationGraphMousePlugin(1.f, 6.f, .2f))); magnifyLayoutSupport = new LayoutLensSupport<String, Number>(vv, new MagnifyTransformer(vv, vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT)), new ModalLensGraphMouse(new LensMagnificationGraphMousePlugin(1.f, 6.f, .2f))); hyperbolicLayoutSupport.getLensTransformer() .setLensShape(hyperbolicViewSupport.getLensTransformer().getLensShape()); magnifyViewSupport.getLensTransformer() .setLensShape(hyperbolicLayoutSupport.getLensTransformer().getLensShape()); magnifyLayoutSupport.getLensTransformer() .setLensShape(magnifyViewSupport.getLensTransformer().getLensShape()); 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()); } }); ButtonGroup radio = new ButtonGroup(); JRadioButton normal = new JRadioButton("None"); normal.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { if (hyperbolicViewSupport != null) { hyperbolicViewSupport.deactivate(); } if (hyperbolicLayoutSupport != null) { hyperbolicLayoutSupport.deactivate(); } if (magnifyViewSupport != null) { magnifyViewSupport.deactivate(); } if (magnifyLayoutSupport != null) { magnifyLayoutSupport.deactivate(); } } } }); final JRadioButton hyperView = new JRadioButton("Hyperbolic View"); hyperView.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { hyperbolicViewSupport.activate(e.getStateChange() == ItemEvent.SELECTED); } }); final JRadioButton hyperModel = new JRadioButton("Hyperbolic Layout"); hyperModel.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { hyperbolicLayoutSupport.activate(e.getStateChange() == ItemEvent.SELECTED); } }); final JRadioButton magnifyView = new JRadioButton("Magnified View"); magnifyView.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { magnifyViewSupport.activate(e.getStateChange() == ItemEvent.SELECTED); } }); final JRadioButton magnifyModel = new JRadioButton("Magnified Layout"); magnifyModel.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { magnifyLayoutSupport.activate(e.getStateChange() == ItemEvent.SELECTED); } }); JLabel modeLabel = new JLabel(" Mode Menu >>"); modeLabel.setUI(new VerticalLabelUI(false)); radio.add(normal); radio.add(hyperModel); radio.add(hyperView); radio.add(magnifyModel); radio.add(magnifyView); normal.setSelected(true); graphMouse.addItemListener(hyperbolicLayoutSupport.getGraphMouse().getModeListener()); graphMouse.addItemListener(hyperbolicViewSupport.getGraphMouse().getModeListener()); graphMouse.addItemListener(magnifyLayoutSupport.getGraphMouse().getModeListener()); graphMouse.addItemListener(magnifyViewSupport.getGraphMouse().getModeListener()); ButtonGroup graphRadio = new ButtonGroup(); JRadioButton graphButton = new JRadioButton("Graph"); graphButton.setSelected(true); graphButton.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { visualizationModel.setGraphLayout(graphLayout); vv.getRenderContext().setVertexShapeTransformer(ovals); vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller()); vv.repaint(); } } }); JRadioButton gridButton = new JRadioButton("Grid"); gridButton.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { visualizationModel.setGraphLayout(gridLayout); vv.getRenderContext().setVertexShapeTransformer(squares); vv.getRenderContext().setVertexLabelTransformer(new ConstantTransformer(null)); vv.repaint(); } } }); graphRadio.add(graphButton); graphRadio.add(gridButton); JPanel modePanel = new JPanel(new GridLayout(3, 1)); modePanel.setBorder(BorderFactory.createTitledBorder("Display")); modePanel.add(graphButton); modePanel.add(gridButton); JMenuBar menubar = new JMenuBar(); menubar.add(graphMouse.getModeMenu()); gzsp.setCorner(menubar); Box controls = Box.createHorizontalBox(); JPanel zoomControls = new JPanel(new GridLayout(2, 1)); zoomControls.setBorder(BorderFactory.createTitledBorder("Zoom")); JPanel hyperControls = new JPanel(new GridLayout(3, 2)); hyperControls.setBorder(BorderFactory.createTitledBorder("Examiner Lens")); zoomControls.add(plus); zoomControls.add(minus); hyperControls.add(normal); hyperControls.add(new JLabel()); hyperControls.add(hyperModel); hyperControls.add(magnifyModel); hyperControls.add(hyperView); hyperControls.add(magnifyView); controls.add(zoomControls); controls.add(hyperControls); controls.add(modePanel); controls.add(modeLabel); content.add(controls, BorderLayout.SOUTH); }
From source file:com.mirth.connect.client.ui.browsers.message.MessageBrowser.java
/** * Helper function to update the error tab *///ww w . j av a 2 s. c o m private void updateDescriptionErrors(ConnectorMessage connectorMessage) { String processingError = connectorMessage.getProcessingError(); String postProcessorError = connectorMessage.getPostProcessorError(); String responseError = connectorMessage.getResponseError(); ErrorsRadioPane.removeAll(); boolean paneSelected = false; String firstVisiblePane = null; if (processingError != null) { ErrorsRadioPane.add(ProcessingErrorRadioButton); paneSelected = lastUserSelectedErrorType.equals(ProcessingErrorRadioButton.getText()); if (firstVisiblePane == null) { firstVisiblePane = ProcessingErrorRadioButton.getText(); } setCorrectDocument(ProcessingErrorTextPane, processingError, null); } if (postProcessorError != null) { ErrorsRadioPane.add(PostprocessorErrorRadioButton); paneSelected = lastUserSelectedErrorType.equals(PostprocessorErrorRadioButton.getText()); if (firstVisiblePane == null) { firstVisiblePane = PostprocessorErrorRadioButton.getText(); } setCorrectDocument(PostprocessorErrorTextPane, postProcessorError, null); } if (responseError != null) { ErrorsRadioPane.add(ResponseErrorRadioButton); paneSelected = lastUserSelectedErrorType.equals(ResponseErrorRadioButton.getText()); if (firstVisiblePane == null) { firstVisiblePane = ResponseErrorRadioButton.getText(); } setCorrectDocument(ResponseErrorTextPane, responseError, null); } String paneToSelect; // Set the default pane if the last user selected one is not added. if (!paneSelected) { if (firstVisiblePane != null) { paneToSelect = firstVisiblePane; } else { paneToSelect = ProcessingErrorRadioButton.getText(); } } else { paneToSelect = lastUserSelectedErrorType; } JRadioButton button = getRadioButtonForErrorPane(paneToSelect); button.setSelected(true); showErrorPane(button.getText()); }
From source file:com.mirth.connect.client.ui.browsers.message.MessageBrowser.java
public void updateMessageRadioGroup() { JRadioButton button = getRadioButtonForMessagePane(lastUserSelectedMessageType); if (!button.isShowing()) { button = RawMessageRadioButton;/*from ww w . ja v a 2s. co m*/ } button.setSelected(true); showMessagePane(button.getText()); }
From source file:com.nikonhacker.gui.EmulatorUI.java
private void openUIOptionsDialog() { JPanel options = new JPanel(new GridLayout(0, 1)); options.setName("User Interface"); // Button size ActionListener buttonSizeRadioListener = new ActionListener() { @Override/* w w w . j a va 2s. c o m*/ public void actionPerformed(ActionEvent e) { prefs.setButtonSize(e.getActionCommand()); } }; JRadioButton small = new JRadioButton("Small"); small.setActionCommand(BUTTON_SIZE_SMALL); small.addActionListener(buttonSizeRadioListener); if (BUTTON_SIZE_SMALL.equals(prefs.getButtonSize())) small.setSelected(true); JRadioButton medium = new JRadioButton("Medium"); medium.setActionCommand(BUTTON_SIZE_MEDIUM); medium.addActionListener(buttonSizeRadioListener); if (BUTTON_SIZE_MEDIUM.equals(prefs.getButtonSize())) medium.setSelected(true); JRadioButton large = new JRadioButton("Large"); large.setActionCommand(BUTTON_SIZE_LARGE); large.addActionListener(buttonSizeRadioListener); if (BUTTON_SIZE_LARGE.equals(prefs.getButtonSize())) large.setSelected(true); ButtonGroup group = new ButtonGroup(); group.add(small); group.add(medium); group.add(large); // Close windows on stop final JCheckBox closeAllWindowsOnStopCheckBox = new JCheckBox("Close all windows on Stop"); closeAllWindowsOnStopCheckBox.setSelected(prefs.isCloseAllWindowsOnStop()); // Refresh interval JPanel refreshIntervalPanel = new JPanel(); final JTextField refreshIntervalField = new JTextField(5); refreshIntervalPanel.add(new JLabel("Refresh interval for cpu, screen, etc. (ms):")); refreshIntervalField.setText("" + prefs.getRefreshIntervalMs()); refreshIntervalPanel.add(refreshIntervalField); // Setup panel options.add(new JLabel("Button size :")); options.add(small); options.add(medium); options.add(large); options.add(closeAllWindowsOnStopCheckBox); options.add(refreshIntervalPanel); options.add(new JLabel("Larger value greatly increases emulation speed")); if (JOptionPane.OK_OPTION == JOptionPane.showOptionDialog(this, options, "Preferences", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null, null, JOptionPane.DEFAULT_OPTION)) { // save prefs.setButtonSize(group.getSelection().getActionCommand()); prefs.setCloseAllWindowsOnStop(closeAllWindowsOnStopCheckBox.isSelected()); int refreshIntervalMs = 0; try { refreshIntervalMs = Integer.parseInt(refreshIntervalField.getText()); } catch (NumberFormatException e) { // noop } refreshIntervalMs = Math.max(Math.min(refreshIntervalMs, 10000), 10); prefs.setRefreshIntervalMs(refreshIntervalMs); applyPrefsToUI(); } }
From source file:com.emental.mindraider.ui.dialogs.AttachmentJDialog.java
/** * Concetructor./*from ww w . j ava2 s . c om*/ * * @param noteResource * The concept resource. * @param dragAndDropReference * The drag'n'drop reference. */ public AttachmentJDialog(ConceptResource conceptResource, DragAndDropReference dragAndDropReference) { super(Messages.getString("AttachmentJDialog.title")); this.conceptResource = conceptResource; getContentPane().setLayout(new BorderLayout()); JPanel p, pp; p = new JPanel(); p.setLayout(new BorderLayout()); JLabel intro = new JLabel("<html> " + Messages.getString("AttachmentJDialog.introduction") + " <br><br></html>"); p.add(intro, BorderLayout.NORTH); p.add(new JLabel("<html> " + Messages.getString("AttachmentJDialog.description") + "</html>"), BorderLayout.CENTER); description = new JTextField(38); pp = new JPanel(new FlowLayout(FlowLayout.LEFT)); pp.add(description); p.add(pp, BorderLayout.SOUTH); getContentPane().add(p, BorderLayout.NORTH); JPanel mainPanel = new JPanel(); mainPanel.setLayout(new BorderLayout()); mainPanel.setBorder(new TitledBorder(Messages.getString("AttachmentJDialog.resource"))); ButtonGroup attachType = new ButtonGroup(); JPanel webPanel = new JPanel(); webPanel.setLayout(new BorderLayout()); webType = new JRadioButton(Messages.getString("AttachmentJDialog.web")); webType.setActionCommand(WEB); webType.addActionListener(this); webType.setSelected(true); attachType.add(webType); webPanel.add(webType, BorderLayout.NORTH); urlTextField = new JTextField("http://", 35); urlTextField.selectAll(); urlTextField.addKeyListener(new KeyListener() { public void keyPressed(KeyEvent keyEvent) { if (keyEvent.getKeyCode() == KeyEvent.VK_ENTER) { attach(); } } public void keyReleased(KeyEvent keyEvent) { } public void keyTyped(KeyEvent keyEvent) { } }); p = new JPanel(); p.setLayout(new FlowLayout(FlowLayout.LEFT)); p.add(new JLabel(" ")); p.add(urlTextField); webPanel.add(p, BorderLayout.SOUTH); mainPanel.add(webPanel, BorderLayout.NORTH); JPanel localPanel = new JPanel(); localPanel.setLayout(new BorderLayout()); JRadioButton localType = new JRadioButton(Messages.getString("AttachmentJDialog.local")); localType.setActionCommand(LOCAL); localType.addActionListener(this); localPanel.add(localType, BorderLayout.NORTH); pathTextField = new JTextField(35); pathTextField.setEnabled(false); browseButton = new JButton(Messages.getString("AttachmentJDialog.browse")); browseButton.setToolTipText(Messages.getString("AttachmentJDialog.browseTip")); browseButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JFileChooser fc = new JFileChooser(); fc.setApproveButtonText(Messages.getString("AttachmentJDialog.attach")); fc.setControlButtonsAreShown(true); fc.setDialogTitle(Messages.getString("AttachmentJDialog.chooseAttachment")); fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); int returnVal = fc.showOpenDialog(AttachmentJDialog.this); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); pathTextField.setText(file.toString()); } } }); browseButton.setEnabled(false); pp = new JPanel(); pp.setLayout(new BorderLayout()); p = new JPanel(); p.setLayout(new FlowLayout(FlowLayout.LEFT)); p.add(new JLabel(" ")); pp.add(p, BorderLayout.NORTH); p.add(pathTextField); p = new JPanel(); p.setLayout(new FlowLayout(FlowLayout.RIGHT)); p.add(browseButton); pp.add(p, BorderLayout.SOUTH); localPanel.add(pp, BorderLayout.SOUTH); attachType.add(localType); mainPanel.add(localPanel, BorderLayout.SOUTH); getContentPane().add(mainPanel, BorderLayout.CENTER); // buttons p = new JPanel(); p.setLayout(new FlowLayout(FlowLayout.CENTER)); JButton addButton = new JButton(Messages.getString("AttachmentJDialog.attach")); p.add(addButton); addButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { attach(); } }); JButton cancelButton = new JButton(Messages.getString("AttachmentJDialog.cancel")); p.add(cancelButton); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AttachmentJDialog.this.dispose(); } }); getContentPane().add(p, BorderLayout.SOUTH); /* * drag and drop initialization */ if (dragAndDropReference != null) { if (dragAndDropReference.getType() == DragAndDropReference.BROWSER_LINK) { urlTextField.setText(dragAndDropReference.getReference()); localType.setSelected(false); webType.setSelected(true); enableWebTypeButtons(); } else { pathTextField.setText(dragAndDropReference.getReference()); localType.setSelected(true); webType.setSelected(false); enableLocalTypeButtons(); } description.setText(dragAndDropReference.getTitle()); } pack(); Gfx.centerAndShowWindow(this); }