/*
* -------------------------------------------------------------------------
* $Id: ProfilePlot.java,v 1.2 2004/09/15 19:05:40 estewart Exp $
* -------------------------------------------------------------------------
* Copyright (c) 1999 Visual Numerics Inc. All Rights Reserved.
*
* This software is confidential information which is proprietary to
* and a trade secret of Visual Numerics, Inc. Use, duplication or
* disclosure is subject to the terms of an appropriate license
* agreement.
*
* VISUAL NUMERICS MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE
* SUITABILITY OF THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING
* BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. VISUAL
* NUMERICS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE
* AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR
* ITS DERIVATIVES.
*--------------------------------------------------------------------------
*/
/*
* ProfilePlot.java
*
* Created on September 15, 2004, 4:56 PM
*/
package com.imsl.demo.heatmaps;
import com.imsl.chart.*;
public class ProfilePlot extends javax.swing.JDialog {
private JPanelChart jPanelChart;
private Chart chart;
private AxisXY axis;
private Data data;
private javax.swing.JTextField displayField;
public ProfilePlot(java.awt.Frame parent) {
super(parent, false);
initComponents();
java.awt.Dimension parentSize = parent.getSize();
java.awt.Point parentLoc = parent.getLocationOnScreen();
parentLoc.x += parentSize.width/1.5;
parentLoc.y += parentSize.height/2.5;
setLocation(parentLoc.x, parentLoc.y);
jPanelChart = new JPanelChart();
int h = (int)(parentSize.height/2);
int w = (int)(h/0.8);
jPanelChart.setPreferredSize(new java.awt.Dimension(w,h));
getContentPane().add(jPanelChart);
setChart();
pack();
}
private void setChart() {
chart = jPanelChart.getChart();
chart.getLegend().setPaint(true);
chart.getLegend().setViewport(0.65, 0.85, 0.05, 0.15);
axis = new AxisXY(chart);
axis.getAxisX().getAxisTitle().setTitle("Day of Year");
axis.getAxisX().setAutoscaleInput(AxisXY.AUTOSCALE_OFF);
axis.getAxisY().setAutoscaleInput(AxisXY.AUTOSCALE_OFF);
axis.getAxisX().getAxisLabel().setTextFormat(new java.text.SimpleDateFormat("MMM"));
axis.getAxisX().setWindow((new java.util.GregorianCalendar(2000, 0, 1)).getTimeInMillis(),
(new java.util.GregorianCalendar(2000, 11, 31)).getTimeInMillis());
axis.getAxisX().setNumber(6);
axis.getAxisX().setDensity(2);
java.awt.Container cp = getContentPane();
// Create the display panel
javax.swing.JPanel displayPanel = new javax.swing.JPanel();
displayField = new javax.swing.JTextField("");
displayField.setBorder(null);
displayField.setEditable(false);
displayPanel.add(displayField);
cp.add(displayPanel, java.awt.BorderLayout.SOUTH);
}
void draw(double[] x, double[] y, double[] range, String plotLabel, String yTitle) {
setTitle("Row Profile for "+plotLabel);
axis.getAxisY().getAxisTitle().setTitle(yTitle);
axis.getAxisY().setWindow(range);
displayField.setText("Profile for time = "+plotLabel);
if (data != null) data.remove();
data = new Data(axis, x, y);
data.setDataType(Data.DATA_TYPE_LINE);
data.setLineColor(java.awt.Color.BLUE);
repaint();
}
void clearData() {
if (data != null) data.remove();
displayField.setText("");
setTitle("Row Profile");
repaint();
}
private void initComponents() {
setTitle("Row Profile");
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent evt) {
closeDialog(evt);
}
});
pack();
}
private void closeDialog(java.awt.event.WindowEvent evt) {
setVisible(false);
dispose();
}
}