
de.mcs.jmeasurement.gui.PointDataDialog Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of JMeasurement Show documentation
Show all versions of JMeasurement Show documentation
JMeasurement profiling programs in production enviroment
The newest version!
/*
* MCS Media Computer Software Copyright (c) 2006 by MCS
* -------------------------------------- Created on 18.09.2006 by w.klaas
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
/**
*
*/
package de.mcs.jmeasurement.gui;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JEditorPane;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.text.html.HTMLEditorKit;
import de.mcs.jmeasurement.MeasureData;
import de.mcs.jmeasurement.MeasurePoint;
/**
* This is a dialog to show i single measure point as HTML.
*
* @author w.klaas
*
*/
public class PointDataDialog extends JDialog {
/**
*
*/
private static final long serialVersionUID = 1L;
/** the point to show. */
private MeasurePoint point;
/** content pane. */
private JPanel contentPane;
/** the main text control, showing html. */
private JEditorPane text;
/**
* constructing a dialog showing the measure data of a point.
*
* @param aPoint
* the point to show.
*/
public PointDataDialog(final MeasurePoint aPoint) {
super();
this.point = aPoint;
initialize();
setMeasurePoint(aPoint);
}
/**
* This method initializes this.
*
*/
private void initialize() {
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
this.setContentPane(getJContentPane());
this.setTitle(Messages.getString("ReportViewer.POINTDIALOG.TITLE")); //$NON-NLS-1$
}
/**
* This method initializes jContentPane.
*
* @return javax.swing.JPanel
*/
private JPanel getJContentPane() {
if (contentPane == null) {
contentPane = new JPanel();
contentPane.setLayout(new BorderLayout());
text = new JEditorPane();
text.setEditable(false);
JScrollPane scrollPane = new JScrollPane(text);
contentPane.add(scrollPane, BorderLayout.CENTER);
JPanel bottom = new JPanel();
bottom.setLayout(new BorderLayout());
contentPane.add(bottom, BorderLayout.SOUTH);
JButton btexit = new JButton("Exit");
bottom.add(btexit, BorderLayout.CENTER);
btexit.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
setVisible(false);
}
});
}
return contentPane;
}
/**
* setitng the actual measure point. Filling the html component with the
* html representation of the point data.
*
* @param aPoint
* the point to show.
*/
public final void setMeasurePoint(final MeasurePoint aPoint) {
this.point = aPoint;
this.setTitle(Messages.getString("ReportViewer.POINTDIALOG.TITLE") + " " + point.getName()); //$NON-NLS-1$
StringBuffer buf = new StringBuffer();
buf.append("MeasurePoint ");
buf.append(point.getName());
buf.append("
\r\n");
buf.append("");
MeasureData[] datas = point.getData();
for (int i = 0; i < datas.length; i++) {
MeasureData data = datas[i];
buf.append("");
buf.append(data.getName());
buf.append(" ");
buf.append(data.getAsString());
buf.append(" \r\n");
}
buf.append("
");
buf.append("");
text.setEditorKit(new HTMLEditorKit());
text.setText(buf.toString());
text.setCaretPosition(0);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy