001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: *
017: */
018: package org.apache.jmeter.report.gui;
019:
020: import javax.swing.border.EmptyBorder;
021: import java.awt.BorderLayout;
022: import java.awt.Color;
023:
024: import javax.swing.JLabel;
025: import javax.swing.JPanel;
026: import javax.swing.JPopupMenu;
027:
028: import org.apache.jmeter.gui.util.ReportMenuFactory;
029: import org.apache.jmeter.gui.util.HorizontalPanel;
030: import org.apache.jmeter.gui.util.VerticalPanel;
031: import org.apache.jmeter.testelement.AbstractChart;
032: import org.apache.jmeter.testelement.AbstractTable;
033: import org.apache.jmeter.testelement.BarChart;
034: import org.apache.jmeter.testelement.TestElement;
035: import org.apache.jmeter.util.JMeterUtils;
036: import org.apache.jorphan.gui.JLabeledChoice;
037: import org.apache.jorphan.gui.JLabeledTextField;
038:
039: public class BarChartGui extends AbstractReportGui {
040:
041: private JLabeledChoice xAxisLabel = new JLabeledChoice();
042:
043: private JLabeledTextField yAxisLabel = new JLabeledTextField(
044: JMeterUtils.getResString("report_chart_y_axis_label"));
045:
046: private JLabeledTextField caption = new JLabeledTextField(
047: JMeterUtils.getResString("report_chart_caption"),
048: Color.white);
049: private JLabeledTextField url = new JLabeledTextField(JMeterUtils
050: .getResString("report_bar_graph_url"), Color.white);
051:
052: private JLabeledChoice yItems = new JLabeledChoice();
053: private JLabeledChoice xItems = new JLabeledChoice();
054:
055: public BarChartGui() {
056: super ();
057: init();
058: }
059:
060: public String getLabelResource() {
061: return "report_bar_chart";
062: }
063:
064: public JPopupMenu createPopupMenu() {
065: JPopupMenu pop = new JPopupMenu();
066: ReportMenuFactory.addFileMenu(pop);
067: ReportMenuFactory.addEditMenu(pop, true);
068: return pop;
069: }
070:
071: protected void init() {
072: setLayout(new BorderLayout(10, 10));
073: setBorder(makeBorder());
074: setBackground(Color.white);
075:
076: JPanel pane = new JPanel();
077: pane.setLayout(new BorderLayout(10, 10));
078: pane.setBackground(Color.white);
079: pane.add(this .getNamePanel(), BorderLayout.NORTH);
080:
081: VerticalPanel options = new VerticalPanel(Color.white);
082: xAxisLabel.setBackground(Color.white);
083: yAxisLabel.setBackground(Color.white);
084:
085: JLabel xLabel = new JLabel(JMeterUtils
086: .getResString("report_chart_x_axis"));
087: HorizontalPanel xpanel = new HorizontalPanel(Color.white);
088: xLabel.setBorder(new EmptyBorder(5, 2, 5, 2));
089: xItems.setBackground(Color.white);
090: xItems.setValues(AbstractTable.xitems);
091: xpanel.add(xLabel);
092: xpanel.add(xItems);
093: options.add(xpanel);
094:
095: JLabel xALabel = new JLabel(JMeterUtils
096: .getResString("report_chart_x_axis_label"));
097: HorizontalPanel xApanel = new HorizontalPanel(Color.white);
098: xALabel.setBorder(new EmptyBorder(5, 2, 5, 2));
099: xAxisLabel.setBackground(Color.white);
100: xAxisLabel.setValues(AbstractChart.X_LABELS);
101: xApanel.add(xALabel);
102: xApanel.add(xAxisLabel);
103: options.add(xApanel);
104:
105: JLabel yLabel = new JLabel(JMeterUtils
106: .getResString("report_chart_y_axis"));
107: HorizontalPanel ypanel = new HorizontalPanel(Color.white);
108: yLabel.setBorder(new EmptyBorder(5, 2, 5, 2));
109: yItems.setBackground(Color.white);
110: yItems.setValues(AbstractTable.items);
111: ypanel.add(yLabel);
112: ypanel.add(yItems);
113: options.add(ypanel);
114: options.add(yAxisLabel);
115: options.add(caption);
116: options.add(url);
117:
118: add(pane, BorderLayout.NORTH);
119: add(options, BorderLayout.CENTER);
120: }
121:
122: public TestElement createTestElement() {
123: BarChart element = new BarChart();
124: modifyTestElement(element);
125: return element;
126: }
127:
128: public void modifyTestElement(TestElement element) {
129: this .configureTestElement(element);
130: BarChart bc = (BarChart) element;
131: bc.setXAxis(xItems.getText());
132: bc.setYAxis(yItems.getText());
133: bc.setXLabel(xAxisLabel.getText());
134: bc.setYLabel(yAxisLabel.getText());
135: bc.setCaption(caption.getText());
136: bc.setURL(url.getText());
137: }
138:
139: public void configure(TestElement element) {
140: super .configure(element);
141: BarChart bc = (BarChart) element;
142: xItems.setText(bc.getXAxis());
143: yItems.setText(bc.getYAxis());
144: xAxisLabel.setText(bc.getXLabel());
145: yAxisLabel.setText(bc.getYLabel());
146: caption.setText(bc.getCaption());
147: url.setText(bc.getURL());
148: }
149:
150: }
|