criteriumshowpanel.java
来自「erp decision with ahp」· Java 代码 · 共 199 行
JAVA
199 行
// Graphical User Interfacepackage gui;//importsimport javax.swing.*; //This is the final package name.//import com.sun.java.swing.*; //Used by JDK 1.2 Beta 4 and all//Swing releases before Swing 1.1 Beta 3.import javax.swing.border.*;import javax.swing.event.*;import javax.swing.text.*;import javax.swing.tree.*;import java.awt.*;import java.awt.event.*;import java.util.*;import java.io.*;import java.net.*;import Jama.*;// Abstract Data Typeimport adt.*;/** * <code>CriteriumShowPanel</code> the Pane to show a criterium * @author Maxime MORGE <A HREF="mailto:morge@emse.fr">morge@emse.fr</A> * @version March 26, 2003 * @version July 21, 2003 */public class CriteriumShowPanel extends JPanel implements DocumentListener{ //ATRIBUTS private Hierarchy h; // The decision hierarchy private Criterium c; // the Criterium to show private JLabel l_ir; // inconsistency ration view private CriteriumSonTablePane table;// table to show Criteria private JTextArea tf_comment;// comment area private PlainDocument whatsup;// document area /** * <code>update</code> method to update the Panel * @param Criterium c to show */ public void update(Criterium c){ this.c=c; //System.out.println("new name of criterium :"+c.getName()); //tf_comment.setText((c.getComment()).toString()); whatsup=new PlainDocument(); try{ whatsup.insertString(0,c.getComment(), null); } catch (BadLocationException e) {System.err.println("Bad Location Exception "+e);} tf_comment=new JTextArea(whatsup); this.remove(table); table=new CriteriumSonTablePane(c,h); this.add(table);//updateWEIGHT(); } /** * <code>update</code> method to update the Panel */ public void updateWEIGHT(){ //System.out.println("repaint"); table.update(); Double value= new Double(((c.getP()).getInconsistencyRatio())*100); String value_s =new String(value.toString()); if(value_s.length()>6){ value_s = value_s.substring(0,5);} if (!(c.getP()).isConsistency()) l_ir.setText(("<html><font color=red>"+value_s+"%</font></html>")); else l_ir.setText(("<html><font color=green>"+value_s+"%</font></html>")); //Systemout.println("size PairwiseComparisonMatrix"+(c.getP()).getSize()); //System.out.println("the new criterium"); //System.out.println(c.print()); } /** * Creates a new <code>CriteriumShowPanel</code> instance. * @param Criterium c * @param Hierarchy h */ public CriteriumShowPanel(Criterium c, Hierarchy h) { super(new GridLayout(0,1)); this.c=c; this.h=h; // if (c!=null){ JPanel top=new JPanel(new GridLayout(0,1)); table=new CriteriumSonTablePane(c,h); JPanel down=new JPanel(new FlowLayout()); //top top.add(new JLabel("Comment : ")); whatsup=new PlainDocument(); try{ whatsup.insertString(0,c.getComment(), null); } catch (BadLocationException e) {System.err.println("Bad Location Exception "+e);} tf_comment=new JTextArea(whatsup,null,20,5); tf_comment.setCaretPosition(tf_comment.getText().length()); JScrollPane scrollPane = new JScrollPane(tf_comment); whatsup.addDocumentListener(this); top.add(scrollPane); //dowm down.add(new JLabel("Inconsisteny Ratio")); Double value= new Double((c.getP()).getInconsistencyRatio()*100); String value_s =new String(value.toString()); if(value_s.length()>6){ value_s = value_s.substring(0,5);} if (!(c.getP()).isConsistency()) l_ir=new JLabel(("<html><font color=red>"+value_s+"%</font></html>")); else l_ir= new JLabel(("<html><font color=green>"+value_s+"%</font></html>")); down.add(l_ir); //center // int n=c.getNb_sons(); // System.out.println("NB SONS"+n); // for(int i=0;i<c.getNb_sons();i++){ // } this.add(top); this.add(table); this.add(down); } } /** * Describe <code>getPreferredSize</code> method here. * * @return a <code>Dimension</code> value * @see <code>Container</code> */ public Dimension getPreferredSize(){ return new Dimension(350,150); } /** * Describe <code>getMinimumSize</code> method here. * * @return a <code>Dimension</code> value * @see <code>Container</code> */ public Dimension getMinimumSize(){ return new Dimension(350,150);} /** * <code>updateComment</code> method invoked when comment is changed * * @param e a <code>DocumentEvent</code> value */ public void updateComment(DocumentEvent e) { //JTextField source = (JTextField)e.getSource(); String text=new String() ; try {text=whatsup.getText(0,whatsup.getLength());} catch (BadLocationException f) {System.out.println("Bad Location Exception "+f);} c.setComment(text); } /**Gives notification that there was an insert into the document.*/ public void insertUpdate(DocumentEvent e){ updateComment(e); } /**Gives notification that a portion of the document has been removed.*/ public void removeUpdate(DocumentEvent e){ updateComment(e); } /** Gives notification that an attribute or set of attributes changed. */ public void changedUpdate(DocumentEvent e){ updateComment(e); } /** * <code>main</code> method to test this class. * @param Criterium : command line * */ public static void main(String s[]) { JFrame frame = new JFrame("CriteriumShowPanel"); frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) {System.exit(0);} }); OwnTest test=new OwnTest(); Hierarchy h=test.getHierarchyExample(); CriteriumShowPanel cp = new CriteriumShowPanel((h.getGoal()).getSubcriteriumAt(0),h); frame.getContentPane().add(cp); frame.pack(); frame.setVisible(true); }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?