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 java.awt.BorderLayout;
021: import java.awt.Color;
022:
023: import javax.swing.JLabel;
024: import javax.swing.JPanel;
025: import javax.swing.JPopupMenu;
026: import javax.swing.border.EmptyBorder;
027:
028: import org.apache.jmeter.gui.util.HorizontalPanel;
029: import org.apache.jmeter.gui.util.ReportMenuFactory;
030: import org.apache.jmeter.gui.util.VerticalPanel;
031: import org.apache.jmeter.testelement.AbstractTable;
032: import org.apache.jmeter.testelement.AbstractChart;
033: import org.apache.jmeter.testelement.LineChart;
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 LineGraphGui 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:
050: private JLabeledTextField urls = new JLabeledTextField(JMeterUtils
051: .getResString("report_line_graph_urls"), Color.white);
052:
053: private JLabeledChoice yItems = new JLabeledChoice();
054: private JLabeledChoice xItems = new JLabeledChoice();
055:
056: public LineGraphGui() {
057: super ();
058: init();
059: }
060:
061: public String getLabelResource() {
062: return "report_line_graph";
063: }
064:
065: public JPopupMenu createPopupMenu() {
066: JPopupMenu pop = new JPopupMenu();
067: ReportMenuFactory.addFileMenu(pop);
068: ReportMenuFactory.addEditMenu(pop, true);
069: return pop;
070: }
071:
072: protected void init() {
073: setLayout(new BorderLayout(10, 10));
074: setBorder(makeBorder());
075: setBackground(Color.white);
076:
077: JPanel pane = new JPanel();
078: pane.setLayout(new BorderLayout(10, 10));
079: pane.setBackground(Color.white);
080: pane.add(this .getNamePanel(), BorderLayout.NORTH);
081:
082: VerticalPanel options = new VerticalPanel(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(urls);
117:
118: add(pane, BorderLayout.NORTH);
119: add(options, BorderLayout.CENTER);
120: }
121:
122: public TestElement createTestElement() {
123: LineChart element = new LineChart();
124: modifyTestElement(element);
125: return element;
126: }
127:
128: public void modifyTestElement(TestElement element) {
129: this .configureTestElement(element);
130: LineChart bc = (LineChart) 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.setURLs(urls.getText());
137: }
138:
139: public void configure(TestElement element) {
140: super .configure(element);
141: LineChart bc = (LineChart) 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: urls.setText(bc.getURLs());
148: }
149: }
|