List of usage examples for javax.swing GroupLayout createParallelGroup
public ParallelGroup createParallelGroup()
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame(); JPanel panel = new JPanel(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); GroupLayout layout = new GroupLayout(panel); panel.setLayout(layout);//from ww w. j av a 2s.c o m JButton buttonD = new JButton("D"); JButton buttonR = new JButton("R"); JButton buttonY = new JButton("Y"); JButton buttonO = new JButton("O"); JButton buttonT = new JButton("T"); GroupLayout.SequentialGroup leftToRight = layout.createSequentialGroup(); leftToRight.addComponent(buttonD); GroupLayout.ParallelGroup columnMiddle = layout.createParallelGroup(); columnMiddle.addComponent(buttonR); columnMiddle.addComponent(buttonO); columnMiddle.addComponent(buttonT); leftToRight.addGroup(columnMiddle); leftToRight.addComponent(buttonY); GroupLayout.SequentialGroup topToBottom = layout.createSequentialGroup(); GroupLayout.ParallelGroup rowTop = layout.createParallelGroup(); rowTop.addComponent(buttonD); rowTop.addComponent(buttonR); rowTop.addComponent(buttonY); topToBottom.addGroup(rowTop); topToBottom.addComponent(buttonO); topToBottom.addComponent(buttonT); layout.setHorizontalGroup(leftToRight); layout.setVerticalGroup(topToBottom); frame.add(panel); frame.pack(); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame(); JPanel panel = new JPanel(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); GroupLayout layout = new GroupLayout(panel); panel.setLayout(layout);/*from w w w . j ava 2 s .c o m*/ System.out.println(layout.getLayoutStyle()); JButton buttonD = new JButton("D"); JButton buttonR = new JButton("R"); JButton buttonY = new JButton("Y"); JButton buttonO = new JButton("O"); JButton buttonT = new JButton("T"); GroupLayout.SequentialGroup leftToRight = layout.createSequentialGroup(); leftToRight.addComponent(buttonD); GroupLayout.ParallelGroup columnMiddle = layout.createParallelGroup(); columnMiddle.addComponent(buttonR); columnMiddle.addComponent(buttonO); columnMiddle.addComponent(buttonT); leftToRight.addGroup(columnMiddle); leftToRight.addComponent(buttonY); GroupLayout.SequentialGroup topToBottom = layout.createSequentialGroup(); GroupLayout.ParallelGroup rowTop = layout.createParallelGroup(); rowTop.addComponent(buttonD); rowTop.addComponent(buttonR); rowTop.addComponent(buttonY); topToBottom.addGroup(rowTop); topToBottom.addComponent(buttonO); topToBottom.addComponent(buttonT); layout.setHorizontalGroup(leftToRight); layout.setVerticalGroup(topToBottom); frame.add(panel); frame.pack(); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame(); JPanel panel = new JPanel(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); GroupLayout layout = new GroupLayout(panel); panel.setLayout(layout);//from w w w . j a v a2s . c om System.out.println(layout.getAutoCreateGaps()); JButton buttonD = new JButton("D"); JButton buttonR = new JButton("R"); JButton buttonY = new JButton("Y"); JButton buttonO = new JButton("O"); JButton buttonT = new JButton("T"); GroupLayout.SequentialGroup leftToRight = layout.createSequentialGroup(); leftToRight.addComponent(buttonD); GroupLayout.ParallelGroup columnMiddle = layout.createParallelGroup(); columnMiddle.addComponent(buttonR); columnMiddle.addComponent(buttonO); columnMiddle.addComponent(buttonT); leftToRight.addGroup(columnMiddle); leftToRight.addComponent(buttonY); GroupLayout.SequentialGroup topToBottom = layout.createSequentialGroup(); GroupLayout.ParallelGroup rowTop = layout.createParallelGroup(); rowTop.addComponent(buttonD); rowTop.addComponent(buttonR); rowTop.addComponent(buttonY); topToBottom.addGroup(rowTop); topToBottom.addComponent(buttonO); topToBottom.addComponent(buttonT); layout.setHorizontalGroup(leftToRight); layout.setVerticalGroup(topToBottom); frame.add(panel); frame.pack(); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame(); JPanel panel = new JPanel(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); GroupLayout layout = new GroupLayout(panel); panel.setLayout(layout);/* w ww . j av a2 s . c o m*/ System.out.println(layout.getHonorsVisibility()); JButton buttonD = new JButton("D"); JButton buttonR = new JButton("R"); JButton buttonY = new JButton("Y"); JButton buttonO = new JButton("O"); JButton buttonT = new JButton("T"); GroupLayout.SequentialGroup leftToRight = layout.createSequentialGroup(); leftToRight.addComponent(buttonD); GroupLayout.ParallelGroup columnMiddle = layout.createParallelGroup(); columnMiddle.addComponent(buttonR); columnMiddle.addComponent(buttonO); columnMiddle.addComponent(buttonT); leftToRight.addGroup(columnMiddle); leftToRight.addComponent(buttonY); GroupLayout.SequentialGroup topToBottom = layout.createSequentialGroup(); GroupLayout.ParallelGroup rowTop = layout.createParallelGroup(); rowTop.addComponent(buttonD); rowTop.addComponent(buttonR); rowTop.addComponent(buttonY); topToBottom.addGroup(rowTop); topToBottom.addComponent(buttonO); topToBottom.addComponent(buttonT); layout.setHorizontalGroup(leftToRight); layout.setVerticalGroup(topToBottom); frame.add(panel); frame.pack(); frame.setVisible(true); }
From source file:org.xapagy.ui.tempdyn.tdVisualizationGenerator.java
/** * Generate a vertical list of JFreeCharts * //from w w w .j av a 2 s . c om * @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; }
From source file:org.xapagy.ui.tempdyn.GraphEvolution.java
/** * Graphs the evolution of the links of all types (PRED, SUCC, SUMMARY, * CONTEXT etc) between two Vis.//from www.j av a 2s . c o m * * @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); }
From source file:org.xapagy.ui.tempdyn.GraphEvolution.java
/** * Generates the graph which plots the three choice scores (independent, * dependent and mood) for the evolution of a choice in time. * /*from www . j a v a 2s . c om*/ * @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 = PpChoice.ppConcise(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); }
From source file:org.xapagy.ui.tempdyn.GraphEvolution.java
/** * This function generates a frame into which a number of graphs are * arranged horizontally. Each graph describes the time series values for a * given in-focus object. We have: the focus (with all the energy colors - * salience / energy), the memory (with all the energy colors - salience / * energy), and a list of shadows (with all the energy colors - salience / * energy)./* w w w . j av a 2s.c om*/ * * @param tdc * @param database * @param agent * @param index * - the index of time values * @param isInstance * - true for instances * @param shadowComponents * - how many components will we enter in the graph * @param shadowRange * - the range of the y plot on the shadows - needs to be unique. * * */ public static void graphFMSComposite(tdComponent tdc, tdDataBase database, Agent agent, List<Double> index, int shadowComponents, double shadowRange, GraphEvolutionDescriptor ged) { String label = tdc.getLastPrettyPrint(); // FIXME: this is a tiny bit iffy: we are getting the shadows based on a // certain energy color String ecx = EnergyColors.SHI_GENERIC; List<String> shadowList = database.getShadowComponents(tdc.getIdentifier(), ecx, shadowComponents); // // 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 values // if (ged.graphFocusEnergy || ged.graphFocusSalience) { JFreeChart chart = chartFocusEvolution(tdc, label, database, agent, index, ged); ChartPanel cp = new ChartPanel(chart); sgv.addComponent(cp); pgh.addComponent(cp); } // // the graph with the memory values // if (ged.graphMemoryEnergy || ged.graphMemorySalience) { JFreeChart chart = chartMemoryEvolution(tdc, label, database, agent, index, ged); ChartPanel cp = new ChartPanel(chart); sgv.addComponent(cp); pgh.addComponent(cp); } // // the graphs with the shadow components // if (ged.graphShadowEnergy || ged.graphShadowSalience) { for (String sh : shadowList) { JFreeChart chart = chartShadowEvolution(tdc, sh, database, agent, index, shadowRange, ged); ChartPanel cp = new ChartPanel(chart); sgv.addComponent(cp); pgh.addComponent(cp); } } JFrame frame = new JFrame(); frame.add(panel); frame.pack(); frame.setVisible(true); }
From source file:org.xapagy.ui.tempdyn.GraphEvolution.java
/** * Graphs which plots the evolution of all the links from a given VI. If the * linkType is not null, it filters based on that, otherwise, it plots all * the link types/* ww w . ja va 2 s. com*/ * * @param fromVi * @param linkType * @param tdb * @param agent * @param index */ public static void graphLinksFromAVi(tdComponent fromVi, String linkType, tdDataBase tdb, Agent agent, List<Double> index) { String label; if (linkType != null) { label = "Links of type " + linkType + " from " + fromVi.getIdentifier(); } else { label = "Links of all types from " + fromVi.getIdentifier(); } // create a general purpose xy collection for jfreechart XYSeriesCollection xysc = new XYSeriesCollection(); List<tdComponent> linkedVis = tdb.getFocusVis(); List<String> types = new ArrayList<>(); if (linkType != null) { types.add(linkType); } else { types.addAll(agent.getLinks().getLinkTypeNames()); } // add a series for each VI - if not null for (tdComponent toVi : linkedVis) { for (String linkName : types) { boolean addDecision = false; String id; if (linkType != null) { id = toVi.getIdentifier() + "-" + toVi.getLastPrettyPrint(); } else { id = linkName + " to " + toVi.getIdentifier() + "-" + toVi.getLastPrettyPrint(); } XYSeries linkSeries = new XYSeries(id); // now fill in the series with values for (Double time : index) { double dtime = time; double linkValue = tdb.getLinkValue(fromVi.getIdentifier(), toVi.getIdentifier(), linkName, time); if (linkValue != 0.0) { addDecision = true; } linkSeries.add(dtime, linkValue); } if (addDecision) { xysc.addSeries(linkSeries); } } } // // 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); }
From source file:Main.java
private JPanel create() { JPanel panel = new JPanel(); GroupLayout layout = new GroupLayout(panel); panel.setLayout(layout);/*ww w. ja v a 2 s . com*/ layout.setAutoCreateGaps(true); layout.setAutoCreateContainerGaps(true); GroupLayout.ParallelGroup parallel = layout.createParallelGroup(); layout.setHorizontalGroup(layout.createSequentialGroup().addGroup(parallel)); GroupLayout.SequentialGroup sequential = layout.createSequentialGroup(); layout.setVerticalGroup(sequential); for (int i = 0; i < NUM; i++) { labels[i] = new JLabel(String.valueOf(i + 1), JLabel.RIGHT); fields[i] = new JTextField(String.valueOf("" + (i + 1))); labels[i].setLabelFor(fields[i]); parallel.addGroup(layout.createSequentialGroup().addComponent(labels[i]).addComponent(fields[i])); sequential.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(labels[i]) .addComponent(fields[i])); layout.linkSize(SwingConstants.HORIZONTAL, labels[i], labels[0]); } return panel; }