📄 optimizationapplet.java
字号:
package com.power.pipeengine;
import java.awt.*;
import javax.swing.*;
import javax.swing.event.*;
import java.awt.event.*;
import java.util.*;
import java.awt.geom.*;
import java.applet.*;
import com.power.util.Message.*;
import com.power.util.graph2D.*;
import com.power.pipeengine.EngineUI.*;
import com.power.pipeengine.InputData.*;
import com.power.pipeengine.Entity.*;
import com.power.lpsolver.LPSolve.*;
public class OptimizationApplet
extends JApplet
{
static ResourceBundle res = null;
// This is a hack to avoid an ugly error message in 1.1.
public OptimizationApplet() {
getRootPane().putClientProperty("defeatSystemEventQueueCheck",
Boolean.TRUE);
}
public void init() {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
SwingUtilities.updateComponentTreeUI(getContentPane());
} catch (Exception e) {
//unsupported UI exception
}
res = ResourceBundle.getBundle("com.power.pipeengine.Res",
EngineConfig.getInstance().getLocale() );
int xOffset = 75;
int yOffset = 60;
Color bkgrdColor = new Color(203,208,222);
//getContentPane().setLayout( null );
//getContentPane().setBackground( Color.white );
getContentPane().setLayout( new BorderLayout() );
PrettyPanel pp = new PrettyPanel( this );
getContentPane().add( BorderLayout.CENTER, pp );
ObjSelectionPanel objSelectionPanel = ObjSelectionPanel.getInstance();
objSelectionPanel.setLocation( xOffset, yOffset );
objSelectionPanel.setSize( 245, 60 );
objSelectionPanel.setBackground( bkgrdColor );
//getContentPane().add( objSelectionPanel );
pp.add( objSelectionPanel );
UpdateFreqSelectionPanel updFreqSelPanel = UpdateFreqSelectionPanel.getInstance();
updFreqSelPanel.setLocation( 255 + xOffset, yOffset );
updFreqSelPanel.setSize( 245, 60 );
updFreqSelPanel.setBackground( bkgrdColor );
//getContentPane().add( updFreqSelPanel );
pp.add( updFreqSelPanel );
final JButton optBtn = new JButton( res.getString("Optimize_My_Supply") );
optBtn.setLocation( xOffset, 70 + yOffset);
optBtn.setSize( 500, 25 );
optBtn.setBackground( bkgrdColor );
//getContentPane().add(optBtn);
pp.add( optBtn );
optBtn.addActionListener( new ActionListener() {
public void actionPerformed( ActionEvent e ) {
PIPEMain.getInstance().start();
optBtn.setEnabled( false );
}
});
//plotting objective values on a line chart
//Color bkgrdColor = Color.white;
JPanel aPanel = new JPanel();
aPanel.setBackground( bkgrdColor.darker() );
aPanel.setLocation( xOffset, 110 + yOffset);
aPanel.setSize( 500, 25 );
aPanel.add( new JLabel( res.getString("OBJECTIVE_VALUE_CHART") ) );
//getContentPane().add( aPanel );
pp.add( aPanel );
ObjectiveValuePlot objValuePlot = ObjectiveValuePlot.getInstance();
objValuePlot.setOrigin( new Point2D.Double(30,165) );
objValuePlot.setDimension( new Dimension(500,190) );
objValuePlot.setDoubleBuffered(true);
objValuePlot.setLocation( xOffset, 135 + yOffset);
objValuePlot.setSize( 500, 190 );
objValuePlot.setBackground( bkgrdColor );
//getContentPane().add( objValuePlot ) ;
pp.add( objValuePlot );
//display the message area window
MessageArea msgArea = MessageArea.getInstance();
JScrollPane scrollPane = new JScrollPane( msgArea.getTextArea() );
scrollPane.setVerticalScrollBarPolicy(
JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
scrollPane.setLocation( xOffset, 335 + yOffset);
scrollPane.setSize( 500, 180 );
scrollPane.setName( res.getString("Engine_Message_Window") );
scrollPane.setBorder( BorderFactory.createTitledBorder( res.getString("Engine_Message_Window") ));
scrollPane.setBackground( bkgrdColor );
//getContentPane().add( scrollPane );
pp.add( scrollPane );
EngineConfig.getInstance().setEngineApplet( this );
//getContentPane().add( new PrettyPanel( this ) );
}
class PrettyPanel extends Container {
Image headingBand;
Image backGround;
Applet myApplet;
PrettyPanel(Applet applet) {
headingBand = applet.getImage(applet.getDocumentBase(), "images/bg-green.gif" );
backGround = applet.getImage(applet.getDocumentBase(), "images/bg.gif" );
myApplet = applet;
this.setSize( 650, 600);
this.setLayout( null );
//this.setBackground( new Color( 225,225,225 ) );
}
/**
* paint the background picture, then call super.paint which
* will paint all contained components
*
* Note: You MUST call super.paint(g) or the lightweight
* components won't get painted.
*/
public void paint(Graphics g) {
g.drawImage(headingBand, 0, 0, 650, 50,
this);
for( int i=0; i<13; i++ ) {
for( int j=1; j<=11; j++ ) {
g.drawImage(backGround, i*50, 50*j, 50, 50, this);
}
}
Color penColor = g.getColor();
g.setColor( Color.gray );
g.drawLine( 0, 0, 650, 0 );
g.drawLine( 0, 0, 0, 650 );
g.setColor( Color.black );
g.drawLine( 0, 600, 650, 600 );
g.drawLine( 650, 0, 650, 600 );
g.setColor( penColor );
super.paint(g);
g.setFont(new java.awt.Font(res.getString("Times_New_Roman"), Font.BOLD, 26));
g.setColor(new Color(100,100,110));
g.drawString( res.getString("Optimization_Engine"), 50, 35);
}
}
/*public void actionPerformed( ActionEvent e )
{
try {
PIPEMain.getInstance().run();
} catch ( Exception ex ) {
System.out.println( ex.getMessage() );
}
}*/
/*public OptimizationApplet() {}
public static void main(java.lang.String[] args) {
JFrame aFrame = new JFrame();
aFrame.getContentPane().setLayout( null );
aFrame.setBackground( Color.white );
aFrame.setSize( 800,1000 );
final JButton optBtn = new JButton( "Optimize My Supply Chain" );
optBtn.setLocation( 100, 20 );
optBtn.setSize( 500, 30 );
optBtn.addActionListener( new ActionListener() {
public void actionPerformed( ActionEvent e ) {
PIPEMain.getInstance().start();
optBtn.setEnabled( false );
}
});
aFrame.getContentPane().add(optBtn );
JLabel aLabel = new JLabel( "Objective Value Chart" );
Vector pointVect = new Vector();
pointVect.add(new Point2D.Double(50,20));
pointVect.add(new Point2D.Double(100,50));
pointVect.add(new Point2D.Double(200,120));
pointVect.add(new Point2D.Double(240,180));
pointVect.add(new Point2D.Double(300,250));
//final graphPanel graph = new graphPanel(new Point2D.Double(50,275),new Dimension(500,300));
ObjectiveValuePlot objValuePlot = ObjectiveValuePlot.getInstance();
objValuePlot.setOrigin( new Point2D.Double(50,275) );
objValuePlot.setDimension( new Dimension(500,300) );
objValuePlot.setDoubleBuffered(true);
//objValuePlot.setPointVect(pointVect);
objValuePlot.setLocation( 100, 120 );
objValuePlot.setSize( 500, 320 );
objValuePlot.setBackground( Color.cyan );
objValuePlot.setName( "Objective Function Values:" );
objValuePlot.add( aLabel );
aFrame.getContentPane().add( objValuePlot ) ;
ObjectiveValuePanel objValuePanel = ObjectiveValuePanel.getInstance();
objValuePanel.setLocation( 100, 75 );
objValuePanel.setSize( 500, 50 );
aFrame.getContentPane().add( objValuePanel );
MessageArea msgArea = MessageArea.getInstance();
JScrollPane scrollPane = new JScrollPane( msgArea.getTextArea() );
//msgWindow.setScrollPane( scrollPane );
//scrollPane.setPreferredSize(new Dimension(500, 200));
scrollPane.setVerticalScrollBarPolicy(
JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
scrollPane.setLocation( 100, 450 );
scrollPane.setSize( 500, 200 );
aFrame.getContentPane().add( scrollPane );
aFrame.show();
//PIPEMain.getInstance().run();
}*/
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -