📄 snns.java
字号:
else if(source == mPrint) {
int i=0;
boolean found = false;
Printable painter = null;
// da NetworkView selbst und nicht die contantPane Printable implementiert
// muessen die NetworkViews extra durchgegangen werden
NetworkView view = getLastSelectedView();
if( view != null && view.frame.isSelected() ){
found = true;
painter = view;
}
while( !found && i < frames.length ){
if( frames[i].isSelected() ){
found = true;
Container cp = frames[i].getContentPane();
if( cp instanceof Printable ) painter = (Printable)cp;
}
else i++;
}
/* Container cp = desktop.getSelectedFrame().getContentPane();
if( cp instanceof Printable ) painter = (Printable)cp;*/
if( found && painter != null ){
PrinterJob printJob = PrinterJob.getPrinterJob();
printJob.setPrintable( painter );
if ( printJob.printDialog() ) {
try { printJob.print(); }
catch (Exception ex) { showException( ex ); }
}
}
}
// Edit menu
else if( source == mTop ){
mTop.setEnabled( false );
mBottom.setEnabled( false );
last_view.editTopLabels();
}
else if( source == mBottom ){
mTop.setEnabled( false );
mBottom.setEnabled( false );
last_view.editBottomLabels();
}
else if( source == mLayer ) {
boolean found = false;
int i=0;
while( !found && i<frames.length )
if( frames[i].getContentPane() instanceof LayerPanel ) {
found = true;
try{ frames[i].setIcon( false ); }
catch( Exception ex ){
showException( "The LayerPanel couldn't be deiconified" );
}
frames[i].toFront();
}
else i++;
if( !found ) {
LayerPanel lp = new LayerPanel( this );
addInternalFrame( lp.frame, true );
}
}
else if( source == mConnect ){
boolean found = false;
int i=0;
while( !found && i<frames.length )
if( frames[i].getContentPane() instanceof LinkPanel ) {
found = true;
try{ frames[i].setIcon( false ); }
catch( Exception ex ){
showException( "The LinkPanel couldn磘 be deiconified" );
}
frames[i].toFront();
}
else i++;
if( !found ) {
LinkPanel lp = new LinkPanel( this );
addInternalFrame( lp.frame, true );
}
}
// Edit / Delete menu:
else if( source == mDeleteUnits ||
source == mPopDelU ) network.deleteUnits();
else if( source == mDeleteLinks ||
source == mPopDelL ) network.deleteLinks();
else if( source == mPopEditL ){
try{
LinkEdit le = new LinkEdit( this );
addInternalFrame( le.frame, true );
}
catch( Exception ex ){ showException( ex ); }
}
// View menu:
else if( source == mNetwork )
openNetworkView();
else if( source == mViewSettings ){
NetworkView view = last_view;
String title = "Display settings of view "+view.frame.getTitle();
JDialog sd = new JDialog(this, title, true);
sd.setLocation( 200, 200 );
DisplaySettingsPanel dsp = new DisplaySettingsPanel(this, view );
sd.setContentPane(dsp);
sd.addWindowListener(new DisplaySettingsListener(dsp));
sd.pack();
sd.setResizable( false );
sd.setVisible(true); //necessary as of kestrel
}
else if( source == mProjection ){
ProjectionPanel p = new ProjectionPanel( this );
addInternalFrame( p.frame, true );
}
else if( source == mWeights ){
WeightPanel wp = new WeightPanel( this );
addInternalFrame(wp.frame, true);
}
else if( source == mAnalyzer ){
AnalyzerPanel ap = new AnalyzerPanel( this );
addInternalFrame( ap.frame, true );
}
else if( source == mEditUnits ||
source == mPopEditU ) unitDetail.showDetails();
else if(source == mGraph) {
// open or restore the error graph window
boolean found = false;
int i=0;
while( !found && i<frames.length )
if( frames[i].getContentPane() instanceof GraphPanel ) {
found = true;
try{ frames[i].setIcon( false ); }
catch( Exception ex ){
showException( "The GraphPanel couldn't be deiconified" );
}
frames[i].toFront();
}
else i++;
if( !found ) {
GraphPanel gp = new GraphPanel( this );
addInternalFrame( gp.frame, true );
}
}
else if(source == cbmiStatusPanel)
statusPanel.setVisible( cbmiStatusPanel.isSelected() );
else if(source == mProperties) properties.edit();
// Tools menu
else if(source == mControl) {
// open or restore the control panel
/*boolean found = false;
int i=0;
while( !found && i<frames.length )
if(frames[i].getTitle().equals(master.frame_title)) {
found = true;
try{ frames[i].setIcon( false ); }
catch( Exception ex ){
showException("The ControlPanel couldn't be deiconified");
}
frames[i].toFront();
}
else i++;
if( !found ) addInternalFrame( master.frame, true );*/
master.frame.setVisible(true);
master.frame.toFront();
}
else if(source == mCascade) {
boolean found = false;
int i=0;
while( !found && i<frames.length )
if( frames[i].getTitle().equals( CCPanel.TITLE ) ) {
found = true;
try{ frames[i].setIcon( false ); }
catch( Exception ex ){
showException( "The CascadePanel couldn't be deiconified" );
}
frames[i].toFront();
}
else i++;
if( !found ) {
CCPanel ccp = new CCPanel( this );
addInternalFrame( ccp.frame, true );
}
}
else if( source == mKohonen ){
SOMPanel sp = new SOMPanel( this, getDefaultDisplayType() );
sp.addListener( this );
net_views.addElement( sp );
net_views_count++;
addInternalFrame( sp.frame, true );
}
else if( source == mLog ){
pLog.frame.setVisible( true );
try{ pLog.frame.setIcon( false ); }
catch( Exception ex ){
showException( "The status panel couldn't be deiconified" );
}
pLog.frame.toFront();
}
// Patterns menu:
if(source == mAddPattern || source == mModifyPattern || source == mDeletePattern) {
if( last_view != null && last_view.getLabelsToEdit() == NetworkViewSettings.ACT )
last_view.evaluateDirectEdit( false );
if(source == mAddPattern)
try{ network.createPattern(); }
catch( Exception ex ){ showException( ex ); }
else if(source == mModifyPattern) network.modifyPattern();
else
try{ network.deletePattern(); }
catch( Exception ex ) {
showException( ex );
}
}
// window menu:
else if( source == mCascadeW ) cascadeWindows();
else if( source == mCloseW ){
for( int i=0; i<frames.length; i++ )
frames[i].dispose();
}
// help menu:
else if(source == mAbout) {
JOptionPane.showMessageDialog(
this,
"<html><body><font face='Arial, Helvetica, sans-serif'><center>" +
"<h1>Java Neural Network Simulator " + JavaNNS_VERSION + "</h1>" +
"based on the <b>Stuttgart Neuronal Network Simulator 4.2</b> kernel<br>" +
"<h2>Credits:<br><small>(in order of participation)</small></h2></center>" +
"<b>SNNS:</b> Andreas Zell, Günter Mamier, Michael Vogt, Niels Mache,<br>" +
"Tilman Sommer, Ralf Hübner, Michael Schmalzl, Tobias Soyez, Sven<br>" +
"Döring, Dietmar Posselt, Kai-Uwe Herrmann, Artemis Hatzigeorgiou;<br>" +
"<b>external contributions:</b> Martin Riedmiller, Heike Speckmann, Martin<br>" +
"Reczko, Jamie DeCoster, Jochen Biederman, Joachim Danz, Christian<br>" +
"Wehrfritz, Randolf Werner, Michael Berthold, Hans Rudolph<br>" +
"<p><b>Java User Interface:</b> Igor Fischer, Fabian Hennecke, Christian Bannes<br>" +
"<p>Copyright © 1990-1995 IPVR, University of Stuttgart<br>" +
"Copyright © 1996-2002 WSI, University of Tübingen<br></font></body></html>",
"About JavaNNS",
JOptionPane.INFORMATION_MESSAGE
);
}
else if(source == mContents) {
try {
if(applet != null) {
URL helpURL = new URL(properties.getProperty(properties.USER_MANUAL_URL_KEY));
applet.getAppletContext().showDocument(helpURL, "Help");
}
else {
String[] command = new String[]{
properties.getProperty(properties.BROWSER_NAME_KEY),
properties.getProperty(properties.USER_MANUAL_URL_KEY)};
Runtime.getRuntime().exec( command );
}
}
catch(Exception ex) { showException(ex); }
}
}
// implementing LoaderAndSaver:
public String getLASName() { return "Configuration"; }
public JPanel getAccessory(){ return null; }
public boolean hasHomeFile(){ return ( configHomeFile != null );}
public void save() throws IOException{
if( hasHomeFile() ) save( configHomeFile);
else throw new IOException("No home file defined");
}
public File getFile(){ return configHomeFile; }
/**
* returns the keyword of configuration files
*/
public String getKeyword(){ return "configuration file" ; }
/**
* returns the usual file ending of the configuration files
*/
public String getFileExtension(){ return "cfg"; }
/**
* returns the description of the configuration file type for the fileManager
*/
public String getDescription(){ return "Configuration file *.cfg"; }
/**
* should save the configuration
*/
public void save( File file ) throws IOException{
String path = file.getCanonicalPath();
if( !FileManager.getFileExtension( file ).equals("cfg") ) path += ".cfg";
System.out.println( "not yet implemented." );
}
/**
* removes the old configuration and loads a new one
* with new network views
*/
public void load( File file ) throws IOException{
FileInputStream configFile = new FileInputStream( file );
byte buffer[] = new byte [ configFile.available() ];
configFile.read( buffer );
LineReader configBuffer = new LineReader( buffer );
UIConfig configuration = new UIConfig();
configuration.readConfiguration( configBuffer );
int display_count = configuration.displays;
UIDisplayType dt;
for(int i=0; i<display_count; i++) {
dt = configuration.displayTypes[ i ];
dt.displayNo = net_views.size() + 1;
openNetworkView( dt );
}
configHomeFile = file;
}
public boolean contentChanged(){ return false; }
// implementing NetworkViewListener:
/**
* method receives messages from the network views
*
* @param network view event
*/
public void networkViewChanged( NetworkViewEvent evt ){
//System.out.println("Snns.networkViewChanged("+evt.getMessage()+")");
NetworkView view = evt.getView();
if( evt.id == NetworkViewEvent.VIEW_CLOSED ) {
net_views.remove( view );
if( view == last_view ) last_view = null;
}
else if( evt.id == NetworkViewEvent.VIEW_ACTIVATED ){
if( !net_views.contains( view ) ) net_views.add( view );
last_view = view;
}
updateTheMenu( evt );
}
public void cascadeWindows() {
JInternalFrame[] frames = desktop.getAllFrames();
if( frames.length == 0 ) return;
JInternalFrame frame;
int index = 0, delta = 0, i;
for( i = 0; i<frames.length; i++ ){
frame = frames[i];
if( frame.isVisible() ){
if( index == 0 )
delta = frame.getContentPane().getLocationOnScreen().y
- frame.getLocationOnScreen().y;
frame.setLocation(index*delta, index*delta);
frame.toFront();
desktop.setSelectedFrame(frame);
index++;
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -