📄 outputpanel.java,v
字号:
head 1.5;access;symbols;locks rirwin:1.5; strict;comment @# @;1.5date 2005.06.10.18.50.58; author rirwin; state Exp;branches;next 1.4;1.4date 2005.05.24.15.52.44; author rirwin; state Exp;branches;next 1.3;1.3date 2005.03.11.22.33.49; author patil; state Exp;branches;next 1.2;1.2date 2004.12.31.23.53.09; author patil; state Exp;branches;next 1.1;1.1date 2004.12.28.00.04.32; author patil; state Exp;branches;next ;desc@@1.5log@Establishing RCS version.@text@/** * file: OutputPanel.java * * last edited: Ryan Irwin */// import necessary java libraries//import java.awt.*;import javax.swing.*;import java.util.*;import javax.swing.border.*;//These imports are not needed - Phil T. 6-23-03//import java.awt.event.*;//import javax.swing.Timer;/** * OutputPanel acts as the top level container that encompasses the output * plot that displays the input classes as well as the decision regions * * heirarchy: JPanel->SubPanel->OutputPanel * */public class OutputPanel extends SubPanel implements Cloneable{ // ********************************************************************* // // declare global variables and components // // ********************************************************************* // static members // public static double Xmax = 2.0; // maximum range of the x axis public static double Xmin = -2.0; // minimum range of the x axis public static double Ymax = 2.0; // maximum range of the y axis public static double Ymin = -2.0; // minimum range of the y axis public static double Rx = 0.0; // time per pixel ration of the x axis public static double Ry = 0.0; // time per pixel ration of the y axis // declare components // String title; // title for the input panel Font currentFont = getFont(); // fonts for the buttons Font newFont = new Font(currentFont.getName(), currentFont.getStyle(), 12); DisplayArea disp_area_d; // declare a panel for plotting static final int GRID_DIV = 20; // division size for the grid int width = 0; // width of the canvas int height = 0; // height of the canvas int zeroX = 0; // zero position on x axis int zeroY = 0; // zero position on y axis int currObject = 0; // current object that is in focus String newline; // newline statement for text area String text; // string for process description int algorithm = 0; // index to indicate algorithm to be used // ********************************************************************* // // declare class constructors // // ********************************************************************* /** * constructor initializes the samples to be plotted in the signal panel * */ OutputPanel() { super(); // initialize the panel used for plotting // disp_area_d = new DisplayArea(); // set the border for the panel // title = new String("Output Display:"); Border titleBorder = BorderFactory.createTitledBorder( BorderFactory.createLineBorder(Color.black), title, TitledBorder.LEFT, TitledBorder.ABOVE_TOP, newFont, Color.black); setBorder(titleBorder); } /** * constructor initializes the samples to be plotted in the signal panel * * @@param toCopy OutputPanel to be initialized */ OutputPanel(OutputPanel toCopy) { super(); // initialize the panel used for plotting // disp_area_d = toCopy.disp_area_d; // set the border for the panel // title = new String("Output Display:"); Border titleBorder = BorderFactory.createTitledBorder( BorderFactory.createLineBorder(Color.black), title, TitledBorder.LEFT, TitledBorder.ABOVE_TOP, newFont, Color.black); setBorder(titleBorder); } // ********************************************************************* // // declare class methods // // ********************************************************************* /** * Adds components to the input panel * */ public void add_components() { constrain( this, disp_area_d, 0, 0, GridBagConstraints.REMAINDER, GridBagConstraints.REMAINDER, GridBagConstraints.BOTH, GridBagConstraints.NORTHWEST, 1, 1, 2, 2, 2, 2); } /** * Paints the current data points and if needed the decision regions * * @@param g graphics object to use */ public void paintComponent(Graphics g) { super.paintComponent(g); // g.drawLine(10, 15, 410, 50); draws a line but always // near the Text Output Display:. // the line is drawn in the background. // idea is to draw a line - refer the AlgorithmLP.java code. } /** * Adds points to the output panel * * @@param points_a points to be added to panel * @@param type_a integer value of type * @@param color_a color of point * * @@return true * */ public boolean addOutput(Vector<MyPoint> points_a, int type_a, Color color_a) { disp_area_d.output_points_d.add(points_a); disp_area_d.type_d.addElement(new Integer(type_a)); disp_area_d.color_d.add(color_a); // init the algorithm // return true; } /** * Gets the width on the output canvas * method: getDisplayWidth * * @@return width of the output plot */ public int getDisplayWidth() { // return the width // return disp_area_d.getWidth(); } /** * Gets the height on the output canvas * * @@return height of the output plot */ public int getDisplayHeight() { // return the width // return disp_area_d.getHeight(); } /** * Gets the X direction Ratio * * @@return X ratio of the output plot */ public double getXRatio() { Rx = (Xmax - Xmin) / getDisplayWidth(); // return the width // return Rx; } /** * Gets the Y direction Ratio * * @@return Y Ratio of the output plot */ public double getYRatio() { Ry = (Ymax - Ymin) / getDisplayWidth(); // return the width // return Ry; } /** * Clears the input panel screen * */ public void clear() { super.repaint(); disp_area_d.clear(); disp_area_d.repaint(); } /** * Redraws the input panel screen */ public void refresh() { super.repaint(); disp_area_d.repaint(); } /** * Duplicates the OutputPanel Object * * @@return clone of OutputPanel */ public OutputPanel copy() { try { return (OutputPanel)clone(); } catch (CloneNotSupportedException e) {} return null; }}@1.4log@fixed javadoc comments.@text@d7 1d26 1a26 1class OutputPanel extends SubPanel implements Cloneabled185 1a185 2 public boolean addOutput(Vector points_a, int type_a, Color color_a) {d188 1a188 1 disp_area_d.type_d.add(new Integer(type_a));@1.3log@comments changed to suit Java Documentation style.@text@d4 1a18 2 * class: OutputPanel *a74 8 * method: OutputPanel * * @@param Data d: data samples form the input plot * @@param InputPanel in: panel that encompasses the input plot * @@param ProcessBox p: process description box * * @@return none *a101 8 * method: OutputPanel * * @@param Data d: data samples form the input plot * @@param InputPanel in: panel that encompasses the input plot * @@param ProcessBox p: process description box * * @@return none *d104 1d136 1a136 6 * method: add_components * * @@param none * @@return none * * add components to the input paneld160 1a160 7 * method: paintComponent * * @@param Graphics g: graphics object * * @@return none * * paing the current data points and if needed the decision regionsd162 1d175 1a175 1 * method: addOutputd177 3a179 2 * @@param * Graphics g: graphics objectd181 1a181 3 * @@return : none * * paing the current data points and if needed the decision regionsd197 1a199 1 * @@param nonea200 3 *
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -