private void updatePanels() { jFiltersPanel.removeAll(); GroupLayout groupLayout = new GroupLayout(jFiltersPanel); jFiltersPanel.setLayout(groupLayout); groupLayout.setAutoCreateGaps(true); groupLayout.setAutoCreateContainerGaps(false); ParallelGroup horizontalGroup = groupLayout.createParallelGroup(); SequentialGroup verticalGroup = groupLayout.createSequentialGroup(); for (LocationPanel locationPanel : locationPanels) { horizontalGroup.addComponent(locationPanel.getPanel()); verticalGroup.addComponent(locationPanel.getPanel()); } jFiltersPanel.setVisible(!locationPanels.isEmpty()); groupLayout.setHorizontalGroup(horizontalGroup); groupLayout.setVerticalGroup(verticalGroup); autoValidate(); this.getDialog().pack(); }
private void add(GroupLayout layout, ParallelGroup horizontalGroup, SequentialGroup verticalGroup) { //Layout horizontalGroup .addGroup(layout.createSequentialGroup() .addComponent(jLabel, 75, 75, 75) .addComponent(jBrowse) .addComponent(jReset) .addComponent(jPlay) ); verticalGroup .addGroup(layout.createParallelGroup(GroupLayout.Alignment.CENTER) .addComponent(jLabel) .addComponent(jBrowse) .addComponent(jReset) .addComponent(jPlay) ); }
/** * Generate a vertical list of JFreeCharts * * @param labels * - the labels for the values * @param index * - the index * @param values * @return */ public static String generateJFreeChart(List<String> labels, List<Double> index, List<List<Double>> values) { JPanel panel = new JPanel(); // create a layout GroupLayout layout = new GroupLayout(panel); panel.setLayout(layout); layout.setAutoCreateGaps(true); layout.setAutoCreateContainerGaps(true); SequentialGroup sgv = layout.createSequentialGroup(); layout.setVerticalGroup(sgv); ParallelGroup pgh = layout.createParallelGroup(); layout.setHorizontalGroup(pgh); for (int i = 0; i != labels.size(); i++) { XYSeries xys = new XYSeries(labels.get(i)); for (int j = 0; j != index.size(); j++) { xys.add(index.get(j), values.get(i).get(j)); } XYSeriesCollection xysc = new XYSeriesCollection(xys); JFreeChart chart = ChartFactory.createXYLineChart(labels.get(i), "Time", "Focus", xysc, PlotOrientation.VERTICAL, false, false, false); chart.setBackgroundPaint(Color.white); chart.getTitle().setFont(new Font("Tahoma", Font.BOLD, 14)); ChartPanel cp = new ChartPanel(chart); sgv.addComponent(cp); pgh.addComponent(cp); } JFrame frame = new JFrame(); frame.add(panel); frame.pack(); frame.setVisible(true); return null; }
private ParallelGroup makeHorizontalGroup( GroupLayout layout ) { ParallelGroup removeButtonGroup = layout.createParallelGroup( GroupLayout.Alignment.LEADING ); for ( JButton removeRowButton : removeRowButtons ) { removeButtonGroup.addComponent( removeRowButton ); } removeButtonGroup.addComponent( addRelationshipButton ); ParallelGroup subjectCBGroup = layout.createParallelGroup( GroupLayout.Alignment.LEADING ); subjectCBGroup.addComponent( subjectJLabel ); for ( UriComboBox subjectCB : subjectComboBoxes ) { subjectCBGroup.addComponent( subjectCB ); } subjectCBGroup.addComponent( maxExportLimitLabel ); ParallelGroup relationCBGroup = layout.createParallelGroup( GroupLayout.Alignment.LEADING ); relationCBGroup.addComponent( relationJLabel ); for ( UriComboBox relationCB : relationComboBoxes ) { relationCBGroup.addComponent( relationCB ); } ParallelGroup objectCBGroup = layout.createParallelGroup( GroupLayout.Alignment.LEADING ); objectCBGroup.addComponent( objectJLabel ); for ( UriComboBox objectCB : objectComboBoxes ) { objectCBGroup.addComponent( objectCB ); } ParallelGroup horizontalGroup = layout.createParallelGroup( GroupLayout.Alignment.TRAILING ) .addGroup( layout.createSequentialGroup() .addGroup( removeButtonGroup ) .addGroup( subjectCBGroup ) .addGroup( relationCBGroup ) .addGroup( objectCBGroup ) ) .addGroup( layout.createSequentialGroup() .addComponent( togrid ) .addComponent( exportButton ) ); return horizontalGroup; }
private void doLayout() { autoValidate(); jFilters.removeAll(); GroupLayout layout = new GroupLayout(jFilters); jFilters.setLayout(layout); layout.setAutoCreateGaps(true); layout.setAutoCreateContainerGaps(false); ParallelGroup horizontalGroup = layout.createParallelGroup(); SequentialGroup verticalGroup = layout.createSequentialGroup(); for (FilterPanel ownerPanel : ownerPanels) { horizontalGroup.addComponent(ownerPanel.getPanel()); verticalGroup.addComponent(ownerPanel.getPanel()); } for (FilterPanel flagPanel : flagPanels) { horizontalGroup.addComponent(flagPanel.getPanel()); verticalGroup.addComponent(flagPanel.getPanel()); } for (FilterPanel containerPanel : containerPanels) { horizontalGroup.addComponent(containerPanel.getPanel()); verticalGroup.addComponent(containerPanel.getPanel()); } layout.setVerticalGroup(verticalGroup); layout.setHorizontalGroup(horizontalGroup); getDialog().pack(); }
private GroupLayout makeTweaksLayout(List<JCheckBox> tweaks) { GroupLayout gl = new GroupLayout(miscTweaksPanel); int numTweaks = tweaks.size(); // Handle columns SequentialGroup columnsGroup = gl.createSequentialGroup().addContainerGap(); int numCols = Math.min(TWEAK_COLS, numTweaks); ParallelGroup[] colGroups = new ParallelGroup[numCols]; for (int col = 0; col < numCols; col++) { if (col > 0) { columnsGroup.addGap(18, 18, 18); } colGroups[col] = gl.createParallelGroup(GroupLayout.Alignment.LEADING); columnsGroup.addGroup(colGroups[col]); } for (int tweak = 0; tweak < numTweaks; tweak++) { colGroups[tweak % numCols].addComponent(tweaks.get(tweak)); } columnsGroup.addContainerGap(); gl.setHorizontalGroup(gl.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(columnsGroup)); // And rows SequentialGroup rowsGroup = gl.createSequentialGroup().addContainerGap(); int numRows = (numTweaks - 1) / numCols + 1; ParallelGroup[] rowGroups = new ParallelGroup[numRows]; for (int row = 0; row < numRows; row++) { if (row > 0) { rowsGroup.addPreferredGap(ComponentPlacement.UNRELATED); } rowGroups[row] = gl.createParallelGroup(GroupLayout.Alignment.BASELINE); rowsGroup.addGroup(rowGroups[row]); } for (int tweak = 0; tweak < numTweaks; tweak++) { rowGroups[tweak / numCols].addComponent(tweaks.get(tweak)); } rowsGroup.addContainerGap(); gl.setVerticalGroup(gl.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(rowsGroup)); return gl; }
private void initComponent() { this.initInputComponents(); final GroupLayout groupLayout = new GroupLayout(this); groupLayout.setAutoCreateContainerGaps(true); groupLayout.setAutoCreateGaps(true); this.setLayout(groupLayout); SequentialGroup horizontalGroup = groupLayout.createSequentialGroup(); ParallelGroup first = groupLayout.createParallelGroup(getLabelsAlignment()); ParallelGroup second = groupLayout.createParallelGroup(); ParallelGroup third = groupLayout.createParallelGroup(); parameters.forEach(c -> { first.addComponent(descriptionLabels.get(c)); second.addComponent(inputComponents.get(c)); third.addComponent(helpLabels.get(c)); }); horizontalGroup .addGroup(first) .addGroup(second) .addGroup(third); groupLayout.setHorizontalGroup(horizontalGroup); SequentialGroup verticalGroup = groupLayout.createSequentialGroup(); parameters.forEach(c -> { ParallelGroup current = groupLayout.createParallelGroup(Alignment.CENTER); current.addComponent(descriptionLabels.get(c)); current.addComponent(inputComponents.get(c)); current.addComponent(helpLabels.get(c)); verticalGroup.addGroup(current); }); groupLayout.setVerticalGroup(verticalGroup); }
private void createLayout() { this.setLayout(layout = new GroupLayout(this)); setFloatable(false); SequentialGroup hGroup = layout.createSequentialGroup(); ParallelGroup pGroup = layout.createParallelGroup(GroupLayout.Alignment.BASELINE); boolean isSubst = LookAndFeelManager.isSubstance(); for(int i = 0; i < BUTTONCOUNT; i++) { if (isSubst) { hGroup.addComponent(buttons[i], sizes[i], buttons[i].getPreferredSize().width, Short.MAX_VALUE); pGroup.addComponent(buttons[i], 0, buttons[i].getPreferredSize().height, Short.MAX_VALUE); } else { hGroup.addComponent(buttons[i]); pGroup.addComponent(buttons[i]); } hGroup.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 0, Short.MAX_VALUE); final int fi = i; buttons[i].addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { onClick(fi); } }); } if (isSubst) { hGroup.addGap(4); } layout.setHorizontalGroup(hGroup); layout.setVerticalGroup(pGroup); }
private Group buildAttributesV(GroupLayout layout) { ParallelGroup statsSectionV = layout.createParallelGroup(); statsSectionV.addGroup(layout.createSequentialGroup().addGroup(parallelPair( layout, lblIntelligence, parallelRadioArray(layout, rdoIntelligence))).addGroup(parallelPair( layout, lblWits, parallelRadioArray(layout, rdoWits))).addGroup(parallelPair( layout, lblResolve, parallelRadioArray(layout, rdoResolve)))); statsSectionV.addGroup(layout.createSequentialGroup().addGroup(parallelPair( layout, lblStrength, parallelRadioArray(layout, rdoStrength))).addGroup(parallelPair( layout, lblDexterity, parallelRadioArray(layout, rdoDexterity))).addGroup(parallelPair( layout, lblStamina, parallelRadioArray(layout, rdoStamina)))); statsSectionV.addGroup(layout.createSequentialGroup().addGroup(parallelPair( layout, lblPresence, parallelRadioArray(layout, rdoPresence))).addGroup(parallelPair( layout, lblManipulation, parallelRadioArray(layout, rdoManipulation))).addGroup(parallelPair( layout, lblComposure, parallelRadioArray(layout, rdoComposure)))); return statsSectionV; }
private Group buildDetailsV(GroupLayout layout) { ParallelGroup skillsSectionV = layout.createParallelGroup(); skillsSectionV.addGroup( layout.createSequentialGroup() .addGap(5, 10, 15) .addGroup( parallelPair(layout, parallelPair(layout, lblBackgroud, scrBackground), (parallelPair(layout, lblDescription, scrDescription)))) .addGap(5, 10, 15) .addGroup(layout.createParallelGroup() .addComponent(lblAge) .addComponent(spnAge) .addComponent(lblHeight) .addComponent(txtHeight)) .addGap(5, 10, 15) .addGroup(layout.createParallelGroup() .addComponent(lblApparent) .addComponent(spnApparent) .addComponent(lblWeight) .addComponent(txtWeight)) .addGap(5, 10, 15) .addGroup(layout.createParallelGroup() .addComponent(lblHair) .addComponent(txtHair) .addComponent(lblRace) .addComponent(txtRace)) .addGap(5, 10, 15) .addGroup(layout.createParallelGroup() .addComponent(lblEyes) .addComponent(txtEyes) .addComponent(lblSex) .addComponent(txtSex)) .addGap(5, 10, Short.MAX_VALUE)); return skillsSectionV; }
private Group buildSpecH(GroupLayout layout) { ParallelGroup specSectionH = layout.createParallelGroup( Alignment.CENTER); for (int i = 0; i < cboSpecialty.length; i++) { specSectionH.addGroup(sequentialPair(layout, cboSpecialty[i], txtSpecialty[i])); } return specSectionH; }
private Group buildMeritsH(GroupLayout layout) { ParallelGroup contractsSectionH = layout.createParallelGroup( Alignment.CENTER); for (int i = 0; i < cboMerits.length; i++) { contractsSectionH.addGroup(sequentialPair(layout, cboMerits[i], sequentialRadioArray(layout, rdoMerits[i]))); } return contractsSectionH; }
private Group buildGoblinContractsH(GroupLayout layout) { ParallelGroup contractsSectionH = layout.createParallelGroup( Alignment.CENTER); for (int i = 0; i < cboContracts.length; i++) { contractsSectionH.addGroup(sequentialPair(layout, lblGoblin[i], txtGoblin[i])); } return contractsSectionH; }
private Group buildPledgesH(GroupLayout layout) { ParallelGroup contractsSectionH = layout.createParallelGroup( Alignment.CENTER); contractsSectionH.addComponent(scrPledge); return contractsSectionH; }
private Group buildContractsH(GroupLayout layout) { ParallelGroup contractsSectionH = layout.createParallelGroup( Alignment.CENTER); for (int i = 0; i < cboContracts.length; i++) { contractsSectionH.addGroup(sequentialPair(layout, cboContracts[i], sequentialRadioArray(layout, rdoContracts[i]))); } return contractsSectionH; }
public static ParallelGroup parallelPair( GroupLayout layout, JComponent label, Component editable ) { return layout.createParallelGroup(GroupLayout.Alignment.CENTER) .addComponent(label) .addComponent(editable); }
public static ParallelGroup parallelPair( GroupLayout layout, Component label, Component editable ) { return layout.createParallelGroup(GroupLayout.Alignment.CENTER) .addComponent(label) .addComponent(editable); }
public static ParallelGroup parallelPair( GroupLayout layout, Component label, Group arrayGroup ) { return layout.createParallelGroup(GroupLayout.Alignment.CENTER) .addComponent(label) .addGroup(arrayGroup); }
public static ParallelGroup parallelPair( GroupLayout layout, Group label, Group arrayGroup ) { return layout.createParallelGroup(GroupLayout.Alignment.CENTER) .addGroup(label) .addGroup(arrayGroup); }
public static ParallelGroup parallelRadioArray( GroupLayout layout, Component[] array ) { ParallelGroup rtn = layout.createParallelGroup(); for ( int i = 0; i < array.length; i++ ) { rtn.addComponent(array[i]); } return rtn; }
@Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { JPanel panel = new JPanel(); if (value instanceof String[]) { String[] valueArray = (String[]) value; if (valueArray.length == 0) return panel; GroupLayout layout = new GroupLayout(panel); panel.setLayout(layout); layout.setAutoCreateGaps(true); layout.setAutoCreateContainerGaps(true); SequentialGroup cols = layout.createSequentialGroup(); layout.setHorizontalGroup(cols); ParallelGroup col1 = layout .createParallelGroup(GroupLayout.Alignment.LEADING); ParallelGroup col2 = layout .createParallelGroup(GroupLayout.Alignment.TRAILING); cols.addGroup(col1) .addPreferredGap( LayoutStyle.ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(col2); SequentialGroup rows = layout.createSequentialGroup(); layout.setVerticalGroup(rows); for (int i = 0; i < valueArray.length; i++) { // the value array has null elements for // IdResource/Demand if (valueArray[i] != null) { /* TODO: Fix ArrayIndexOutofBounds Exception here * Update: Problem is actually above. Probably linked to resources without setters. */ //System.out.println("ValueArray: " + valueArray[i]); //for (int j = 0; j < resParamNames.size(); j++) { System.out.println("resParamNames: " + resParamNames.get(j)); } JLabel label = new JLabel(); if (resParamNames.get(row).length == 0) label.setText("max. param"); else label.setText("max. " + resParamNames.get(row)[i]); JTextField tf = new JTextField(3); tf.setText(valueArray[i]); col1.addComponent(label); col2.addComponent(tf, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE); rows.addGroup(layout .createParallelGroup( GroupLayout.Alignment.CENTER) .addComponent(label).addComponent(tf)); } } } table.setRowHeight(row, Math.max(table.getRowHeight(row), (int) panel.getPreferredSize().getHeight())); TableColumn cm = table.getColumnModel().getColumn(column); cm.setMinWidth(Math.max(cm.getMinWidth(), (int) panel .getPreferredSize().getWidth())); return panel; }
@Override public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { panel = new JPanel(); if (value instanceof String[]) { String[] valueArray = (String[]) value; if (valueArray.length == 0) return panel; GroupLayout layout = new GroupLayout(panel); panel.setLayout(layout); layout.setAutoCreateGaps(true); layout.setAutoCreateContainerGaps(true); SequentialGroup cols = layout.createSequentialGroup(); layout.setHorizontalGroup(cols); ParallelGroup col1 = layout .createParallelGroup(GroupLayout.Alignment.LEADING); ParallelGroup col2 = layout .createParallelGroup(GroupLayout.Alignment.TRAILING); cols.addGroup(col1) .addPreferredGap( LayoutStyle.ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(col2); SequentialGroup rows = layout.createSequentialGroup(); layout.setVerticalGroup(rows); for (int i = 0; i < valueArray.length; i++) { // create the label. use the resource param name for both // resource and demand params as it should be the same. TODO JLabel label = new JLabel(); if (resParamNames.get(row).length == 0) label.setText("max. param"); else label.setText("max. " + resParamNames.get(row)[i]); JTextField tf = new JTextField(3); tf.setText(valueArray[i]); tf.setEditable(true); col1.addComponent(label); col2.addComponent(tf, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE); rows.addGroup(layout .createParallelGroup(GroupLayout.Alignment.CENTER) .addComponent(label).addComponent(tf)); } } table.setRowHeight(row, Math.max(table.getRowHeight(row), (int) panel.getPreferredSize().getHeight())); TableColumn cm = table.getColumnModel().getColumn(column); cm.setMinWidth(Math.max(cm.getMinWidth(), (int) panel .getPreferredSize().getWidth())); return panel; }
void setLayoutGroups(GroupLayout.ParallelGroup horizontalGroup, GroupLayout.SequentialGroup verticalGroup) { this.horizontalGroup = horizontalGroup; this.verticalGroup = verticalGroup; }
/** * Generates the graph which plots the three choice scores (independent, * dependent and mood) for the evolution of a choice in time. * * @param tdc * - encompasses the selected choice * @param database * - the database of values collected * @param agent * @param index * - a list of time points which will be plotted on the x axis * @param choiceRange * - the y axis will be [0, choiceRange] */ public static void graphChoiceEvolution(tdComponent tdc, tdDataBase database, Agent agent, List<Double> index, double choiceRange) { String label = xwChoice.xwConcise(new TwFormatter(), tdc.getChoice(), agent); // create a general purpose xy collection for jfreechart XYSeriesCollection xysc = new XYSeriesCollection(); // focus and memory xysc.addSeries(new XYSeries("ChoiceScoreIndependent")); xysc.addSeries(new XYSeries("ChoiceScoreDependent")); xysc.addSeries(new XYSeries("ChoiceScoreMood")); // Fill in the values for (Double time : index) { double dtime = time; double valueChoiceScoreIndependent = database.getChoiceScoreDependent(tdc.getIdentifier(), time); xysc.getSeries("ChoiceScoreIndependent").add(dtime, valueChoiceScoreIndependent); double valueChoiceScoreDependent = database.getChoiceScoreDependent(tdc.getIdentifier(), time); xysc.getSeries("ChoiceScoreDependent").add(dtime, valueChoiceScoreDependent); double valueChoiceScoreMood = database.getChoiceScoreDependent(tdc.getIdentifier(), time); xysc.getSeries("ChoiceScoreMood").add(dtime, valueChoiceScoreMood); } // // ok, now let us create a graph // JPanel panel = new JPanel(); // create a layout GroupLayout layout = new GroupLayout(panel); panel.setLayout(layout); layout.setAutoCreateGaps(true); layout.setAutoCreateContainerGaps(true); SequentialGroup sgv = layout.createSequentialGroup(); layout.setVerticalGroup(sgv); ParallelGroup pgh = layout.createParallelGroup(); layout.setHorizontalGroup(pgh); // // the graph with the focus and the memory // XYSeriesCollection xysFM = new XYSeriesCollection(); xysFM.addSeries(xysc.getSeries("ChoiceScoreIndependent")); xysFM.addSeries(xysc.getSeries("ChoiceScoreDependent")); xysFM.addSeries(xysc.getSeries("ChoiceScoreMood")); JFreeChart chart = ChartFactory.createXYLineChart(label + " - Choice", "Time", "Value", xysFM, PlotOrientation.VERTICAL, true, false, false); GraphEvolution.setChartProperties(chart, GraphEvolution.lineStylesColorful); ChartPanel cp = new ChartPanel(chart); sgv.addComponent(cp); pgh.addComponent(cp); JFrame frame = new JFrame(); frame.add(panel); frame.pack(); frame.setVisible(true); }
/** * Graphs the evolution of the links of all types (PRED, SUCC, SUMMARY, * CONTEXT etc) between two Vis. * * @param fromVi * @param toVi * @param tdb * @param agent * @param index * - a list of time points which will be plotted on the x axis */ public static void graphLinksBetweenVis(tdComponent fromVi, tdComponent toVi, tdDataBase tdb, Agent agent, List<Double> index) { String label = "Links between " + fromVi.getIdentifier() + " and " + toVi.getIdentifier(); // create a general purpose xy collection for jfreechart XYSeriesCollection xysc = new XYSeriesCollection(); // add a series for each link type for (String linkName : agent.getLinks().getLinkTypeNames()) { XYSeries linkSeries = new XYSeries(linkName); xysc.addSeries(linkSeries); // now fill in the series with values for (Double time : index) { double dtime = time; double linkValue = tdb.getLinkValue(fromVi.getIdentifier(), toVi.getIdentifier(), linkName, time); linkSeries.add(dtime, linkValue); } } // // ok, now let us create a graph // JPanel panel = new JPanel(); // create a layout GroupLayout layout = new GroupLayout(panel); panel.setLayout(layout); layout.setAutoCreateGaps(true); layout.setAutoCreateContainerGaps(true); SequentialGroup sgv = layout.createSequentialGroup(); layout.setVerticalGroup(sgv); ParallelGroup pgh = layout.createParallelGroup(); layout.setHorizontalGroup(pgh); JFreeChart chart = ChartFactory.createXYLineChart(label, "Time", "Value", xysc, PlotOrientation.VERTICAL, true, false, false); GraphEvolution.setChartProperties(chart, GraphEvolution.lineStylesColorful); ChartPanel cp = new ChartPanel(chart); sgv.addComponent(cp); pgh.addComponent(cp); JFrame frame = new JFrame(); frame.add(panel); frame.pack(); frame.setVisible(true); }
private void displayDecisionVariables() { Panel dvPanel = new Panel(); ScrollPane scrollPane = new ScrollPane(); GroupLayout dvlayout = new GroupLayout(dvPanel); dvlayout.setAutoCreateGaps(true); dvlayout.setAutoCreateContainerGaps(true); ParallelGroup groupForElementsInLine = dvlayout.createParallelGroup(Alignment.LEADING); SequentialGroup groupForElementsInColumns = dvlayout.createSequentialGroup(); for (Displayable displayable : decisionVariables) { List<InfoGUI> infos = displayable.getInfo(); for (InfoGUI infoGUI : infos) { DecisionVariableGUI dvGui1 = new DecisionVariableGUI(infoGUI); groupForElementsInLine.addGroup((dvlayout.createSequentialGroup().addComponent(dvGui1.getLabel()) .addComponent(dvGui1.getComponent()))); groupForElementsInColumns.addGroup((dvlayout.createParallelGroup(Alignment.CENTER) .addComponent(dvGui1.getLabel()).addComponent(dvGui1.getComponent()))); mapWithControls.add(dvGui1); } } dvlayout.setHorizontalGroup(groupForElementsInLine); dvlayout.setVerticalGroup(groupForElementsInColumns); dvPanel.setLayout(dvlayout); dvPanel.setBackground(Color.lightGray); Collections.sort(mapWithControls); Dimension scrollPaneDimension = new Dimension(dvPanel.getPreferredSize().width + 30, dvPanel.getPreferredSize().height + 35); scrollPane.setPreferredSize(new Dimension(250, 700)); if (scrollPaneDimension.height < scrollPane.getPreferredSize().height) { scrollPane.setPreferredSize(scrollPaneDimension); } scrollPane.add(dvPanel); controlPanel.add(scrollPane); }
/** * Update the controls of the detail panel. */ void updateDetails() { bottomPanel.removeAll(); GroupLayout gl = (GroupLayout)bottomPanel.getLayout(); ParallelGroup c1 = gl.createParallelGroup(); ParallelGroup c2 = gl.createParallelGroup(); SequentialGroup r1 = gl.createSequentialGroup(); c1.addComponent(keyLabel); c2.addComponent(keyField); r1.addGroup( gl.createParallelGroup(Alignment.BASELINE) .addComponent(keyLabel) .addComponent(keyField, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE) ); textAreas.clear(); for (final String lang : context.dataManager().languages()) { JLabel lbl = new JLabel(lang); JTextArea ta = new JTextArea(); final CEValueBox<JTextArea> vta = CEValueBox.of("", ta); vta.validator = new Action1<JTextArea>() { @Override public void invoke(JTextArea value) { validateLabelField(vta); } }; textAreas.put(lang, vta); c1.addComponent(lbl); c2.addComponent(vta); r1.addGroup( gl.createParallelGroup(Alignment.BASELINE) .addComponent(lbl) .addComponent(vta, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE) ); } gl.setHorizontalGroup( gl.createSequentialGroup() .addGroup(c1) .addGroup(c2) ); gl.setVerticalGroup( r1 ); }
/** @return The referenced main data files panel. */ JPanel createReferencesPanel() { JPanel p = new JPanel(); GroupLayout gl = new GroupLayout(p); p.setLayout(gl); gl.setAutoCreateContainerGaps(true); gl.setAutoCreateGaps(true); SequentialGroup rows = gl.createSequentialGroup(); ParallelGroup col1 = gl.createParallelGroup(); ParallelGroup col2 = gl.createParallelGroup(); ParallelGroup col3 = gl.createParallelGroup(); for (String a : ELEMENT_NAMES) { JLabel indicator = new JLabel(); JLabel caption = new JLabel(get("definition.ref_" + a)); JTextField textField = new JTextField(); indicators.put(a, indicator); fields.put(a, textField); ParallelGroup pg = gl.createParallelGroup(Alignment.BASELINE); col1.addComponent(caption); col2.addComponent(textField); col3.addComponent(indicator, 20, 20, 20); pg.addComponent(caption); pg.addComponent(textField, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE); pg.addComponent(indicator, 20, 20, 20); rows.addGroup(pg); } gl.setHorizontalGroup( gl.createSequentialGroup() .addGroup(col1) .addGroup(col2) .addGroup(col3) ); gl.setVerticalGroup(rows); return p; }
/** * @return the properties listing panel */ JPanel createPropertiesPanel() { JPanel p = new JPanel(); GroupLayout gl = new GroupLayout(p); p.setLayout(gl); gl.setAutoCreateContainerGaps(true); gl.setAutoCreateGaps(true); SequentialGroup rows = gl.createSequentialGroup(); ParallelGroup col1 = gl.createParallelGroup(); ParallelGroup col2 = gl.createParallelGroup(); ParallelGroup col3 = gl.createParallelGroup(); for (String a : PARAM_NAMES) { JLabel indicator = new JLabel(); JLabel caption = new JLabel(get("definition.refprop_" + a)); JTextField textField = new JTextField(10); textField.setHorizontalAlignment(JTextField.RIGHT); caption.setToolTipText(get("definition.refprop_" + a + ".tip")); textField.setToolTipText(get("definition.refprop_" + a + ".tip")); indicators.put(a, indicator); fields.put(a, textField); ParallelGroup pg = gl.createParallelGroup(Alignment.BASELINE); col1.addComponent(caption); col2.addComponent(textField, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE); col3.addComponent(indicator, 20, 20, 20); pg.addComponent(caption); pg.addComponent(textField, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE); pg.addComponent(indicator, 20, 20, 20); rows.addGroup(pg); } gl.setHorizontalGroup( gl.createSequentialGroup() .addGroup(col1) .addGroup(col2) .addGroup(col3) ); gl.setVerticalGroup(rows); return p; }
/** * Initializes this panel with GroupLayout and two groups: * <ul> * <li>horizontal group which has two sub-groups: one for labels and one * for spinners. This group positions the elements in two columns.</li> * <li>vertical group which has 3 sub-groups - one for every row: * <ul> * <li>label and {@link #getStartTimeSpinner() spinner} which contains the * the point in time (seconds) where the selection starts,</li> * <li>label and {@link #getLengthSpinner() spinner} which contains the * length in seconds of the selection, * <li>if {@link #withChannelSelection} is set - label and {@link * #getChannelComboBox() combo-box} which allows to select the channel * for the selection (from the list of names)</li></ul> * This group positions elements in rows.</li> * </ul> */ private void initialize() { setBorder(new EmptyBorder(3,3,3,3)); GroupLayout layout = new GroupLayout(this); this.setLayout(layout); layout.setAutoCreateContainerGaps(false); layout.setAutoCreateGaps(true); JLabel channelLabel = new JLabel(_("Channel")); JLabel startTimeLabel = new JLabel(_("Start time")); JLabel lengthLabel = new JLabel(_("Length (seconds)")); GroupLayout.SequentialGroup hGroup = layout.createSequentialGroup(); ParallelGroup group = layout.createParallelGroup(); if (withChannelSelection) { group.addComponent(channelLabel); } group.addComponent(startTimeLabel); group.addComponent(lengthLabel); hGroup.addGroup(group); group = layout.createParallelGroup(); if (withChannelSelection) { group.addComponent(getChannelComboBox()); } group.addComponent(getStartTimeSpinner()); group.addComponent(getLengthSpinner()); hGroup.addGroup(group); layout.setHorizontalGroup(hGroup); GroupLayout.SequentialGroup vGroup = layout.createSequentialGroup(); if (withChannelSelection) { vGroup.addGroup( layout.createParallelGroup(Alignment.BASELINE) .addComponent(channelLabel) .addComponent(getChannelComboBox()) ); } vGroup.addGroup( layout.createParallelGroup(Alignment.BASELINE) .addComponent(startTimeLabel) .addComponent(getStartTimeSpinner()) ); vGroup.addGroup( layout.createParallelGroup(Alignment.BASELINE) .addComponent(lengthLabel) .addComponent(getLengthSpinner()) ); layout.setVerticalGroup(vGroup); }
private void initialize() { setLayout(new BorderLayout()); CompoundBorder border = new CompoundBorder( new TitledBorder(_("Artifact types & sensitivity")), new EmptyBorder(3,3,3,3) ); setBorder(border); JPanel typesPanel = new JPanel(); typesPanel.setBorder(new EmptyBorder(5,0,0,0)); GroupLayout layout = new GroupLayout(typesPanel); typesPanel.setLayout(layout); layout.setAutoCreateContainerGaps(false); layout.setAutoCreateGaps(true); GroupLayout.SequentialGroup hGroup = layout.createSequentialGroup(); GroupLayout.SequentialGroup vGroup = layout.createSequentialGroup(); ParallelGroup checkBoxParallelGroup = layout.createParallelGroup(); ParallelGroup textFieldParallelGroup = layout.createParallelGroup(); ParallelGroup scrollBarParallelGroup = layout.createParallelGroup(Alignment.TRAILING); JCheckBox[] checkBoxes = getArtifactTypeCheckBoxes(); JScrollBar[] scrollBars = getSensitivityScrollBars(); JTextField[] textFields = getSensitivityTextFields(); for (int i=0; i<artifactTypes.length; i++) { vGroup.addGroup( layout.createParallelGroup(Alignment.CENTER) .addComponent(checkBoxes[i]) .addComponent(textFields[i]) .addComponent(scrollBars[i]) ); checkBoxParallelGroup.addComponent(checkBoxes[i]); textFieldParallelGroup.addComponent(textFields[i]); scrollBarParallelGroup.addComponent(scrollBars[i]); checkBoxes[i].addItemListener(new CheckBoxListener(i)); textFields[i].addFocusListener(new TextFieldListener(i)); scrollBars[i].addAdjustmentListener(new ScrollBarListener(i)); } hGroup.addGroup(checkBoxParallelGroup); hGroup.addGroup(textFieldParallelGroup); hGroup.addGroup(scrollBarParallelGroup); layout.setHorizontalGroup(hGroup); layout.setVerticalGroup(vGroup); add(typesPanel, BorderLayout.CENTER); }
@Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { JPanel panel = new JPanel(); if (value instanceof String[]) { String[] valueArray = (String[]) value; if (valueArray.length == 0) return panel; GroupLayout layout = new GroupLayout(panel); panel.setLayout(layout); layout.setAutoCreateGaps(true); layout.setAutoCreateContainerGaps(true); SequentialGroup cols = layout.createSequentialGroup(); layout.setHorizontalGroup(cols); ParallelGroup col1 = layout .createParallelGroup(GroupLayout.Alignment.LEADING); ParallelGroup col2 = layout .createParallelGroup(GroupLayout.Alignment.TRAILING); cols.addGroup(col1) .addPreferredGap( LayoutStyle.ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(col2); SequentialGroup rows = layout.createSequentialGroup(); layout.setVerticalGroup(rows); for (int i = 0; i < valueArray.length; i++) { // the value array has null elements for // IdResource/Demand if (valueArray[i] != null) { JLabel label = new JLabel("max. " + resParamNames.get(row)[i]); JTextField tf = new JTextField(3); tf.setText(valueArray[i]); col1.addComponent(label); col2.addComponent(tf, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE); rows.addGroup(layout .createParallelGroup( GroupLayout.Alignment.CENTER) .addComponent(label).addComponent(tf)); } } } table.setRowHeight(row, Math.max(table.getRowHeight(row), (int) panel.getPreferredSize().getHeight())); TableColumn cm = table.getColumnModel().getColumn(column); cm.setMinWidth(Math.max(cm.getMinWidth(), (int) panel .getPreferredSize().getWidth())); return panel; }
@Override public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { panel = new JPanel(); if (value instanceof String[]) { String[] valueArray = (String[]) value; if (valueArray.length == 0) return panel; GroupLayout layout = new GroupLayout(panel); panel.setLayout(layout); layout.setAutoCreateGaps(true); layout.setAutoCreateContainerGaps(true); SequentialGroup cols = layout.createSequentialGroup(); layout.setHorizontalGroup(cols); ParallelGroup col1 = layout .createParallelGroup(GroupLayout.Alignment.LEADING); ParallelGroup col2 = layout .createParallelGroup(GroupLayout.Alignment.TRAILING); cols.addGroup(col1) .addPreferredGap( LayoutStyle.ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(col2); SequentialGroup rows = layout.createSequentialGroup(); layout.setVerticalGroup(rows); for (int i = 0; i < valueArray.length; i++) { // create the label. use the resource param name for both // resource and demand params as it should be the same. JLabel label = new JLabel("max. " + resParamNames.get(row)[i]); JTextField tf = new JTextField(3); tf.setText(valueArray[i]); tf.setEditable(true); col1.addComponent(label); col2.addComponent(tf, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE); rows.addGroup(layout .createParallelGroup(GroupLayout.Alignment.CENTER) .addComponent(label).addComponent(tf)); } } table.setRowHeight(row, Math.max(table.getRowHeight(row), (int) panel.getPreferredSize().getHeight())); TableColumn cm = table.getColumnModel().getColumn(column); cm.setMinWidth(Math.max(cm.getMinWidth(), (int) panel .getPreferredSize().getWidth())); return panel; }
public final void clear(){ this.removeAll(); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); ParallelGroup horizontal = layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING); horizontal.addGap(0); SequentialGroup vertical = layout.createSequentialGroup(); vertical.addGap(0); layout.setHorizontalGroup(horizontal); layout.setVerticalGroup(vertical); this.validate(); this.enabled = false; }
@Override public JPanel getNewAnsweringPanel() { LikertskalaQuestion question = (LikertskalaQuestion) super.getQuestion(); radioGroup = new ButtonGroup(); radioList = new ArrayList<JRadioButton>(); JLabel minJLabel = new JLabel(question.getLeftLabel()); minJLabel.setHorizontalAlignment(SwingConstants.RIGHT); JLabel maxJLabel = new JLabel(question.getRightLabel()); JRadioButton button; JPanel answer = new JPanel(); GroupLayout layout = new GroupLayout(answer); answer.setLayout(layout); layout.setAutoCreateGaps(true); SequentialGroup hoGrp = layout.createSequentialGroup(); ParallelGroup veGrp = layout.createParallelGroup(GroupLayout.Alignment.BASELINE); hoGrp.addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE); hoGrp.addComponent(minJLabel); veGrp.addComponent(minJLabel); for (int i = 0; i < question.getCountOptions(); i++) { button = new JRadioButton(""); button.setName(String.valueOf(i)); radioGroup.add(button); radioList.add(button); hoGrp.addComponent(button, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE); veGrp.addComponent(button); } hoGrp.addComponent(maxJLabel); veGrp.addComponent(maxJLabel); layout.linkSize(SwingConstants.HORIZONTAL, minJLabel, maxJLabel); hoGrp.addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE); layout.setHorizontalGroup(hoGrp); layout.setVerticalGroup(veGrp); return answer; }
private Group buildSkillsV(GroupLayout layout) { ParallelGroup skillsSectionV = layout.createParallelGroup( GroupLayout.Alignment.CENTER); // Mental skillsSectionV.addGroup(layout.createSequentialGroup().addGroup( parallelPair(layout, lblAcademics, parallelRadioArray( layout, rdoAcademics))).addGroup(parallelPair(layout, lblComputer, parallelRadioArray( layout, rdoComputer))).addGroup(parallelPair(layout, lblCrafts, parallelRadioArray( layout, rdoCrafts))).addGroup(parallelPair(layout, lblInvestigation, parallelRadioArray( layout, rdoInvestigation))).addGroup(parallelPair(layout, lblMedicine, parallelRadioArray( layout, rdoMedicine))).addGroup(parallelPair(layout, lblOccult, parallelRadioArray( layout, rdoOccult))).addGroup(parallelPair(layout, lblPolitics, parallelRadioArray( layout, rdoPolitics))).addGroup(parallelPair(layout, lblScience, parallelRadioArray( layout, rdoScience)))); // Physical skillsSectionV.addGroup(layout.createSequentialGroup().addGroup(parallelPair( layout, lblAthletics, parallelRadioArray( layout, rdoAthletics))).addGroup(parallelPair(layout, lblBrawl, parallelRadioArray( layout, rdoBrawl))).addGroup(parallelPair(layout, lblDrive, parallelRadioArray( layout, rdoDrive))).addGroup(parallelPair(layout, lblFirearms, parallelRadioArray( layout, rdoFirearms))).addGroup(parallelPair(layout, lblLarceny, parallelRadioArray( layout, rdoLarceny))).addGroup(parallelPair(layout, lblStealth, parallelRadioArray( layout, rdoStealth))).addGroup(parallelPair(layout, lblSurvival, parallelRadioArray( layout, rdoSurvival))).addGroup(parallelPair(layout, lblWeaponry, parallelRadioArray( layout, rdoWeaponry)))); // Social skillsSectionV.addGroup(layout.createSequentialGroup().addGroup(parallelPair( layout, lblAnimalKen, parallelRadioArray( layout, rdoAnimalKen))).addGroup(parallelPair(layout, lblEmpathy, parallelRadioArray( layout, rdoEmpathy))).addGroup(parallelPair(layout, lblExpression, parallelRadioArray( layout, rdoExpression))).addGroup(parallelPair(layout, lblIntimidation, parallelRadioArray( layout, rdoIntimidation))).addGroup(parallelPair(layout, lblPersuasion, parallelRadioArray( layout, rdoPersuasion))).addGroup(parallelPair(layout, lblSocialize, parallelRadioArray( layout, rdoSocialize))).addGroup(parallelPair(layout, lblStreetwise, parallelRadioArray( layout, rdoStreetwise))).addGroup(parallelPair(layout, lblSubterfuge, parallelRadioArray( layout, rdoSubterfuge)))); return skillsSectionV; }