⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 layermenuitem.java

📁 JaNet: Java Neural Network Toolkit resume: A well documented toolkit for designing and training, a
💻 JAVA
字号:
////////////////////////////////////////////////////////////////////////////////////  //  //  Copyright (C) 1996 L.  Patocchi & W.Gander////  This program is free  software;  you can  redistribute  it and/or  modify it//  under the terms of the GNU General  Public  License as published by the Free//  Software  Foundation;  either  version 2 of the License, or (at your option)//  any later version.////  This program is  distributed in the hope that it will be useful, but WITHOUT//  ANY  WARRANTY;  without  even the implied  warranty  of  MERCHANTABILITY  or//  FITNESS FOR A PARTICULAR  PURPOSE.  See the GNU General  Public  License for//  more details.////  You should have received a copy of the GNU General Public License along with//  this program; if not, write to the Free Software  Foundation, Inc., 675 Mass//  Ave, Cambridge, MA 02139, USA.////  Contacts://  //    Project Supervisor//      W.Hett       hew@info.isbiel.ch//  //    Authors//      W.Gander     gandw@info.isbiel.ch//      L.Patocchi   patol@info.isbiel.ch////  Documentation can be found at:////      http://www.isbiel.ch/Projects/janet/index.html////////////////////////////////////////////////////////////////////////////////////////// File : layerMenuItem.java//package jaNet.backprop.gui;import java.awt.*;public class layerMenuItem extends MenuComponent{	public static final int SEPARATOR 	= 0;	public static final int BUTTON		= 1;		private boolean 	enabled, selected;	private String 		labelItem;	private int			itemKind;	private int			yOffset, height;	private int 		verticalInset = 2; 	// set label -> create a BUTTON	public layerMenuItem(String label){		labelItem = label;				itemKind = BUTTON;				enabled = true;		selected = false;				height = 20;	}		// no label -> create a SEPARATOR	public layerMenuItem(){		labelItem = null;		itemKind = SEPARATOR;						height	= 3;				enabled = true;		selected = false;	}	public int drawMenuItem(Graphics g, int yoffset, int width){		yOffset = yoffset;			g.setColor(Color.lightGray);		g.fill3DRect(0, yoffset, width,height, !selected);				if (itemKind == SEPARATOR){			g.fill3DRect(0, yoffset, width, height, true);		}else{			height = getStringHeight(g) + 2*verticalInset +2;			if(height < 20) height = 20;						if (enabled){				g.setColor(Color.black);			}else{				g.setColor(Color.gray);			}			g.drawString(labelItem, (width-getLabelWidth(g))/2,yoffset + height-2 - verticalInset);		}				return height;	}	public String getLabel(){		return labelItem;	}	public int getHeight(){		return height;	}	public void setLabel(String label){		if(itemKind != SEPARATOR) labelItem = label;	}	public boolean isSelectable(int y){		return (y>yOffset && y<(yOffset + height));	}	public boolean isSelected(){		return selected;	}	public void select(){		if (itemKind != SEPARATOR) selected = true;	}	public void deselect(){		selected = false;	}	public boolean isEnabled(){		return enabled;	}	public void enable(){		enabled = true;	}	public void enable(boolean cond){		enabled = cond;	}	public void disable(){		enabled = false;	}	public String paramString(){		return "label=" + labelItem;	}		public int getLabelWidth(Graphics g){		if(itemKind == SEPARATOR) return 50;		FontMetrics fm = g.getFontMetrics(g.getFont());        return fm.stringWidth(labelItem);	}	public int getStringHeight(Graphics g){		FontMetrics fm = g.getFontMetrics(g.getFont());        return fm.getHeight();	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -