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) ); }
private Group buildSpecV(GroupLayout layout) { SequentialGroup specSectionV = layout.createSequentialGroup(); specSectionV.addGap(5, 10, 15); for (int i = 0; i < cboSpecialty.length; i++) { specSectionV.addGroup(parallelPair(layout, cboSpecialty[i], txtSpecialty[i])); if (i == cboSpecialty.length - 1) { specSectionV.addGap(5, 10, Short.MAX_VALUE); } else { specSectionV.addGap(5, 10, 15); } } return specSectionV; }
private Group buildMeritsV(GroupLayout layout) { SequentialGroup contractsSectionV = layout.createSequentialGroup(); contractsSectionV.addGap(5, 10, 15); for (int i = 0; i < cboMerits.length; i++) { contractsSectionV.addGroup(parallelPair(layout, cboMerits[i], parallelRadioArray(layout, rdoMerits[i]))); if (i == rdoContracts.length - 1) { contractsSectionV.addGap(5, 10, Short.MAX_VALUE); } else { contractsSectionV.addGap(5, 10, 15); } } return contractsSectionV; }
private Group buildGoblinContractsV(GroupLayout layout) { SequentialGroup contractsSectionV = layout.createSequentialGroup(); contractsSectionV.addGap(5, 10, 15); for (int i = 0; i < cboContracts.length; i++) { contractsSectionV.addGroup(parallelPair(layout, lblGoblin[i], txtGoblin[i])); if (i == rdoContracts.length - 1) { contractsSectionV.addGap(5, 10, Short.MAX_VALUE); } else { contractsSectionV.addGap(5, 10, 15); } } return contractsSectionV; }
private Group buildContractsV(GroupLayout layout) { SequentialGroup contractsSectionV = layout.createSequentialGroup(); contractsSectionV.addGap(5, 10, 15); for (int i = 0; i < cboContracts.length; i++) { contractsSectionV.addGroup(parallelPair(layout, cboContracts[i], parallelRadioArray(layout, rdoContracts[i]))); if (i == rdoContracts.length - 1) { contractsSectionV.addGap(5, 10, Short.MAX_VALUE); } else { contractsSectionV.addGap(5, 10, 15); } } return contractsSectionV; }
/** * 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 SequentialGroup makeVerticalGroup( GroupLayout layout ) { SequentialGroup verticalGroup = layout.createSequentialGroup(); verticalGroup.addGroup( layout.createParallelGroup( GroupLayout.Alignment.BASELINE ) .addComponent( subjectJLabel ) .addComponent( relationJLabel ) .addComponent( objectJLabel ) ); for ( int i = 0; i < Constants.MAX_EXPORTS; i++ ) { verticalGroup.addGroup( layout.createParallelGroup( GroupLayout.Alignment.BASELINE ) .addComponent( removeRowButtons.get( i ) ) .addComponent( subjectComboBoxes.get( i ) ) .addComponent( relationComboBoxes.get( i ) ) .addComponent( objectComboBoxes.get( i ) ) ); } verticalGroup.addComponent( maxExportLimitLabel ); verticalGroup.addGroup( layout.createParallelGroup( GroupLayout.Alignment.BASELINE ) .addComponent( addRelationshipButton ) .addComponent( togrid ) .addComponent( exportButton ) ); return verticalGroup; }
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 JPanel getInputPanel(){ if(panelInput == null){ panelInput = new JPanel(); panelInput.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); GroupLayout layout = new GroupLayout(panelInput); panelInput.setLayout(layout); layout.setAutoCreateGaps(true); layout.setAutoCreateContainerGaps(true); SequentialGroup horizGroup = layout.createSequentialGroup(); JLabel inputFileLabel = new JLabel("Input file:"); inputFileLabel.setPreferredSize(new Dimension(100,30)); inputFileLabel.setHorizontalAlignment(SwingConstants.TRAILING); JLabel inputFormatLabel = new JLabel("Input format:"); inputFormatLabel.setPreferredSize(new Dimension(100,30)); inputFormatLabel.setHorizontalAlignment(SwingConstants.TRAILING); horizGroup.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addComponent(inputFileLabel).addComponent(inputFormatLabel)); horizGroup.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addComponent(getPNPathField()).addComponent(getFormatBox())); horizGroup.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addComponent(getBrowseButton())); layout.setHorizontalGroup(horizGroup); SequentialGroup verticalGroup = layout.createSequentialGroup(); verticalGroup.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(inputFileLabel).addComponent(getPNPathField()).addComponent(getBrowseButton())); verticalGroup.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(inputFormatLabel).addComponent(getFormatBox())); layout.setVerticalGroup(verticalGroup); } return panelInput; }
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); }
/** * Creates non-setting related components and composes the window's layout. * * @param listener the object listening for changes to the preferences * @param controller the controller in charge of restarting the application if need be */ private void initWindow(UIPreferencesChangeListener listener, ApplicationController controller) { /* Create minor components. */ JLabel themeLabel = new JLabel(MessageBundle.get("pref.theme")); themeLabel.setLabelFor(themeCB); JLabel localeLabel = new JLabel(MessageBundle.get("pref.lang")); localeLabel.setLabelFor(localeCB); JButton saveBtn = new JButton(MessageBundle.get("action.save")); saveBtn.addActionListener(new SaveButtonListener(listener, controller)); JButton cancelBtn = new JButton(MessageBundle.get("action.cancel")); cancelBtn.addActionListener(new CancelButtonListener()); /* Create the layout. */ GroupLayout layout = new GroupLayout(this); setLayout(layout); layout.setAutoCreateGaps(true); layout.setAutoCreateContainerGaps(true); SequentialGroup comboBoxesHorizontalGroup = layout.createSequentialGroup() .addGroup(layout.createParallelGroup().addComponent(localeLabel).addComponent(themeLabel)) .addGroup(layout.createParallelGroup().addComponent(localeCB).addComponent(themeCB)); layout.setHorizontalGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(comboBoxesHorizontalGroup) .addComponent(onTopCheckBox)) .addGap(STD_GAP).addGroup(layout.createParallelGroup().addComponent(saveBtn).addComponent(cancelBtn))); layout.setVerticalGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(localeLabel) .addComponent(localeCB).addComponent(saveBtn)) .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(themeLabel) .addComponent(themeCB).addComponent(cancelBtn)) .addComponent(onTopCheckBox)); layout.linkSize(saveBtn, cancelBtn); }
private Group buildAttributesH(GroupLayout layout) { SequentialGroup statsSectionH = layout.createSequentialGroup(); statsSectionH.addGap(10, 75, Short.MAX_VALUE); statsSectionH.addGroup(layout.createParallelGroup().addGroup(sequentialPair( layout, lblIntelligence, sequentialRadioArray(layout, rdoIntelligence))).addGroup(sequentialPair( layout, lblWits, sequentialRadioArray(layout, rdoWits))).addGroup(sequentialPair( layout, lblResolve, sequentialRadioArray(layout, rdoResolve)))); statsSectionH.addGap(10, 15, 50); statsSectionH.addGroup(layout.createParallelGroup().addGroup(sequentialPair( layout, lblStrength, sequentialRadioArray(layout, rdoStrength))).addGroup(sequentialPair( layout, lblDexterity, sequentialRadioArray(layout, rdoDexterity))).addGroup(sequentialPair( layout, lblStamina, sequentialRadioArray(layout, rdoStamina)))); statsSectionH.addGap(10, 15, 50); statsSectionH.addGroup(layout.createParallelGroup().addGroup(sequentialPair( layout, lblPresence, sequentialRadioArray(layout, rdoPresence))).addGroup(sequentialPair( layout, lblManipulation, sequentialRadioArray(layout, rdoManipulation))).addGroup(sequentialPair( layout, lblComposure, sequentialRadioArray(layout, rdoComposure)))); statsSectionH.addGap(10, 75, Short.MAX_VALUE); return statsSectionH; }
private Group buildDetailsH(GroupLayout layout) { SequentialGroup skillsSectionH = layout.createSequentialGroup(); skillsSectionH.addGap(5, 15, Short.MAX_VALUE); skillsSectionH.addGroup( layout.createParallelGroup(GroupLayout.Alignment.CENTER) .addGroup( sequentialPair(layout, sequentialPair(layout, lblBackgroud, scrBackground), sequentialPair(layout, lblDescription, scrDescription))) .addGap(5, 15, Short.MAX_VALUE) .addGroup( sequentialPair(layout, sequentialPair(layout, lblAge, spnAge), sequentialPair(layout, lblHeight, txtHeight))) .addGap(5, 15, Short.MAX_VALUE) .addGroup( sequentialPair(layout, sequentialPair(layout, lblApparent, spnApparent), sequentialPair(layout, lblWeight, txtWeight))) .addGap(5, 15, Short.MAX_VALUE) .addGroup( sequentialPair(layout, sequentialPair(layout, lblHair, txtHair), sequentialPair(layout, lblRace, txtRace))) .addGap(5, 15, Short.MAX_VALUE) .addGroup( sequentialPair(layout, sequentialPair(layout, lblEyes, txtEyes), sequentialPair(layout, lblSex, txtSex)))); skillsSectionH.addGap(5, 15, Short.MAX_VALUE); return skillsSectionH; }
private Group buildPledgesV(GroupLayout layout) { SequentialGroup contractsSectionV = layout.createSequentialGroup(); contractsSectionV.addGap(5, 10, 15); contractsSectionV.addComponent(scrPledge); contractsSectionV.addGap(5, 10, 15); return contractsSectionV; }
public static SequentialGroup sequentialPair( GroupLayout layout, JComponent label, Component editable ) { return layout.createSequentialGroup() .addComponent(label) .addComponent(editable); }
public static SequentialGroup sequentialPair( GroupLayout layout, Component label, Component editable ) { return layout.createSequentialGroup() .addComponent(label) .addComponent(editable); }
public static SequentialGroup sequentialPair( GroupLayout layout, Component label, Group arrayGroup ) { return layout.createSequentialGroup() .addComponent(label) .addGroup(arrayGroup); }
public static SequentialGroup sequentialPair( GroupLayout layout, Group label, Group arrayGroup ) { return layout.createSequentialGroup() .addGroup(label) .addGroup(arrayGroup); }
public static SequentialGroup sequentialRadioArray( GroupLayout layout, Component[] array ) { SequentialGroup rtn = layout.createSequentialGroup(); 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; }
@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 JPanel makeSettings() { JPanel p = new JPanel(); GroupLayout layout = new GroupLayout(p); layout.setAutoCreateContainerGaps(true); p.setLayout(layout); List<JPanel> panels = generateOptionPanels(); sDef = new SimpleCodeHolder(res.definitions); sGlobLoc = new SimpleCodeHolder(res.globalLocals); sInit = new SimpleCodeHolder(res.initialization); sClean = new SimpleCodeHolder(res.cleanup); bDef = new JButton(Messages.getString("EnigmaSettingsFrame.BUTTON_DEFINITIONS"),CODE_ICON); //$NON-NLS-1$ bGlobLoc = new JButton(Messages.getString("EnigmaSettingsFrame.BUTTON_GLOBAL_LOCALS"),CODE_ICON); //$NON-NLS-1$ bInit = new JButton(Messages.getString("EnigmaSettingsFrame.BUTTON_INITIALIZATION"),CODE_ICON); //$NON-NLS-1$ bClean = new JButton(Messages.getString("EnigmaSettingsFrame.BUTTON_CLEANUP"),CODE_ICON); //$NON-NLS-1$ bDef.addActionListener(this); bGlobLoc.addActionListener(this); bInit.addActionListener(this); bClean.addActionListener(this); Group gh = layout.createParallelGroup(); SequentialGroup gv = layout.createSequentialGroup(); if (panels != null) for (JPanel pp : panels) { gh.addComponent(pp); gv.addComponent(pp); } layout.setHorizontalGroup(gh /**/.addGroup(layout.createSequentialGroup() /* */.addComponent(bDef) /* */.addComponent(bGlobLoc)) /**/.addGroup(layout.createSequentialGroup() /* */.addComponent(bInit) /* */.addComponent(bClean))); layout.setVerticalGroup(gv /**/.addGroup(layout.createParallelGroup() /* */.addComponent(bDef) /* */.addComponent(bGlobLoc)) /**/.addGroup(layout.createParallelGroup() /* */.addComponent(bInit) /* */.addComponent(bClean)) /**/.addContainerGap()); return p; }
private JPanel makeAPI() { JPanel p = new JPanel(); GroupLayout layout = new GroupLayout(p); layout.setAutoCreateContainerGaps(true); p.setLayout(layout); Group hg1 = layout.createParallelGroup(); Group hg2 = layout.createParallelGroup(); SequentialGroup vg = layout.createSequentialGroup(); final int pref = GroupLayout.PREFERRED_SIZE; JComponent[] targs = initializeTargets(); for (int i = 0; i < targs.length; i++) { JLabel label = new JLabel(labels[i]); hg1.addComponent(label); hg2.addComponent(targs[i]); vg.addGroup(layout.createParallelGroup(Alignment.BASELINE) /**/.addComponent(label) /**/.addComponent(targs[i],pref,pref,pref)); } tfAuth = new JTextField(null); taDesc = new JTextArea(); tfAuth.setEditable(false); taDesc.setEditable(false); taDesc.setLineWrap(true); taDesc.setWrapStyleWord(true); JLabel lAuth = new JLabel(Messages.getString("EnigmaSettingsFrame.LABEL_AUTHOR")); //$NON-NLS-1$ JScrollPane desc = new JScrollPane(taDesc); layout.setHorizontalGroup(layout.createParallelGroup() /**/.addGroup(layout.createSequentialGroup() /* */.addGroup(hg1) /* */.addPreferredGap(ComponentPlacement.RELATED) /* */.addGroup(hg2)) /**/.addGroup(layout.createSequentialGroup() /* */.addComponent(lAuth) /* */.addPreferredGap(ComponentPlacement.RELATED) /* */.addComponent(tfAuth)) /**/.addComponent(desc)); layout.setVerticalGroup(vg /**/.addPreferredGap(ComponentPlacement.RELATED) /**/.addGroup(layout.createParallelGroup(Alignment.BASELINE) /* */.addComponent(lAuth) /* */.addComponent(tfAuth)) /**/.addPreferredGap(ComponentPlacement.RELATED) /**/.addComponent(desc,0,0,Integer.MAX_VALUE)); return p; }