rem
stringlengths 0
477k
| add
stringlengths 0
313k
| context
stringlengths 6
599k
|
---|---|---|
ObjComparator sc = new ObjComparator(); Collections.sort(yeastDB, sc); | public void readYeast(String path) { // read the yeast from the csv file try { File yeastFile = new File(path, "yeast.csv"); CSVReader reader = new CSVReader(new FileReader( yeastFile), ',', '\"', true, false); try { // get the first line and set up the index: String[] fields = reader.getAllFieldsInLine(); int nameIdx = getIndex(fields, "Name"); int costIdx = getIndex(fields, "Cost"); int descrIdx = getIndex(fields, "Descr"); int modIdx = getIndex(fields, "Modified"); while (true) { Yeast y = new Yeast(); fields = reader.getAllFieldsInLine(); y.setName(fields[nameIdx]); if (!fields[costIdx].equals("")) y.setCost(Double.parseDouble(fields[costIdx])); y.setDescription(fields[descrIdx]); y.setModified(Boolean.valueOf(fields[modIdx]).booleanValue()); yeastDB.add(y); } } catch (EOFException e) { } reader.close(); } catch (IOException e) { e.printStackTrace(); System.out.println(e.getMessage()); } // sort: ObjComparator sc = new ObjComparator(); Collections.sort(yeastDB, sc); } |
|
public Collection find(String query, Object values) { | public Collection find(String query, Object... values) throws DataAccessException { | public Collection find(String query, Object values) { if (logger.isDebugEnabled()) { logger.debug("\n Finding object with query "+query); } if (values instanceof Object[]) { return queryAssembler(query, values).list(); } return this.getHibernateTemplate().find(query, values); } |
logger.debug("\n Finding object with query "+query); | logger.debug("** DAO finding ["+query+"] with "+values); | public Collection find(String query, Object values) { if (logger.isDebugEnabled()) { logger.debug("\n Finding object with query "+query); } if (values instanceof Object[]) { return queryAssembler(query, values).list(); } return this.getHibernateTemplate().find(query, values); } |
if (values instanceof Object[]) { return queryAssembler(query, values).list(); } return this.getHibernateTemplate().find(query, values); | return queryAssembler(query, values).list(); | public Collection find(String query, Object values) { if (logger.isDebugEnabled()) { logger.debug("\n Finding object with query "+query); } if (values instanceof Object[]) { return queryAssembler(query, values).list(); } return this.getHibernateTemplate().find(query, values); } |
public Object findUnique(String query, Object values) throws DataAccessException { Collection list = find(query, values); if (logger.isDebugEnabled()) { logger.debug("\n Query result size is "+list.size()); } if (list.size()==1) { Object object = list.toArray()[0]; if (logger.isDebugEnabled()) { logger.debug("\n Unique object "+object+" found"); } return object; } else if(list.size()==0) { if (logger.isDebugEnabled()) { logger.debug("\n Unique object not found"); } return null; | public Object findUnique(String query, Object... values) throws DataAccessException { Collection list = find(query, values); if (isUnique(list)) { return ((List) list).get(0); | public Object findUnique(String query, Object values) throws DataAccessException { Collection list = find(query, values); if (logger.isDebugEnabled()) { logger.debug("\n Query result size is "+list.size()); } if (list.size()==1) { Object object = list.toArray()[0]; if (logger.isDebugEnabled()) { logger.debug("\n Unique object "+object+" found"); } return object; } else if(list.size()==0) { if (logger.isDebugEnabled()) { logger.debug("\n Unique object not found"); } return null; } throw new DataIntegrityViolationException("Unique object expected"); } |
logger.debug("\n Loading "+clazz.toString() | logger.debug("** DAO Loading "+clazz.toString() | public Object load(Class clazz, Serializable key) throws DataAccessException { if (logger.isDebugEnabled()) { logger.debug("\n Loading "+clazz.toString() +" with id "+key.toString()); } return this.getHibernateTemplate().load(clazz, key); } |
logger.debug("\n Merging "+object.toString()); | logger.debug("** DAO Merging "+object.toString()); | public void merge(Object object) { if (logger.isDebugEnabled()) { logger.debug("\n Merging "+object.toString()); } this.getHibernateTemplate().merge(object); } |
if (logger.isDebugEnabled()) { logger.debug("** DAO Persisting "+object); } | public void persist(Object object) throws DataAccessException { this.getHibernateTemplate().persist(object); } |
|
protected Query queryAssembler(String query, Object values) { | protected Query queryAssembler(String query, Object... values) { | protected Query queryAssembler(String query, Object values) { try { Session session = getSession(true); Query result = session.createQuery(query); if (values != null) { if (values instanceof Object[]) { Object[] valueList = (Object[]) values; for (int i = 0; i<valueList.length; i++) { result.setParameter(i, valueList[i]); if (logger.isDebugEnabled()) { logger.debug("\n Parameter "+i+"="+valueList[i]); } } } else { result.setParameter(0, values); if (logger.isDebugEnabled()) { logger.debug("\n Single parameter is "+values); } } } else { if (logger.isDebugEnabled()) { logger.debug("\n No parameters"); } } return result; } catch (Exception e) { throw new RuntimeException("Unable to assemble query"); } } |
Session session = getSession(true); | Session session = this.getHibernateTemplate().getSessionFactory().getCurrentSession(); | protected Query queryAssembler(String query, Object values) { try { Session session = getSession(true); Query result = session.createQuery(query); if (values != null) { if (values instanceof Object[]) { Object[] valueList = (Object[]) values; for (int i = 0; i<valueList.length; i++) { result.setParameter(i, valueList[i]); if (logger.isDebugEnabled()) { logger.debug("\n Parameter "+i+"="+valueList[i]); } } } else { result.setParameter(0, values); if (logger.isDebugEnabled()) { logger.debug("\n Single parameter is "+values); } } } else { if (logger.isDebugEnabled()) { logger.debug("\n No parameters"); } } return result; } catch (Exception e) { throw new RuntimeException("Unable to assemble query"); } } |
if (values != null) { if (values instanceof Object[]) { Object[] valueList = (Object[]) values; for (int i = 0; i<valueList.length; i++) { result.setParameter(i, valueList[i]); if (logger.isDebugEnabled()) { logger.debug("\n Parameter "+i+"="+valueList[i]); } } } else { result.setParameter(0, values); if (logger.isDebugEnabled()) { logger.debug("\n Single parameter is "+values); } } } else { | int i = 0; for (Object value: values) { result.setParameter(i++, value); | protected Query queryAssembler(String query, Object values) { try { Session session = getSession(true); Query result = session.createQuery(query); if (values != null) { if (values instanceof Object[]) { Object[] valueList = (Object[]) values; for (int i = 0; i<valueList.length; i++) { result.setParameter(i, valueList[i]); if (logger.isDebugEnabled()) { logger.debug("\n Parameter "+i+"="+valueList[i]); } } } else { result.setParameter(0, values); if (logger.isDebugEnabled()) { logger.debug("\n Single parameter is "+values); } } } else { if (logger.isDebugEnabled()) { logger.debug("\n No parameters"); } } return result; } catch (Exception e) { throw new RuntimeException("Unable to assemble query"); } } |
logger.debug("\n No parameters"); | logger.debug("Parameter "+i+"="+value); | protected Query queryAssembler(String query, Object values) { try { Session session = getSession(true); Query result = session.createQuery(query); if (values != null) { if (values instanceof Object[]) { Object[] valueList = (Object[]) values; for (int i = 0; i<valueList.length; i++) { result.setParameter(i, valueList[i]); if (logger.isDebugEnabled()) { logger.debug("\n Parameter "+i+"="+valueList[i]); } } } else { result.setParameter(0, values); if (logger.isDebugEnabled()) { logger.debug("\n Single parameter is "+values); } } } else { if (logger.isDebugEnabled()) { logger.debug("\n No parameters"); } } return result; } catch (Exception e) { throw new RuntimeException("Unable to assemble query"); } } |
logger.debug("\n Refreshing "+object); | logger.debug("** DAO Refreshing "+object); | public void refresh(Object object) throws DataAccessException { if (logger.isDebugEnabled()) { logger.debug("\n Refreshing "+object); } this.getHibernateTemplate().refresh(object); } |
remove(find(object.toString(), null)); | remove(find(object.toString())); | public void remove(Object object) { if (object instanceof String) { remove(find(object.toString(), null)); } else if (object instanceof Collection) { Collection collection = (Collection) object; if (logger.isDebugEnabled()) { logger.debug("\n Deleting collection of size "+collection.size()); } this.getHibernateTemplate().deleteAll(collection); } else { if (logger.isDebugEnabled()) { logger.debug("\n Deleting "+object.toString()); } this.getHibernateTemplate().delete(object); } } |
logger.debug("\n Deleting collection of size "+collection.size()); | logger.debug("** DAO Deleting collection of size "+collection.size()); | public void remove(Object object) { if (object instanceof String) { remove(find(object.toString(), null)); } else if (object instanceof Collection) { Collection collection = (Collection) object; if (logger.isDebugEnabled()) { logger.debug("\n Deleting collection of size "+collection.size()); } this.getHibernateTemplate().deleteAll(collection); } else { if (logger.isDebugEnabled()) { logger.debug("\n Deleting "+object.toString()); } this.getHibernateTemplate().delete(object); } } |
logger.debug("\n Deleting "+object.toString()); | logger.debug("** DAO Deleting "+object.toString()); | public void remove(Object object) { if (object instanceof String) { remove(find(object.toString(), null)); } else if (object instanceof Collection) { Collection collection = (Collection) object; if (logger.isDebugEnabled()) { logger.debug("\n Deleting collection of size "+collection.size()); } this.getHibernateTemplate().deleteAll(collection); } else { if (logger.isDebugEnabled()) { logger.debug("\n Deleting "+object.toString()); } this.getHibernateTemplate().delete(object); } } |
UserLog userLog = new UserLog(); userLog.setUser(user); userLog.setLastLogin(lastLogin); userLogList.add(userLog); return userLog; | lastUserLog = new UserLog(); lastUserLog.setUser(user); lastUserLog.setLastLogin(lastLogin); userLogList.add(lastUserLog); return lastUserLog; | public UserLog createAndPersistUserLog(User user) { if (userLogList==null) { userLogList = new ArrayList<UserLog>(); } UserLog userLog = new UserLog(); userLog.setUser(user); userLog.setLastLogin(lastLogin); userLogList.add(userLog); return userLog; } |
public UserLog findLastUserLog(String principal) { return null; } | public UserLog findLastUserLog(String principal) { return lastUserLog; } | public UserLog findLastUserLog(String principal) { return null; } |
userDao = new UserDaoStub(); | public void setUp() { testCredential = new Credential(); testCredential.setPrincipal("CRED1"); testCredential.setPassword("PASSWORD1"); userDetailsService = new UserDetailsServiceImpl(); userDetailsService.setUserDao(new UserDaoStub()); } |
|
else if ( exp.getType() == FileHandlingException.RENAME_FAILED ) | else { NLogger.error( DownloadConfigDialog.class, exp ); } } catch ( ManagedFileException exp ) { if ( exp.getCause() instanceof FileHandlingException && ((FileHandlingException)exp.getCause()).getType() == FileHandlingException.RENAME_FAILED ) | private boolean isInputValidAndUpdated() { final String localFilename = filenameTF.getText().trim(); if ( localFilename.length() == 0 ) { GUIUtils.showErrorMessage( this, Localizer.getString( "NoFileName" ) ); filenameTF.requestFocus(); return false; } final String researchTerm = researchTermTF.getText().trim(); if ( researchTerm.length() < Cfg.MIN_SEARCH_TERM_LENGTH ) { Object[] objArr = new Object[ 1 ]; objArr[ 0 ] = new Integer( Cfg.MIN_SEARCH_TERM_LENGTH ); GUIUtils.showErrorMessage( this, Localizer.getFormatedString( "MinSearchTerm", objArr ) ); researchTermTF.requestFocus(); return false; } if ( remoteFile != null ) { SwarmingManager.getInstance().addFileToDownload( remoteFile, ServiceManager.sCfg.mDownloadDir + File.separator + FileUtils.convertToLocalSystemFilename( localFilename ), researchTerm ); remoteFile.setInDownloadQueue( true ); } else if ( downloadFile != null ) { if ( !downloadFile.getDestinationFileName().equals( localFilename ) ) { boolean rename = renameOldFileCBx.isSelected(); try { File destFile; destFile = new File( ServiceManager.sCfg.mDownloadDir + File.separator + FileUtils.convertToLocalSystemFilename( localFilename ) ); downloadFile.setDestinationFile( destFile, rename ); } catch ( FileHandlingException exp ) { // setting the new local filename failed. show error if ( exp.getType() == FileHandlingException.FILE_ALREADY_EXISTS ) { Object[] objArr = new Object[ 1 ]; objArr[ 0 ] = localFilename; GUIUtils.showErrorMessage( this, Localizer.getFormatedString( "FileAlreadyExists", objArr ) ); } else if ( exp.getType() == FileHandlingException.RENAME_FAILED ) { GUIUtils.showErrorMessage( this, Localizer.getString( "FileRenameFailed" ) ); } else { exp.printStackTrace(); } } } downloadFile.getResearchSetting().setSearchTerm( researchTerm ); } return true; } |
exp.printStackTrace(); | NLogger.error( DownloadConfigDialog.class, exp ); | private boolean isInputValidAndUpdated() { final String localFilename = filenameTF.getText().trim(); if ( localFilename.length() == 0 ) { GUIUtils.showErrorMessage( this, Localizer.getString( "NoFileName" ) ); filenameTF.requestFocus(); return false; } final String researchTerm = researchTermTF.getText().trim(); if ( researchTerm.length() < Cfg.MIN_SEARCH_TERM_LENGTH ) { Object[] objArr = new Object[ 1 ]; objArr[ 0 ] = new Integer( Cfg.MIN_SEARCH_TERM_LENGTH ); GUIUtils.showErrorMessage( this, Localizer.getFormatedString( "MinSearchTerm", objArr ) ); researchTermTF.requestFocus(); return false; } if ( remoteFile != null ) { SwarmingManager.getInstance().addFileToDownload( remoteFile, ServiceManager.sCfg.mDownloadDir + File.separator + FileUtils.convertToLocalSystemFilename( localFilename ), researchTerm ); remoteFile.setInDownloadQueue( true ); } else if ( downloadFile != null ) { if ( !downloadFile.getDestinationFileName().equals( localFilename ) ) { boolean rename = renameOldFileCBx.isSelected(); try { File destFile; destFile = new File( ServiceManager.sCfg.mDownloadDir + File.separator + FileUtils.convertToLocalSystemFilename( localFilename ) ); downloadFile.setDestinationFile( destFile, rename ); } catch ( FileHandlingException exp ) { // setting the new local filename failed. show error if ( exp.getType() == FileHandlingException.FILE_ALREADY_EXISTS ) { Object[] objArr = new Object[ 1 ]; objArr[ 0 ] = localFilename; GUIUtils.showErrorMessage( this, Localizer.getFormatedString( "FileAlreadyExists", objArr ) ); } else if ( exp.getType() == FileHandlingException.RENAME_FAILED ) { GUIUtils.showErrorMessage( this, Localizer.getString( "FileRenameFailed" ) ); } else { exp.printStackTrace(); } } } downloadFile.getResearchSetting().setSearchTerm( researchTerm ); } return true; } |
OperatorSet op = djep.getOperatorSet(); | OperatorSet opset = djep.getOperatorSet(); | public Node differentiate(ASTFunNode node,String var,Node [] children,Node [] dchildren,DJep djep) throws ParseException { OperatorSet op = djep.getOperatorSet(); NodeFactory nf = djep.getNodeFactory(); int nchild = node.jjtGetNumChildren(); if(nchild==2) return nf.buildOperatorNode(op.getAdd(), nf.buildOperatorNode(op.getMultiply(), dchildren[0], djep.deepCopy(children[1])), nf.buildOperatorNode(op.getMultiply(), djep.deepCopy(children[0]), dchildren[1])); else throw new ParseException("Too many children "+nchild+" for "+node+"\n"); } |
Operator op = opset.getMultiply(); if(mulOp!=null) op = mulOp; | public Node differentiate(ASTFunNode node,String var,Node [] children,Node [] dchildren,DJep djep) throws ParseException { OperatorSet op = djep.getOperatorSet(); NodeFactory nf = djep.getNodeFactory(); int nchild = node.jjtGetNumChildren(); if(nchild==2) return nf.buildOperatorNode(op.getAdd(), nf.buildOperatorNode(op.getMultiply(), dchildren[0], djep.deepCopy(children[1])), nf.buildOperatorNode(op.getMultiply(), djep.deepCopy(children[0]), dchildren[1])); else throw new ParseException("Too many children "+nchild+" for "+node+"\n"); } |
|
return nf.buildOperatorNode(op.getAdd(), nf.buildOperatorNode(op.getMultiply(), | return nf.buildOperatorNode(opset.getAdd(), nf.buildOperatorNode(op, | public Node differentiate(ASTFunNode node,String var,Node [] children,Node [] dchildren,DJep djep) throws ParseException { OperatorSet op = djep.getOperatorSet(); NodeFactory nf = djep.getNodeFactory(); int nchild = node.jjtGetNumChildren(); if(nchild==2) return nf.buildOperatorNode(op.getAdd(), nf.buildOperatorNode(op.getMultiply(), dchildren[0], djep.deepCopy(children[1])), nf.buildOperatorNode(op.getMultiply(), djep.deepCopy(children[0]), dchildren[1])); else throw new ParseException("Too many children "+nchild+" for "+node+"\n"); } |
nf.buildOperatorNode(op.getMultiply(), | nf.buildOperatorNode(op, | public Node differentiate(ASTFunNode node,String var,Node [] children,Node [] dchildren,DJep djep) throws ParseException { OperatorSet op = djep.getOperatorSet(); NodeFactory nf = djep.getNodeFactory(); int nchild = node.jjtGetNumChildren(); if(nchild==2) return nf.buildOperatorNode(op.getAdd(), nf.buildOperatorNode(op.getMultiply(), dchildren[0], djep.deepCopy(children[1])), nf.buildOperatorNode(op.getMultiply(), djep.deepCopy(children[0]), dchildren[1])); else throw new ParseException("Too many children "+nchild+" for "+node+"\n"); } |
cmbStyle2Model.setList(db.styleDB); | public StrangeSwing() { super(); initGUI(); // There has *got* to be a better way to do this: Database db = new Database(); String path=""; String slash = System.getProperty("file.separator"); try { path = new File(".").getCanonicalPath() + slash + "src" + slash + "strangebrew" + slash + "data"; } catch (Exception e) { e.printStackTrace(); } db.readDB(path); cmbStyleModel.setList(db.styleDB); cmbYeastModel.setList(db.yeastDB); cmbMaltModel.setList(db.fermDB); cmbHopsModel.setList(db.hopsDB); cmbSizeUnitsModel.setList(new Quantity().getListofUnits("vol")); cmbMaltUnitsModel.setList(new Quantity().getListofUnits("weight")); cmbHopsUnitsModel.setList(new Quantity().getListofUnits("weight")); fileChooser = new JFileChooser(); String fcpath = getClass().getProtectionDomain().getCodeSource() .getLocation().toString().substring(6) + slash; fileChooser.setCurrentDirectory(new File(path)); // link malt table and totals: addColumnWidthListeners(); // set up tabs: miscPanel.setList(db.miscDB); miscPanel.setDescrArea(descriptionTextArea); myRecipe = new Recipe(); attachRecipeData(); displayRecipe(); } |
|
TableColumnModel tcm = tblHops.getColumnModel(); TableColumnModel tcmt = tblHopsTotals.getColumnModel(); | TableColumnModel tcm = tblMalt.getColumnModel(); TableColumnModel tcmt = tblMaltTotals.getColumnModel(); | public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals("preferredWidth")) { TableColumnModel tcm = tblHops.getColumnModel(); TableColumnModel tcmt = tblHopsTotals.getColumnModel(); int columnCount = tcm.getColumnCount(); // for each column, get its width for (int i = 0; i < columnCount; i++) { tcmt.getColumn(i).setPreferredWidth(tcm.getColumn(i).getPreferredWidth()); } } } |
cmbStyle2Model.addOrInsert(myRecipe.getStyleObj()); | public void attachRecipeData(){ // this method attaches data from the recipe to the tables // and comboboxes // use whenever the Recipe changes cmbStyleModel.addOrInsert(myRecipe.getStyleObj()); cmbYeastModel.addOrInsert(myRecipe.getYeastObj()); cmbSizeUnitsModel.addOrInsert(myRecipe.getVolUnits()); tblMaltModel.setData(myRecipe); tblHopsModel.setData(myRecipe); miscPanel.setData(myRecipe); notesPanel.setData(myRecipe); tblMalt.updateUI(); tblHops.updateUI(); } |
|
ComboBoxModel cmbStyle2Model = new DefaultComboBoxModel(new String[]{ "Item One", "Item Two"}); | cmbStyle2Model = new ComboModel(); | private void initGUI() { try { this.setSize(520, 532); this.addWindowListener(new WindowAdapter() { public void windowClosed(WindowEvent evt) { System.exit(1); } }); { pnlMain = new JPanel(); GridBagLayout jPanel2Layout = new GridBagLayout(); jPanel2Layout.columnWeights = new double[] {0.1,0.1}; jPanel2Layout.columnWidths = new int[] {7,7}; jPanel2Layout.rowWeights = new double[] {0.1,0.1,0.9,0.1}; jPanel2Layout.rowHeights = new int[] {7,7,7,7}; pnlMain.setLayout(jPanel2Layout); this.getContentPane().add(pnlMain, BorderLayout.CENTER); { jPanel1 = new JPanel(); pnlMain.add(jPanel1, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); FlowLayout jPanel1Layout = new FlowLayout(); jPanel1Layout.setAlignment(FlowLayout.LEFT); jPanel1.setLayout(jPanel1Layout); { lblName = new JLabel(); jPanel1.add(lblName); lblName.setText("Name:"); } { txtName = new JTextField(); jPanel1.add(txtName); txtName.setText("Name"); txtName.setPreferredSize(new java.awt.Dimension(179, 20)); txtName.addActionListener(this); txtName.addFocusListener(this); } } { jTabbedPane1 = new JTabbedPane(); pnlMain.add(jTabbedPane1, new GridBagConstraints(0, 1, 1, 1, 0.1, 0.1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); { pnlDetails = new JPanel(); GridBagLayout pnlDetailsLayout = new GridBagLayout(); pnlDetailsLayout.columnWeights = new double[] {0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1}; pnlDetailsLayout.columnWidths = new int[] {7,7,7,7,7,7,7,7,7,7}; pnlDetailsLayout.rowWeights = new double[] {0.1,0.1,0.1,0.1,0.1,0.1,0.1}; pnlDetailsLayout.rowHeights = new int[] {7,7,7,7,7,7,7}; pnlDetails.setLayout(pnlDetailsLayout); jTabbedPane1.addTab("Details", null, pnlDetails, null); pnlDetails.setPreferredSize(new java.awt.Dimension(20, 16)); { lblBrewer = new JLabel(); pnlDetails.add(lblBrewer, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblBrewer.setText("Brewer:"); } { txtBrewer = new JTextField(); pnlDetails.add(txtBrewer, new GridBagConstraints( 1, 0, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); txtBrewer.addFocusListener(this); txtBrewer.addActionListener(this); txtBrewer.setText("Brewer"); } { lblDate = new JLabel(); pnlDetails.add(lblDate, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblDate.setText("Date:"); } { lblStyle = new JLabel(); pnlDetails.add(lblStyle, new GridBagConstraints( 0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblStyle.setText("Style:"); } { lblYeast = new JLabel(); pnlDetails.add(lblYeast, new GridBagConstraints( 0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblYeast.setText("Yeast:"); } { lblPreBoil = new JLabel(); pnlDetails.add(lblPreBoil, new GridBagConstraints( 0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblPreBoil.setText("Pre boil:"); } { lblPostBoil = new JLabel(); pnlDetails.add(lblPostBoil, new GridBagConstraints( 0, 5, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblPostBoil.setText("Post boil:"); } { lblEffic = new JLabel(); pnlDetails.add(lblEffic, new GridBagConstraints( 3, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblEffic.setText("Effic:"); } { lblAtten = new JLabel(); pnlDetails.add(lblAtten, new GridBagConstraints( 3, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblAtten.setText("Atten:"); } { lblOG = new JLabel(); pnlDetails.add(lblOG, new GridBagConstraints( 5, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblOG.setText("OG:"); } { lblFG = new JLabel(); pnlDetails.add(lblFG, new GridBagConstraints( 5, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblFG.setText("FG:"); } { lblIBU = new JLabel(); pnlDetails.add(lblIBU, new GridBagConstraints( 7, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblIBU.setText("IBU:"); } { lblAlc = new JLabel(); pnlDetails.add(lblAlc, new GridBagConstraints( 7, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblAlc.setText("%Alc:"); } { lblColour = new JLabel(); pnlDetails.add(lblColour, new GridBagConstraints( 7, 2, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblColour.setText("Colour:"); } { txtDate = new JFormattedTextField(); pnlDetails.add(txtDate, new GridBagConstraints( 1, 1, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); txtDate.setText("Date"); txtDate.addFocusListener(this); txtDate.addActionListener(this); } { cmbStyleModel = new ComboModel(); cmbStyle = new JComboBox(); pnlDetails.add(cmbStyle, new GridBagConstraints( 1, 2, 5, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); cmbStyle.setModel(cmbStyleModel); cmbStyle.setMaximumSize(new java.awt.Dimension(100, 32767)); cmbStyle.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { Style s = (Style) cmbStyleModel.getSelectedItem(); if (myRecipe != null && s != myRecipe.getStyleObj()) { myRecipe.setStyle(s); } descriptionTextArea.setText(s.getDescription()); cmbStyle.setToolTipText(multiLineToolTip(50,s.getDescription())); } }); } { txtPreBoil = new JFormattedTextField(); pnlDetails.add(txtPreBoil, new GridBagConstraints( 1, 4, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); txtPreBoil.setText("Pre Boil"); txtPreBoil.addFocusListener(this); txtPreBoil.addActionListener(this); } { postBoilText = new JFormattedTextField(); pnlDetails.add(postBoilText, new GridBagConstraints( 1, 5, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); postBoilText.setText("Post Boil"); postBoilText.addFocusListener(new FocusAdapter() { public void focusLost(FocusEvent evt) { myRecipe.setPostBoil(Double.parseDouble(postBoilText.getText() .toString())); displayRecipe(); } }); postBoilText.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { myRecipe.setPostBoil(Double.parseDouble(postBoilText.getText() .toString())); displayRecipe(); } }); } { lblComments = new JLabel(); pnlDetails.add(lblComments, new GridBagConstraints( 6, 3, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblComments.setText("Comments:"); } { SpinnerNumberModel spnEfficModel = new SpinnerNumberModel(75.0, 0.0, 100.0, 1.0); spnEffic = new JSpinner(); pnlDetails.add(spnEffic, new GridBagConstraints( 4, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); spnEffic.setModel(spnEfficModel); spnEffic.setMaximumSize(new java.awt.Dimension(70, 32767)); spnEffic.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent evt) { myRecipe.setEfficiency(Double.parseDouble(spnEffic.getValue() .toString())); displayRecipe(); } }); spnEffic.setEditor(new JSpinner.NumberEditor(spnEffic, "00.#")); spnEffic.getEditor().setPreferredSize(new java.awt.Dimension(28, 16)); } { SpinnerNumberModel spnAttenModel = new SpinnerNumberModel(75.0, 0.0, 100.0, 1.0); spnAtten = new JSpinner(); pnlDetails.add(spnAtten, new GridBagConstraints( 4, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); spnAtten.setModel(spnAttenModel); spnAtten.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent evt) { myRecipe.setAttenuation(Double.parseDouble(spnAtten.getValue() .toString())); displayRecipe(); } }); spnAtten.setEditor(new JSpinner.NumberEditor(spnAtten, "00.#")); } { SpinnerNumberModel spnOgModel = new SpinnerNumberModel(1.000, 0.900, 2.000, 0.001); spnOG = new JSpinner(); pnlDetails.add(spnOG, new GridBagConstraints( 6, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); spnOG.setModel(spnOgModel); spnOG.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent evt) { myRecipe.setEstOg(Double.parseDouble(spnOG.getValue() .toString())); displayRecipe(); } }); spnOG.setEditor(new JSpinner.NumberEditor(spnOG, "0.000")); spnOG.getEditor().setPreferredSize(new java.awt.Dimension(20, 16)); } { SpinnerNumberModel spnFgModel = new SpinnerNumberModel(1.000, 0.900, 2.000, 0.001); spnFG = new JSpinner(); pnlDetails.add(spnFG, new GridBagConstraints( 6, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); spnFG.setModel(spnFgModel); spnFG.setEditor(new JSpinner.NumberEditor(spnFG, "0.000")); spnFG.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent evt) { // set the new FG, and update alc: myRecipe.setEstFg(Double.parseDouble(spnFG.getValue() .toString())); displayRecipe(); } }); } { lblIBUvalue = new JLabel(); pnlDetails.add(lblIBUvalue, new GridBagConstraints( 8, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblIBUvalue.setText("IBUs"); } { lblColourValue = new JLabel(); pnlDetails.add(lblColourValue, new GridBagConstraints( 8, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblColourValue.setText("Colour"); } { lblAlcValue = new JLabel(); pnlDetails.add(lblAlcValue, new GridBagConstraints( 8, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblAlcValue.setText("Alc"); } { scpComments = new JScrollPane(); pnlDetails.add(scpComments, new GridBagConstraints( 6, 4, 3, 2, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); { txtComments = new JTextArea(); scpComments.setViewportView(txtComments); txtComments.setText("Comments"); txtComments.setWrapStyleWord(true); txtComments.setPreferredSize(new java.awt.Dimension(117, 42)); txtComments.addFocusListener(new FocusAdapter() { public void focusLost(FocusEvent evt) { if (!txtComments.getText().equals(myRecipe.getComments())) { myRecipe.setComments(txtComments.getText()); } } }); } } { cmbYeastModel = new ComboModel(); cmbYeast = new JComboBox(); pnlDetails.add(cmbYeast, new GridBagConstraints( 1, 3, 5, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); cmbYeast.setModel(cmbYeastModel); cmbYeast.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { Yeast y = (Yeast) cmbYeastModel.getSelectedItem(); if (myRecipe != null && y != myRecipe.getYeastObj()) { myRecipe.setYeast(y); } cmbYeast.setToolTipText(multiLineToolTip(40,y.getDescription())); } }); } { cmbSizeUnitsModel = new ComboModel(); cmbSizeUnits = new JComboBox(); pnlDetails.add(cmbSizeUnits, new GridBagConstraints( 2, 4, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); cmbSizeUnits.setModel(cmbSizeUnitsModel); cmbSizeUnits.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { String q = (String) cmbSizeUnits.getSelectedItem(); if (myRecipe != null && q != myRecipe.getVolUnits()) { myRecipe.setPostBoilVolUnits(q); displayRecipe(); } } }); } { lblSizeUnits = new JLabel(); pnlDetails.add(lblSizeUnits, new GridBagConstraints( 2, 5, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); lblSizeUnits.setText("Size Units"); } { boilTimeLable = new JLabel(); pnlDetails.add(boilTimeLable, new GridBagConstraints( 4, 4, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); boilTimeLable.setText("Boil Min:"); } { evapLabel = new JLabel(); pnlDetails.add(evapLabel, new GridBagConstraints( 4, 5, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); evapLabel.setText("Evap/hr:"); } { boilMinText = new JTextField(); pnlDetails.add(boilMinText, new GridBagConstraints( 5, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); boilMinText.setText("60"); boilMinText.addFocusListener(this); boilMinText.addActionListener(this); } { evapText = new JTextField(); pnlDetails.add(evapText, new GridBagConstraints( 5, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); evapText.setText("4"); evapText.addFocusListener(this); evapText.addActionListener(this); } } { pnlStyle = new JPanel(); FlowLayout pnlStyleLayout = new FlowLayout(); pnlStyle.setLayout(pnlStyleLayout); jTabbedPane1.addTab("Style", null, pnlStyle, null); { lblStyle2 = new JLabel(); pnlStyle.add(lblStyle2); lblStyle2.setText("Style:"); } { ComboBoxModel cmbStyle2Model = new DefaultComboBoxModel(new String[]{ "Item One", "Item Two"}); cmbStyle2 = new JComboBox(); pnlStyle.add(cmbStyle2); cmbStyle2.setModel(cmbStyle2Model); } { jPanel2 = new JPanel(); GridBagLayout jPanel2Layout1 = new GridBagLayout(); jPanel2Layout1.columnWeights = new double[]{0.1, 0.1, 0.1, 0.1}; jPanel2Layout1.columnWidths = new int[]{7, 7, 7, 7}; jPanel2Layout1.rowWeights = new double[]{0.1, 0.1, 0.1, 0.1, 0.1, 0.1}; jPanel2Layout1.rowHeights = new int[]{7, 7, 7, 7, 7, 7}; jPanel2.setPreferredSize(new java.awt.Dimension(179, 120)); jPanel2.setLayout(jPanel2Layout1); pnlStyle.add(jPanel2); jPanel2.setBorder(BorderFactory.createTitledBorder(new LineBorder( new java.awt.Color(0, 0, 0), 1, false), "Recipe Conformance:", TitledBorder.LEADING, TitledBorder.TOP, new java.awt.Font( "Dialog", 0, 12), new java.awt.Color(0, 0, 0))); { jLabel5 = new JLabel(); jPanel2.add(jLabel5, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel5.setText("OG:"); jLabel5.setBounds(74, 3, 60, 30); } { jLabel1 = new JLabel(); jPanel2.add(jLabel1, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); GridLayout jLabel1Layout = new GridLayout(1, 1); jLabel1.setLayout(jLabel1Layout); jLabel1.setText("Low:"); } { jLabel2 = new JLabel(); jPanel2.add(jLabel2, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel2.setText("Recipe:"); } { jLabel3 = new JLabel(); jPanel2.add(jLabel3, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel3.setText("High:"); } { jLabel4 = new JLabel(); jPanel2.add(jLabel4, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel4.setText("IBU:"); } { jLabel6 = new JLabel(); jPanel2.add(jLabel6, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel6.setText("Colour:"); } { jLabel7 = new JLabel(); jPanel2.add(jLabel7, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel7.setText("ABV:"); } } { jScrollPane3 = new JScrollPane(); pnlStyle.add(jScrollPane3); { txaStyles = new JTextArea(); jScrollPane3.setViewportView(txaStyles); txaStyles.setText("Matched Styles"); } } { sldMatch = new JSlider(); pnlStyle.add(sldMatch); } } { miscPanel = new MiscPanel(myRecipe); jTabbedPane1.addTab("Misc", null, miscPanel, null); } { notesPanel = new NotesPanel(); jTabbedPane1.addTab("Notes", null, notesPanel, null); } } { pnlTables = new JPanel(); BoxLayout pnlMaltsLayout = new BoxLayout(pnlTables, javax.swing.BoxLayout.Y_AXIS); pnlMain.add(pnlTables, new GridBagConstraints(0, 2, 1, 1, 0.5, 0.5, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); pnlTables.setLayout(pnlMaltsLayout); { pnlMalt = new JPanel(); pnlTables.add(pnlMalt); BorderLayout pnlMaltLayout1 = new BorderLayout(); FlowLayout pnlMaltLayout = new FlowLayout(); pnlMalt.setBorder(BorderFactory.createTitledBorder(new LineBorder( new java.awt.Color(0, 0, 0), 1, false), "Fermentables", TitledBorder.LEADING, TitledBorder.TOP, new java.awt.Font("Dialog", 1, 12), new java.awt.Color(51, 51, 51))); pnlMalt.setLayout(pnlMaltLayout1); { jScrollPane1 = new JScrollPane(); pnlMalt.add(jScrollPane1, BorderLayout.CENTER); { tblMaltModel = new MaltTableModel(this); tblMalt = new JTable(){ public String getToolTipText(MouseEvent e) { String tip = null; java.awt.Point p = e.getPoint(); int rowIndex = rowAtPoint(p); tip = multiLineToolTip(40,tblMaltModel.getDescriptionAt(rowIndex)); return tip; } }; jScrollPane1.setViewportView(tblMalt); tblMalt.setModel(tblMaltModel); tblMalt.setAutoCreateColumnsFromModel(false); tblMalt.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { int i = tblMalt.getSelectedRow(); // descriptionTextArea.setText(myRecipe.getMaltDescription(i)); } }); TableColumn maltColumn = tblMalt.getColumnModel().getColumn(0); // set up malt list combo JComboBox maltComboBox = new JComboBox(); cmbMaltModel = new ComboModel(); maltComboBox.setModel(cmbMaltModel); maltColumn.setCellEditor(new DefaultCellEditor(maltComboBox)); maltComboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { Fermentable f = (Fermentable) cmbMaltModel .getSelectedItem(); int i = tblMalt.getSelectedRow(); if (myRecipe != null && i != -1) { Fermentable f2 = myRecipe.getFermentable(i); f2.setLov(f.getLov()); f2.setPppg(f.getPppg()); f2.setDescription(f.getDescription()); f2.setMashed(f.getMashed()); f2.setSteep(f.getSteep()); } } }); // set up malt units combo JComboBox maltUnitsComboBox = new JComboBox(); cmbMaltUnitsModel = new ComboModel(); maltUnitsComboBox.setModel(cmbMaltUnitsModel); maltColumn = tblMalt.getColumnModel().getColumn(2); maltColumn.setCellEditor(new DefaultCellEditor(maltUnitsComboBox)); maltUnitsComboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { String u = (String) cmbMaltUnitsModel.getSelectedItem(); int i = tblMalt.getSelectedRow(); if (myRecipe != null && i != -1) { Fermentable f2 = myRecipe.getFermentable(i); f2.setUnitsFull(u); myRecipe.calcMaltTotals(); displayRecipe(); } } }); } } { tblMaltTotalsModel = new DefaultTableModel(new String[][]{{""}}, new String[]{"Malt", "Amount", "Units", "Points", "Lov", "Cost/U", "%"}); tblMaltTotals = new JTable(); pnlMalt.add(tblMaltTotals, BorderLayout.SOUTH); tblMaltTotals.setModel(tblMaltTotalsModel); tblMaltTotals.getTableHeader().setEnabled(false); tblMaltTotals.setAutoCreateColumnsFromModel(false); } } { pnlMaltButtons = new JPanel(); pnlTables.add(pnlMaltButtons); FlowLayout pnlMaltButtonsLayout = new FlowLayout(); pnlMaltButtonsLayout.setAlignment(FlowLayout.LEFT); pnlMaltButtonsLayout.setVgap(0); pnlMaltButtons.setLayout(pnlMaltButtonsLayout); pnlMaltButtons.setPreferredSize(new java.awt.Dimension(390, 34)); { tlbMalt = new JToolBar(); pnlMaltButtons.add(tlbMalt); tlbMalt.setPreferredSize(new java.awt.Dimension(140, 20)); tlbMalt.setFloatable(false); { btnAddMalt = new JButton(); tlbMalt.add(btnAddMalt); btnAddMalt.setText("+"); btnAddMalt.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (myRecipe != null) { Fermentable f = new Fermentable(myRecipe.getMaltUnits()); myRecipe.addMalt(f); tblMalt.updateUI(); displayRecipe(); } } }); } { btnDelMalt = new JButton(); tlbMalt.add(btnDelMalt); btnDelMalt.setText("-"); btnDelMalt.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (myRecipe != null) { int i = tblMalt.getSelectedRow(); myRecipe.delMalt(i); tblMalt.updateUI(); displayRecipe(); } } }); } } } { pnlHops = new JPanel(); BorderLayout pnlHopsLayout = new BorderLayout(); pnlHops.setBorder(BorderFactory.createTitledBorder(new LineBorder( new java.awt.Color(0, 0, 0), 1, false), "Hops", TitledBorder.LEADING, TitledBorder.TOP, new java.awt.Font("Dialog", 1, 12), new java.awt.Color(51, 51, 51))); pnlHops.setLayout(pnlHopsLayout); pnlTables.add(pnlHops); { tblHopsTotalsModel = new DefaultTableModel(new String[][]{{""}}, new String[]{"1", "2","3","4","5","6","7","8","9"}); tblHopsTotals = new JTable(); pnlHops.add(tblHopsTotals, BorderLayout.SOUTH); tblHopsTotals.setModel(tblHopsTotalsModel); tblHopsTotals.setAutoCreateColumnsFromModel(false); } { jScrollPane2 = new JScrollPane(); pnlHops.add(jScrollPane2, BorderLayout.CENTER); { tblHopsModel = new HopsTableModel(this); tblHops = new JTable(); jScrollPane2.setViewportView(tblHops); tblHops.setModel(tblHopsModel); tblHops.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { int i = tblHops.getSelectedRow(); descriptionTextArea.setText(myRecipe.getHopDescription(i)); } }); TableColumn hopColumn = tblHops.getColumnModel().getColumn(0); JComboBox hopComboBox = new JComboBox(); cmbHopsModel = new ComboModel(); hopComboBox.setModel(cmbHopsModel); hopColumn.setCellEditor(new DefaultCellEditor(hopComboBox)); hopComboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { Hop h = (Hop) cmbHopsModel.getSelectedItem(); int i = tblHops.getSelectedRow(); if (myRecipe != null && i != -1) { Hop h2 = (Hop) myRecipe.getHop(i); h2.setAlpha(h.getAlpha()); h2.setDescription(h.getDescription()); } } }); // set up hop units combo JComboBox hopsUnitsComboBox = new JComboBox(); cmbHopsUnitsModel = new ComboModel(); hopsUnitsComboBox.setModel(cmbHopsUnitsModel); hopColumn = tblHops.getColumnModel().getColumn(4); hopColumn.setCellEditor(new DefaultCellEditor(hopsUnitsComboBox)); hopsUnitsComboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { String u = (String) cmbHopsUnitsModel.getSelectedItem(); int i = tblHops.getSelectedRow(); if (myRecipe != null && i != -1) { Hop h = (Hop) myRecipe.getHop(i); h.setUnitsFull(u); myRecipe.calcHopsTotals(); // tblHops.updateUI(); displayRecipe(); } } }); // set up hop type combo String [] forms = {"Leaf","Pellet","Plug"}; JComboBox hopsFormComboBox = new JComboBox(forms); hopColumn = tblHops.getColumnModel().getColumn(1); hopColumn.setCellEditor(new DefaultCellEditor(hopsFormComboBox)); // set up hop add combo String [] add = {"Boil","FWH","Dry", "Mash"}; JComboBox hopsAddComboBox = new JComboBox(add); hopColumn = tblHops.getColumnModel().getColumn(5); hopColumn.setCellEditor(new DefaultCellEditor(hopsAddComboBox)); } } } { pnlHopsButtons = new JPanel(); FlowLayout pnlHopsButtonsLayout = new FlowLayout(); pnlHopsButtonsLayout.setAlignment(FlowLayout.LEFT); pnlHopsButtonsLayout.setVgap(0); pnlHopsButtons.setLayout(pnlHopsButtonsLayout); pnlTables.add(pnlHopsButtons); pnlHopsButtons.setPreferredSize(new java.awt.Dimension(512, 16)); { tlbHops = new JToolBar(); pnlHopsButtons.add(tlbHops); tlbHops.setPreferredSize(new java.awt.Dimension(70, 19)); tlbHops.setFloatable(false); { btnAddHop = new JButton(); tlbHops.add(btnAddHop); btnAddHop.setText("+"); btnAddHop.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (myRecipe != null) { Hop h = new Hop(myRecipe.getHopUnits()); myRecipe.addHop(h); tblHops.updateUI(); displayRecipe(); } } }); } { btnDelHop = new JButton(); tlbHops.add(btnDelHop); btnDelHop.setText("-"); btnDelHop.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (myRecipe != null) { int i = tblHops.getSelectedRow(); myRecipe.delHop(i); tblHops.updateUI(); displayRecipe(); } } }); } } } } { descriptionPanel = new JPanel(); FlowLayout descriptionPanelLayout = new FlowLayout(); descriptionPanel.setLayout(descriptionPanelLayout); pnlMain.add(descriptionPanel, new GridBagConstraints( 1, 0, 1, 3, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.VERTICAL, new Insets(0, 0, 0, 0), 0, 0)); descriptionPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); { descriptionTextArea = new JTextArea(); descriptionPanel.add(descriptionTextArea); descriptionTextArea.setText("Description"); descriptionTextArea.setFont(new java.awt.Font("Dialog", 0, 10)); descriptionTextArea.setEditable(false); descriptionTextArea.setFocusable(false); descriptionTextArea.setLineWrap(true); descriptionTextArea.setWrapStyleWord(true); } } { statusPanel = new JPanel(); FlowLayout statusPanelLayout = new FlowLayout(); statusPanelLayout.setAlignment(FlowLayout.LEFT); statusPanel.setLayout(statusPanelLayout); pnlMain.add(statusPanel, new GridBagConstraints( 0, 3, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); statusPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); { fileNameLabel = new JLabel(); statusPanel.add(fileNameLabel); fileNameLabel.setText("File Name"); fileNameLabel.setFont(new java.awt.Font("Dialog",1,10)); } } } { jMenuBar1 = new JMenuBar(); setJMenuBar(jMenuBar1); { jMenu3 = new JMenu(); jMenuBar1.add(jMenu3); jMenu3.setText("File"); { newFileMenuItem = new JMenuItem(); jMenu3.add(newFileMenuItem); newFileMenuItem.setText("New"); newFileMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // This is just a test right now to see that // stuff is changed. myRecipe = new Recipe(); attachRecipeData(); displayRecipe(); } }); } { openFileMenuItem = new JMenuItem(); jMenu3.add(openFileMenuItem); openFileMenuItem.setText("Open"); openFileMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // Show open dialog; this method does // not return until the dialog is closed int returnVal = fileChooser.showOpenDialog(jMenuBar1); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); System.out.print("Opening: " + file.getName() + ".\n"); ImportXml imp = new ImportXml(file.toString()); myRecipe = imp.handler.getRecipe(); myRecipe.calcMaltTotals(); myRecipe.calcHopsTotals(); myRecipe.mash.calcMashSchedule(); attachRecipeData(); displayRecipe(); // show true file name fileName = file.getName(); fileNameLabel.setText(fileName); } else { System.out.print("Open command cancelled by user.\n"); } } }); } { saveMenuItem = new JMenuItem(); jMenu3.add(saveMenuItem); saveMenuItem.setText("Save"); } { saveAsMenuItem = new JMenuItem(); jMenu3.add(saveAsMenuItem); saveAsMenuItem.setText("Save As ..."); saveAsMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (DEBUG){ // This is just a test right now to see that // stuff is changed. System.out.print(myRecipe.toXML()); } // Show save dialog; this method does // not return until the dialog is closed int returnVal = fileChooser.showSaveDialog(jMenuBar1); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); //This is where a real application would save the file. try { FileWriter out = new FileWriter(file); out.write(myRecipe.toXML()); out.close(); } catch (Exception e){ // TODO: handle io exception } } else { System.out.print("Save command cancelled by user.\n"); } } }); } { exportMenu = new JMenu(); jMenu3.add(exportMenu); exportMenu.setText("Export"); { exportHTMLmenu = new JMenuItem(); exportMenu.add(exportHTMLmenu); exportHTMLmenu.setText("HTML"); exportHTMLmenu.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // Show save dialog; this method does // not return until the dialog is closed fileChooser.setSelectedFile(new File(myRecipe.getName()+".html")); int returnVal = fileChooser.showSaveDialog(jMenuBar1); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); //This is where a real application would save the file. try { saveAsHTML(file); } catch (Exception e){ // TODO: handle io exception } } else { System.out.print("Save command cancelled by user.\n"); } } }); exportTextMenuItem = new JMenuItem(); exportMenu.add(exportTextMenuItem); exportTextMenuItem.setText("Text"); exportTextMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // Show save dialog; this method does // not return until the dialog is closed fileChooser.setSelectedFile(new File(myRecipe.getName()+".txt")); int returnVal = fileChooser.showSaveDialog(jMenuBar1); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); //This is where a real application would save the file. try { FileWriter out = new FileWriter(file); out.write(myRecipe.toText()); out.close(); } catch (Exception e){ // TODO: handle io exception } } else { System.out.print("Export text command cancelled by user.\n"); } } }); } } { jSeparator2 = new JSeparator(); jMenu3.add(jSeparator2); } { exitMenuItem = new JMenuItem(); jMenu3.add(exitMenuItem); exitMenuItem.setText("Exit"); exitMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // exit program System.exit(0); } }); } } { jMenu4 = new JMenu(); jMenuBar1.add(jMenu4); jMenu4.setText("Edit"); { final JFrame owner = this; editPrefsMenuItem = new JMenuItem(); jMenu4.add(editPrefsMenuItem); editPrefsMenuItem.setText("Preferences..."); editPrefsMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { PreferencesDialog d = new PreferencesDialog(owner, preferences); d.setVisible(true); } }); } { jSeparator1 = new JSeparator(); jMenu4.add(jSeparator1); } { deleteMenuItem = new JMenuItem(); jMenu4.add(deleteMenuItem); deleteMenuItem.setText("Delete"); deleteMenuItem.setEnabled(false); } } { mnuView = new JMenu(); jMenuBar1.add(mnuView); mnuView.setText("View"); { mashManagerMenuItem = new JMenuItem(); mnuView.add(mashManagerMenuItem); mashManagerMenuItem.setText("Mash Manager..."); mashManagerMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { mashMgr = new MashManager(myRecipe); mashMgr.setVisible(true); } }); } } { jMenu5 = new JMenu(); jMenuBar1.add(jMenu5); jMenu5.setText("Help"); { helpMenuItem = new JMenuItem(); jMenu5.add(helpMenuItem); helpMenuItem.setText("Help"); } { aboutMenuItem = new JMenuItem(); jMenu5.add(aboutMenuItem); aboutMenuItem.setText("About..."); final JFrame owner = this; aboutMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { aboutDlg = new AboutDialog(owner); aboutDlg.setVisible(true); } }); } } } } catch (Exception e) { e.printStackTrace(); } } |
pnlStyle.add(cmbStyle2); | pnlStyle.add(cmbStyle2, new GridBagConstraints( 1, 2, 5, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); | private void initGUI() { try { this.setSize(520, 532); this.addWindowListener(new WindowAdapter() { public void windowClosed(WindowEvent evt) { System.exit(1); } }); { pnlMain = new JPanel(); GridBagLayout jPanel2Layout = new GridBagLayout(); jPanel2Layout.columnWeights = new double[] {0.1,0.1}; jPanel2Layout.columnWidths = new int[] {7,7}; jPanel2Layout.rowWeights = new double[] {0.1,0.1,0.9,0.1}; jPanel2Layout.rowHeights = new int[] {7,7,7,7}; pnlMain.setLayout(jPanel2Layout); this.getContentPane().add(pnlMain, BorderLayout.CENTER); { jPanel1 = new JPanel(); pnlMain.add(jPanel1, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); FlowLayout jPanel1Layout = new FlowLayout(); jPanel1Layout.setAlignment(FlowLayout.LEFT); jPanel1.setLayout(jPanel1Layout); { lblName = new JLabel(); jPanel1.add(lblName); lblName.setText("Name:"); } { txtName = new JTextField(); jPanel1.add(txtName); txtName.setText("Name"); txtName.setPreferredSize(new java.awt.Dimension(179, 20)); txtName.addActionListener(this); txtName.addFocusListener(this); } } { jTabbedPane1 = new JTabbedPane(); pnlMain.add(jTabbedPane1, new GridBagConstraints(0, 1, 1, 1, 0.1, 0.1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); { pnlDetails = new JPanel(); GridBagLayout pnlDetailsLayout = new GridBagLayout(); pnlDetailsLayout.columnWeights = new double[] {0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1}; pnlDetailsLayout.columnWidths = new int[] {7,7,7,7,7,7,7,7,7,7}; pnlDetailsLayout.rowWeights = new double[] {0.1,0.1,0.1,0.1,0.1,0.1,0.1}; pnlDetailsLayout.rowHeights = new int[] {7,7,7,7,7,7,7}; pnlDetails.setLayout(pnlDetailsLayout); jTabbedPane1.addTab("Details", null, pnlDetails, null); pnlDetails.setPreferredSize(new java.awt.Dimension(20, 16)); { lblBrewer = new JLabel(); pnlDetails.add(lblBrewer, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblBrewer.setText("Brewer:"); } { txtBrewer = new JTextField(); pnlDetails.add(txtBrewer, new GridBagConstraints( 1, 0, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); txtBrewer.addFocusListener(this); txtBrewer.addActionListener(this); txtBrewer.setText("Brewer"); } { lblDate = new JLabel(); pnlDetails.add(lblDate, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblDate.setText("Date:"); } { lblStyle = new JLabel(); pnlDetails.add(lblStyle, new GridBagConstraints( 0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblStyle.setText("Style:"); } { lblYeast = new JLabel(); pnlDetails.add(lblYeast, new GridBagConstraints( 0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblYeast.setText("Yeast:"); } { lblPreBoil = new JLabel(); pnlDetails.add(lblPreBoil, new GridBagConstraints( 0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblPreBoil.setText("Pre boil:"); } { lblPostBoil = new JLabel(); pnlDetails.add(lblPostBoil, new GridBagConstraints( 0, 5, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblPostBoil.setText("Post boil:"); } { lblEffic = new JLabel(); pnlDetails.add(lblEffic, new GridBagConstraints( 3, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblEffic.setText("Effic:"); } { lblAtten = new JLabel(); pnlDetails.add(lblAtten, new GridBagConstraints( 3, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblAtten.setText("Atten:"); } { lblOG = new JLabel(); pnlDetails.add(lblOG, new GridBagConstraints( 5, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblOG.setText("OG:"); } { lblFG = new JLabel(); pnlDetails.add(lblFG, new GridBagConstraints( 5, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblFG.setText("FG:"); } { lblIBU = new JLabel(); pnlDetails.add(lblIBU, new GridBagConstraints( 7, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblIBU.setText("IBU:"); } { lblAlc = new JLabel(); pnlDetails.add(lblAlc, new GridBagConstraints( 7, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblAlc.setText("%Alc:"); } { lblColour = new JLabel(); pnlDetails.add(lblColour, new GridBagConstraints( 7, 2, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblColour.setText("Colour:"); } { txtDate = new JFormattedTextField(); pnlDetails.add(txtDate, new GridBagConstraints( 1, 1, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); txtDate.setText("Date"); txtDate.addFocusListener(this); txtDate.addActionListener(this); } { cmbStyleModel = new ComboModel(); cmbStyle = new JComboBox(); pnlDetails.add(cmbStyle, new GridBagConstraints( 1, 2, 5, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); cmbStyle.setModel(cmbStyleModel); cmbStyle.setMaximumSize(new java.awt.Dimension(100, 32767)); cmbStyle.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { Style s = (Style) cmbStyleModel.getSelectedItem(); if (myRecipe != null && s != myRecipe.getStyleObj()) { myRecipe.setStyle(s); } descriptionTextArea.setText(s.getDescription()); cmbStyle.setToolTipText(multiLineToolTip(50,s.getDescription())); } }); } { txtPreBoil = new JFormattedTextField(); pnlDetails.add(txtPreBoil, new GridBagConstraints( 1, 4, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); txtPreBoil.setText("Pre Boil"); txtPreBoil.addFocusListener(this); txtPreBoil.addActionListener(this); } { postBoilText = new JFormattedTextField(); pnlDetails.add(postBoilText, new GridBagConstraints( 1, 5, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); postBoilText.setText("Post Boil"); postBoilText.addFocusListener(new FocusAdapter() { public void focusLost(FocusEvent evt) { myRecipe.setPostBoil(Double.parseDouble(postBoilText.getText() .toString())); displayRecipe(); } }); postBoilText.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { myRecipe.setPostBoil(Double.parseDouble(postBoilText.getText() .toString())); displayRecipe(); } }); } { lblComments = new JLabel(); pnlDetails.add(lblComments, new GridBagConstraints( 6, 3, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblComments.setText("Comments:"); } { SpinnerNumberModel spnEfficModel = new SpinnerNumberModel(75.0, 0.0, 100.0, 1.0); spnEffic = new JSpinner(); pnlDetails.add(spnEffic, new GridBagConstraints( 4, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); spnEffic.setModel(spnEfficModel); spnEffic.setMaximumSize(new java.awt.Dimension(70, 32767)); spnEffic.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent evt) { myRecipe.setEfficiency(Double.parseDouble(spnEffic.getValue() .toString())); displayRecipe(); } }); spnEffic.setEditor(new JSpinner.NumberEditor(spnEffic, "00.#")); spnEffic.getEditor().setPreferredSize(new java.awt.Dimension(28, 16)); } { SpinnerNumberModel spnAttenModel = new SpinnerNumberModel(75.0, 0.0, 100.0, 1.0); spnAtten = new JSpinner(); pnlDetails.add(spnAtten, new GridBagConstraints( 4, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); spnAtten.setModel(spnAttenModel); spnAtten.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent evt) { myRecipe.setAttenuation(Double.parseDouble(spnAtten.getValue() .toString())); displayRecipe(); } }); spnAtten.setEditor(new JSpinner.NumberEditor(spnAtten, "00.#")); } { SpinnerNumberModel spnOgModel = new SpinnerNumberModel(1.000, 0.900, 2.000, 0.001); spnOG = new JSpinner(); pnlDetails.add(spnOG, new GridBagConstraints( 6, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); spnOG.setModel(spnOgModel); spnOG.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent evt) { myRecipe.setEstOg(Double.parseDouble(spnOG.getValue() .toString())); displayRecipe(); } }); spnOG.setEditor(new JSpinner.NumberEditor(spnOG, "0.000")); spnOG.getEditor().setPreferredSize(new java.awt.Dimension(20, 16)); } { SpinnerNumberModel spnFgModel = new SpinnerNumberModel(1.000, 0.900, 2.000, 0.001); spnFG = new JSpinner(); pnlDetails.add(spnFG, new GridBagConstraints( 6, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); spnFG.setModel(spnFgModel); spnFG.setEditor(new JSpinner.NumberEditor(spnFG, "0.000")); spnFG.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent evt) { // set the new FG, and update alc: myRecipe.setEstFg(Double.parseDouble(spnFG.getValue() .toString())); displayRecipe(); } }); } { lblIBUvalue = new JLabel(); pnlDetails.add(lblIBUvalue, new GridBagConstraints( 8, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblIBUvalue.setText("IBUs"); } { lblColourValue = new JLabel(); pnlDetails.add(lblColourValue, new GridBagConstraints( 8, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblColourValue.setText("Colour"); } { lblAlcValue = new JLabel(); pnlDetails.add(lblAlcValue, new GridBagConstraints( 8, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblAlcValue.setText("Alc"); } { scpComments = new JScrollPane(); pnlDetails.add(scpComments, new GridBagConstraints( 6, 4, 3, 2, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); { txtComments = new JTextArea(); scpComments.setViewportView(txtComments); txtComments.setText("Comments"); txtComments.setWrapStyleWord(true); txtComments.setPreferredSize(new java.awt.Dimension(117, 42)); txtComments.addFocusListener(new FocusAdapter() { public void focusLost(FocusEvent evt) { if (!txtComments.getText().equals(myRecipe.getComments())) { myRecipe.setComments(txtComments.getText()); } } }); } } { cmbYeastModel = new ComboModel(); cmbYeast = new JComboBox(); pnlDetails.add(cmbYeast, new GridBagConstraints( 1, 3, 5, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); cmbYeast.setModel(cmbYeastModel); cmbYeast.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { Yeast y = (Yeast) cmbYeastModel.getSelectedItem(); if (myRecipe != null && y != myRecipe.getYeastObj()) { myRecipe.setYeast(y); } cmbYeast.setToolTipText(multiLineToolTip(40,y.getDescription())); } }); } { cmbSizeUnitsModel = new ComboModel(); cmbSizeUnits = new JComboBox(); pnlDetails.add(cmbSizeUnits, new GridBagConstraints( 2, 4, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); cmbSizeUnits.setModel(cmbSizeUnitsModel); cmbSizeUnits.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { String q = (String) cmbSizeUnits.getSelectedItem(); if (myRecipe != null && q != myRecipe.getVolUnits()) { myRecipe.setPostBoilVolUnits(q); displayRecipe(); } } }); } { lblSizeUnits = new JLabel(); pnlDetails.add(lblSizeUnits, new GridBagConstraints( 2, 5, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); lblSizeUnits.setText("Size Units"); } { boilTimeLable = new JLabel(); pnlDetails.add(boilTimeLable, new GridBagConstraints( 4, 4, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); boilTimeLable.setText("Boil Min:"); } { evapLabel = new JLabel(); pnlDetails.add(evapLabel, new GridBagConstraints( 4, 5, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); evapLabel.setText("Evap/hr:"); } { boilMinText = new JTextField(); pnlDetails.add(boilMinText, new GridBagConstraints( 5, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); boilMinText.setText("60"); boilMinText.addFocusListener(this); boilMinText.addActionListener(this); } { evapText = new JTextField(); pnlDetails.add(evapText, new GridBagConstraints( 5, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); evapText.setText("4"); evapText.addFocusListener(this); evapText.addActionListener(this); } } { pnlStyle = new JPanel(); FlowLayout pnlStyleLayout = new FlowLayout(); pnlStyle.setLayout(pnlStyleLayout); jTabbedPane1.addTab("Style", null, pnlStyle, null); { lblStyle2 = new JLabel(); pnlStyle.add(lblStyle2); lblStyle2.setText("Style:"); } { ComboBoxModel cmbStyle2Model = new DefaultComboBoxModel(new String[]{ "Item One", "Item Two"}); cmbStyle2 = new JComboBox(); pnlStyle.add(cmbStyle2); cmbStyle2.setModel(cmbStyle2Model); } { jPanel2 = new JPanel(); GridBagLayout jPanel2Layout1 = new GridBagLayout(); jPanel2Layout1.columnWeights = new double[]{0.1, 0.1, 0.1, 0.1}; jPanel2Layout1.columnWidths = new int[]{7, 7, 7, 7}; jPanel2Layout1.rowWeights = new double[]{0.1, 0.1, 0.1, 0.1, 0.1, 0.1}; jPanel2Layout1.rowHeights = new int[]{7, 7, 7, 7, 7, 7}; jPanel2.setPreferredSize(new java.awt.Dimension(179, 120)); jPanel2.setLayout(jPanel2Layout1); pnlStyle.add(jPanel2); jPanel2.setBorder(BorderFactory.createTitledBorder(new LineBorder( new java.awt.Color(0, 0, 0), 1, false), "Recipe Conformance:", TitledBorder.LEADING, TitledBorder.TOP, new java.awt.Font( "Dialog", 0, 12), new java.awt.Color(0, 0, 0))); { jLabel5 = new JLabel(); jPanel2.add(jLabel5, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel5.setText("OG:"); jLabel5.setBounds(74, 3, 60, 30); } { jLabel1 = new JLabel(); jPanel2.add(jLabel1, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); GridLayout jLabel1Layout = new GridLayout(1, 1); jLabel1.setLayout(jLabel1Layout); jLabel1.setText("Low:"); } { jLabel2 = new JLabel(); jPanel2.add(jLabel2, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel2.setText("Recipe:"); } { jLabel3 = new JLabel(); jPanel2.add(jLabel3, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel3.setText("High:"); } { jLabel4 = new JLabel(); jPanel2.add(jLabel4, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel4.setText("IBU:"); } { jLabel6 = new JLabel(); jPanel2.add(jLabel6, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel6.setText("Colour:"); } { jLabel7 = new JLabel(); jPanel2.add(jLabel7, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel7.setText("ABV:"); } } { jScrollPane3 = new JScrollPane(); pnlStyle.add(jScrollPane3); { txaStyles = new JTextArea(); jScrollPane3.setViewportView(txaStyles); txaStyles.setText("Matched Styles"); } } { sldMatch = new JSlider(); pnlStyle.add(sldMatch); } } { miscPanel = new MiscPanel(myRecipe); jTabbedPane1.addTab("Misc", null, miscPanel, null); } { notesPanel = new NotesPanel(); jTabbedPane1.addTab("Notes", null, notesPanel, null); } } { pnlTables = new JPanel(); BoxLayout pnlMaltsLayout = new BoxLayout(pnlTables, javax.swing.BoxLayout.Y_AXIS); pnlMain.add(pnlTables, new GridBagConstraints(0, 2, 1, 1, 0.5, 0.5, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); pnlTables.setLayout(pnlMaltsLayout); { pnlMalt = new JPanel(); pnlTables.add(pnlMalt); BorderLayout pnlMaltLayout1 = new BorderLayout(); FlowLayout pnlMaltLayout = new FlowLayout(); pnlMalt.setBorder(BorderFactory.createTitledBorder(new LineBorder( new java.awt.Color(0, 0, 0), 1, false), "Fermentables", TitledBorder.LEADING, TitledBorder.TOP, new java.awt.Font("Dialog", 1, 12), new java.awt.Color(51, 51, 51))); pnlMalt.setLayout(pnlMaltLayout1); { jScrollPane1 = new JScrollPane(); pnlMalt.add(jScrollPane1, BorderLayout.CENTER); { tblMaltModel = new MaltTableModel(this); tblMalt = new JTable(){ public String getToolTipText(MouseEvent e) { String tip = null; java.awt.Point p = e.getPoint(); int rowIndex = rowAtPoint(p); tip = multiLineToolTip(40,tblMaltModel.getDescriptionAt(rowIndex)); return tip; } }; jScrollPane1.setViewportView(tblMalt); tblMalt.setModel(tblMaltModel); tblMalt.setAutoCreateColumnsFromModel(false); tblMalt.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { int i = tblMalt.getSelectedRow(); // descriptionTextArea.setText(myRecipe.getMaltDescription(i)); } }); TableColumn maltColumn = tblMalt.getColumnModel().getColumn(0); // set up malt list combo JComboBox maltComboBox = new JComboBox(); cmbMaltModel = new ComboModel(); maltComboBox.setModel(cmbMaltModel); maltColumn.setCellEditor(new DefaultCellEditor(maltComboBox)); maltComboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { Fermentable f = (Fermentable) cmbMaltModel .getSelectedItem(); int i = tblMalt.getSelectedRow(); if (myRecipe != null && i != -1) { Fermentable f2 = myRecipe.getFermentable(i); f2.setLov(f.getLov()); f2.setPppg(f.getPppg()); f2.setDescription(f.getDescription()); f2.setMashed(f.getMashed()); f2.setSteep(f.getSteep()); } } }); // set up malt units combo JComboBox maltUnitsComboBox = new JComboBox(); cmbMaltUnitsModel = new ComboModel(); maltUnitsComboBox.setModel(cmbMaltUnitsModel); maltColumn = tblMalt.getColumnModel().getColumn(2); maltColumn.setCellEditor(new DefaultCellEditor(maltUnitsComboBox)); maltUnitsComboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { String u = (String) cmbMaltUnitsModel.getSelectedItem(); int i = tblMalt.getSelectedRow(); if (myRecipe != null && i != -1) { Fermentable f2 = myRecipe.getFermentable(i); f2.setUnitsFull(u); myRecipe.calcMaltTotals(); displayRecipe(); } } }); } } { tblMaltTotalsModel = new DefaultTableModel(new String[][]{{""}}, new String[]{"Malt", "Amount", "Units", "Points", "Lov", "Cost/U", "%"}); tblMaltTotals = new JTable(); pnlMalt.add(tblMaltTotals, BorderLayout.SOUTH); tblMaltTotals.setModel(tblMaltTotalsModel); tblMaltTotals.getTableHeader().setEnabled(false); tblMaltTotals.setAutoCreateColumnsFromModel(false); } } { pnlMaltButtons = new JPanel(); pnlTables.add(pnlMaltButtons); FlowLayout pnlMaltButtonsLayout = new FlowLayout(); pnlMaltButtonsLayout.setAlignment(FlowLayout.LEFT); pnlMaltButtonsLayout.setVgap(0); pnlMaltButtons.setLayout(pnlMaltButtonsLayout); pnlMaltButtons.setPreferredSize(new java.awt.Dimension(390, 34)); { tlbMalt = new JToolBar(); pnlMaltButtons.add(tlbMalt); tlbMalt.setPreferredSize(new java.awt.Dimension(140, 20)); tlbMalt.setFloatable(false); { btnAddMalt = new JButton(); tlbMalt.add(btnAddMalt); btnAddMalt.setText("+"); btnAddMalt.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (myRecipe != null) { Fermentable f = new Fermentable(myRecipe.getMaltUnits()); myRecipe.addMalt(f); tblMalt.updateUI(); displayRecipe(); } } }); } { btnDelMalt = new JButton(); tlbMalt.add(btnDelMalt); btnDelMalt.setText("-"); btnDelMalt.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (myRecipe != null) { int i = tblMalt.getSelectedRow(); myRecipe.delMalt(i); tblMalt.updateUI(); displayRecipe(); } } }); } } } { pnlHops = new JPanel(); BorderLayout pnlHopsLayout = new BorderLayout(); pnlHops.setBorder(BorderFactory.createTitledBorder(new LineBorder( new java.awt.Color(0, 0, 0), 1, false), "Hops", TitledBorder.LEADING, TitledBorder.TOP, new java.awt.Font("Dialog", 1, 12), new java.awt.Color(51, 51, 51))); pnlHops.setLayout(pnlHopsLayout); pnlTables.add(pnlHops); { tblHopsTotalsModel = new DefaultTableModel(new String[][]{{""}}, new String[]{"1", "2","3","4","5","6","7","8","9"}); tblHopsTotals = new JTable(); pnlHops.add(tblHopsTotals, BorderLayout.SOUTH); tblHopsTotals.setModel(tblHopsTotalsModel); tblHopsTotals.setAutoCreateColumnsFromModel(false); } { jScrollPane2 = new JScrollPane(); pnlHops.add(jScrollPane2, BorderLayout.CENTER); { tblHopsModel = new HopsTableModel(this); tblHops = new JTable(); jScrollPane2.setViewportView(tblHops); tblHops.setModel(tblHopsModel); tblHops.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { int i = tblHops.getSelectedRow(); descriptionTextArea.setText(myRecipe.getHopDescription(i)); } }); TableColumn hopColumn = tblHops.getColumnModel().getColumn(0); JComboBox hopComboBox = new JComboBox(); cmbHopsModel = new ComboModel(); hopComboBox.setModel(cmbHopsModel); hopColumn.setCellEditor(new DefaultCellEditor(hopComboBox)); hopComboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { Hop h = (Hop) cmbHopsModel.getSelectedItem(); int i = tblHops.getSelectedRow(); if (myRecipe != null && i != -1) { Hop h2 = (Hop) myRecipe.getHop(i); h2.setAlpha(h.getAlpha()); h2.setDescription(h.getDescription()); } } }); // set up hop units combo JComboBox hopsUnitsComboBox = new JComboBox(); cmbHopsUnitsModel = new ComboModel(); hopsUnitsComboBox.setModel(cmbHopsUnitsModel); hopColumn = tblHops.getColumnModel().getColumn(4); hopColumn.setCellEditor(new DefaultCellEditor(hopsUnitsComboBox)); hopsUnitsComboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { String u = (String) cmbHopsUnitsModel.getSelectedItem(); int i = tblHops.getSelectedRow(); if (myRecipe != null && i != -1) { Hop h = (Hop) myRecipe.getHop(i); h.setUnitsFull(u); myRecipe.calcHopsTotals(); // tblHops.updateUI(); displayRecipe(); } } }); // set up hop type combo String [] forms = {"Leaf","Pellet","Plug"}; JComboBox hopsFormComboBox = new JComboBox(forms); hopColumn = tblHops.getColumnModel().getColumn(1); hopColumn.setCellEditor(new DefaultCellEditor(hopsFormComboBox)); // set up hop add combo String [] add = {"Boil","FWH","Dry", "Mash"}; JComboBox hopsAddComboBox = new JComboBox(add); hopColumn = tblHops.getColumnModel().getColumn(5); hopColumn.setCellEditor(new DefaultCellEditor(hopsAddComboBox)); } } } { pnlHopsButtons = new JPanel(); FlowLayout pnlHopsButtonsLayout = new FlowLayout(); pnlHopsButtonsLayout.setAlignment(FlowLayout.LEFT); pnlHopsButtonsLayout.setVgap(0); pnlHopsButtons.setLayout(pnlHopsButtonsLayout); pnlTables.add(pnlHopsButtons); pnlHopsButtons.setPreferredSize(new java.awt.Dimension(512, 16)); { tlbHops = new JToolBar(); pnlHopsButtons.add(tlbHops); tlbHops.setPreferredSize(new java.awt.Dimension(70, 19)); tlbHops.setFloatable(false); { btnAddHop = new JButton(); tlbHops.add(btnAddHop); btnAddHop.setText("+"); btnAddHop.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (myRecipe != null) { Hop h = new Hop(myRecipe.getHopUnits()); myRecipe.addHop(h); tblHops.updateUI(); displayRecipe(); } } }); } { btnDelHop = new JButton(); tlbHops.add(btnDelHop); btnDelHop.setText("-"); btnDelHop.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (myRecipe != null) { int i = tblHops.getSelectedRow(); myRecipe.delHop(i); tblHops.updateUI(); displayRecipe(); } } }); } } } } { descriptionPanel = new JPanel(); FlowLayout descriptionPanelLayout = new FlowLayout(); descriptionPanel.setLayout(descriptionPanelLayout); pnlMain.add(descriptionPanel, new GridBagConstraints( 1, 0, 1, 3, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.VERTICAL, new Insets(0, 0, 0, 0), 0, 0)); descriptionPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); { descriptionTextArea = new JTextArea(); descriptionPanel.add(descriptionTextArea); descriptionTextArea.setText("Description"); descriptionTextArea.setFont(new java.awt.Font("Dialog", 0, 10)); descriptionTextArea.setEditable(false); descriptionTextArea.setFocusable(false); descriptionTextArea.setLineWrap(true); descriptionTextArea.setWrapStyleWord(true); } } { statusPanel = new JPanel(); FlowLayout statusPanelLayout = new FlowLayout(); statusPanelLayout.setAlignment(FlowLayout.LEFT); statusPanel.setLayout(statusPanelLayout); pnlMain.add(statusPanel, new GridBagConstraints( 0, 3, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); statusPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); { fileNameLabel = new JLabel(); statusPanel.add(fileNameLabel); fileNameLabel.setText("File Name"); fileNameLabel.setFont(new java.awt.Font("Dialog",1,10)); } } } { jMenuBar1 = new JMenuBar(); setJMenuBar(jMenuBar1); { jMenu3 = new JMenu(); jMenuBar1.add(jMenu3); jMenu3.setText("File"); { newFileMenuItem = new JMenuItem(); jMenu3.add(newFileMenuItem); newFileMenuItem.setText("New"); newFileMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // This is just a test right now to see that // stuff is changed. myRecipe = new Recipe(); attachRecipeData(); displayRecipe(); } }); } { openFileMenuItem = new JMenuItem(); jMenu3.add(openFileMenuItem); openFileMenuItem.setText("Open"); openFileMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // Show open dialog; this method does // not return until the dialog is closed int returnVal = fileChooser.showOpenDialog(jMenuBar1); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); System.out.print("Opening: " + file.getName() + ".\n"); ImportXml imp = new ImportXml(file.toString()); myRecipe = imp.handler.getRecipe(); myRecipe.calcMaltTotals(); myRecipe.calcHopsTotals(); myRecipe.mash.calcMashSchedule(); attachRecipeData(); displayRecipe(); // show true file name fileName = file.getName(); fileNameLabel.setText(fileName); } else { System.out.print("Open command cancelled by user.\n"); } } }); } { saveMenuItem = new JMenuItem(); jMenu3.add(saveMenuItem); saveMenuItem.setText("Save"); } { saveAsMenuItem = new JMenuItem(); jMenu3.add(saveAsMenuItem); saveAsMenuItem.setText("Save As ..."); saveAsMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (DEBUG){ // This is just a test right now to see that // stuff is changed. System.out.print(myRecipe.toXML()); } // Show save dialog; this method does // not return until the dialog is closed int returnVal = fileChooser.showSaveDialog(jMenuBar1); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); //This is where a real application would save the file. try { FileWriter out = new FileWriter(file); out.write(myRecipe.toXML()); out.close(); } catch (Exception e){ // TODO: handle io exception } } else { System.out.print("Save command cancelled by user.\n"); } } }); } { exportMenu = new JMenu(); jMenu3.add(exportMenu); exportMenu.setText("Export"); { exportHTMLmenu = new JMenuItem(); exportMenu.add(exportHTMLmenu); exportHTMLmenu.setText("HTML"); exportHTMLmenu.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // Show save dialog; this method does // not return until the dialog is closed fileChooser.setSelectedFile(new File(myRecipe.getName()+".html")); int returnVal = fileChooser.showSaveDialog(jMenuBar1); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); //This is where a real application would save the file. try { saveAsHTML(file); } catch (Exception e){ // TODO: handle io exception } } else { System.out.print("Save command cancelled by user.\n"); } } }); exportTextMenuItem = new JMenuItem(); exportMenu.add(exportTextMenuItem); exportTextMenuItem.setText("Text"); exportTextMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // Show save dialog; this method does // not return until the dialog is closed fileChooser.setSelectedFile(new File(myRecipe.getName()+".txt")); int returnVal = fileChooser.showSaveDialog(jMenuBar1); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); //This is where a real application would save the file. try { FileWriter out = new FileWriter(file); out.write(myRecipe.toText()); out.close(); } catch (Exception e){ // TODO: handle io exception } } else { System.out.print("Export text command cancelled by user.\n"); } } }); } } { jSeparator2 = new JSeparator(); jMenu3.add(jSeparator2); } { exitMenuItem = new JMenuItem(); jMenu3.add(exitMenuItem); exitMenuItem.setText("Exit"); exitMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // exit program System.exit(0); } }); } } { jMenu4 = new JMenu(); jMenuBar1.add(jMenu4); jMenu4.setText("Edit"); { final JFrame owner = this; editPrefsMenuItem = new JMenuItem(); jMenu4.add(editPrefsMenuItem); editPrefsMenuItem.setText("Preferences..."); editPrefsMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { PreferencesDialog d = new PreferencesDialog(owner, preferences); d.setVisible(true); } }); } { jSeparator1 = new JSeparator(); jMenu4.add(jSeparator1); } { deleteMenuItem = new JMenuItem(); jMenu4.add(deleteMenuItem); deleteMenuItem.setText("Delete"); deleteMenuItem.setEnabled(false); } } { mnuView = new JMenu(); jMenuBar1.add(mnuView); mnuView.setText("View"); { mashManagerMenuItem = new JMenuItem(); mnuView.add(mashManagerMenuItem); mashManagerMenuItem.setText("Mash Manager..."); mashManagerMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { mashMgr = new MashManager(myRecipe); mashMgr.setVisible(true); } }); } } { jMenu5 = new JMenu(); jMenuBar1.add(jMenu5); jMenu5.setText("Help"); { helpMenuItem = new JMenuItem(); jMenu5.add(helpMenuItem); helpMenuItem.setText("Help"); } { aboutMenuItem = new JMenuItem(); jMenu5.add(aboutMenuItem); aboutMenuItem.setText("About..."); final JFrame owner = this; aboutMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { aboutDlg = new AboutDialog(owner); aboutDlg.setVisible(true); } }); } } } } catch (Exception e) { e.printStackTrace(); } } |
cmbStyle2.setMaximumSize(new java.awt.Dimension(100, 32767)); cmbStyle2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { Style s = (Style) cmbStyle2Model.getSelectedItem(); descriptionTextArea.setText(s.getDescription()); cmbStyle2.setToolTipText(multiLineToolTip(50,s.getDescription())); } }); | private void initGUI() { try { this.setSize(520, 532); this.addWindowListener(new WindowAdapter() { public void windowClosed(WindowEvent evt) { System.exit(1); } }); { pnlMain = new JPanel(); GridBagLayout jPanel2Layout = new GridBagLayout(); jPanel2Layout.columnWeights = new double[] {0.1,0.1}; jPanel2Layout.columnWidths = new int[] {7,7}; jPanel2Layout.rowWeights = new double[] {0.1,0.1,0.9,0.1}; jPanel2Layout.rowHeights = new int[] {7,7,7,7}; pnlMain.setLayout(jPanel2Layout); this.getContentPane().add(pnlMain, BorderLayout.CENTER); { jPanel1 = new JPanel(); pnlMain.add(jPanel1, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); FlowLayout jPanel1Layout = new FlowLayout(); jPanel1Layout.setAlignment(FlowLayout.LEFT); jPanel1.setLayout(jPanel1Layout); { lblName = new JLabel(); jPanel1.add(lblName); lblName.setText("Name:"); } { txtName = new JTextField(); jPanel1.add(txtName); txtName.setText("Name"); txtName.setPreferredSize(new java.awt.Dimension(179, 20)); txtName.addActionListener(this); txtName.addFocusListener(this); } } { jTabbedPane1 = new JTabbedPane(); pnlMain.add(jTabbedPane1, new GridBagConstraints(0, 1, 1, 1, 0.1, 0.1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); { pnlDetails = new JPanel(); GridBagLayout pnlDetailsLayout = new GridBagLayout(); pnlDetailsLayout.columnWeights = new double[] {0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1}; pnlDetailsLayout.columnWidths = new int[] {7,7,7,7,7,7,7,7,7,7}; pnlDetailsLayout.rowWeights = new double[] {0.1,0.1,0.1,0.1,0.1,0.1,0.1}; pnlDetailsLayout.rowHeights = new int[] {7,7,7,7,7,7,7}; pnlDetails.setLayout(pnlDetailsLayout); jTabbedPane1.addTab("Details", null, pnlDetails, null); pnlDetails.setPreferredSize(new java.awt.Dimension(20, 16)); { lblBrewer = new JLabel(); pnlDetails.add(lblBrewer, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblBrewer.setText("Brewer:"); } { txtBrewer = new JTextField(); pnlDetails.add(txtBrewer, new GridBagConstraints( 1, 0, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); txtBrewer.addFocusListener(this); txtBrewer.addActionListener(this); txtBrewer.setText("Brewer"); } { lblDate = new JLabel(); pnlDetails.add(lblDate, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblDate.setText("Date:"); } { lblStyle = new JLabel(); pnlDetails.add(lblStyle, new GridBagConstraints( 0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblStyle.setText("Style:"); } { lblYeast = new JLabel(); pnlDetails.add(lblYeast, new GridBagConstraints( 0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblYeast.setText("Yeast:"); } { lblPreBoil = new JLabel(); pnlDetails.add(lblPreBoil, new GridBagConstraints( 0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblPreBoil.setText("Pre boil:"); } { lblPostBoil = new JLabel(); pnlDetails.add(lblPostBoil, new GridBagConstraints( 0, 5, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblPostBoil.setText("Post boil:"); } { lblEffic = new JLabel(); pnlDetails.add(lblEffic, new GridBagConstraints( 3, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblEffic.setText("Effic:"); } { lblAtten = new JLabel(); pnlDetails.add(lblAtten, new GridBagConstraints( 3, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblAtten.setText("Atten:"); } { lblOG = new JLabel(); pnlDetails.add(lblOG, new GridBagConstraints( 5, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblOG.setText("OG:"); } { lblFG = new JLabel(); pnlDetails.add(lblFG, new GridBagConstraints( 5, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblFG.setText("FG:"); } { lblIBU = new JLabel(); pnlDetails.add(lblIBU, new GridBagConstraints( 7, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblIBU.setText("IBU:"); } { lblAlc = new JLabel(); pnlDetails.add(lblAlc, new GridBagConstraints( 7, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblAlc.setText("%Alc:"); } { lblColour = new JLabel(); pnlDetails.add(lblColour, new GridBagConstraints( 7, 2, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblColour.setText("Colour:"); } { txtDate = new JFormattedTextField(); pnlDetails.add(txtDate, new GridBagConstraints( 1, 1, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); txtDate.setText("Date"); txtDate.addFocusListener(this); txtDate.addActionListener(this); } { cmbStyleModel = new ComboModel(); cmbStyle = new JComboBox(); pnlDetails.add(cmbStyle, new GridBagConstraints( 1, 2, 5, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); cmbStyle.setModel(cmbStyleModel); cmbStyle.setMaximumSize(new java.awt.Dimension(100, 32767)); cmbStyle.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { Style s = (Style) cmbStyleModel.getSelectedItem(); if (myRecipe != null && s != myRecipe.getStyleObj()) { myRecipe.setStyle(s); } descriptionTextArea.setText(s.getDescription()); cmbStyle.setToolTipText(multiLineToolTip(50,s.getDescription())); } }); } { txtPreBoil = new JFormattedTextField(); pnlDetails.add(txtPreBoil, new GridBagConstraints( 1, 4, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); txtPreBoil.setText("Pre Boil"); txtPreBoil.addFocusListener(this); txtPreBoil.addActionListener(this); } { postBoilText = new JFormattedTextField(); pnlDetails.add(postBoilText, new GridBagConstraints( 1, 5, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); postBoilText.setText("Post Boil"); postBoilText.addFocusListener(new FocusAdapter() { public void focusLost(FocusEvent evt) { myRecipe.setPostBoil(Double.parseDouble(postBoilText.getText() .toString())); displayRecipe(); } }); postBoilText.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { myRecipe.setPostBoil(Double.parseDouble(postBoilText.getText() .toString())); displayRecipe(); } }); } { lblComments = new JLabel(); pnlDetails.add(lblComments, new GridBagConstraints( 6, 3, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblComments.setText("Comments:"); } { SpinnerNumberModel spnEfficModel = new SpinnerNumberModel(75.0, 0.0, 100.0, 1.0); spnEffic = new JSpinner(); pnlDetails.add(spnEffic, new GridBagConstraints( 4, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); spnEffic.setModel(spnEfficModel); spnEffic.setMaximumSize(new java.awt.Dimension(70, 32767)); spnEffic.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent evt) { myRecipe.setEfficiency(Double.parseDouble(spnEffic.getValue() .toString())); displayRecipe(); } }); spnEffic.setEditor(new JSpinner.NumberEditor(spnEffic, "00.#")); spnEffic.getEditor().setPreferredSize(new java.awt.Dimension(28, 16)); } { SpinnerNumberModel spnAttenModel = new SpinnerNumberModel(75.0, 0.0, 100.0, 1.0); spnAtten = new JSpinner(); pnlDetails.add(spnAtten, new GridBagConstraints( 4, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); spnAtten.setModel(spnAttenModel); spnAtten.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent evt) { myRecipe.setAttenuation(Double.parseDouble(spnAtten.getValue() .toString())); displayRecipe(); } }); spnAtten.setEditor(new JSpinner.NumberEditor(spnAtten, "00.#")); } { SpinnerNumberModel spnOgModel = new SpinnerNumberModel(1.000, 0.900, 2.000, 0.001); spnOG = new JSpinner(); pnlDetails.add(spnOG, new GridBagConstraints( 6, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); spnOG.setModel(spnOgModel); spnOG.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent evt) { myRecipe.setEstOg(Double.parseDouble(spnOG.getValue() .toString())); displayRecipe(); } }); spnOG.setEditor(new JSpinner.NumberEditor(spnOG, "0.000")); spnOG.getEditor().setPreferredSize(new java.awt.Dimension(20, 16)); } { SpinnerNumberModel spnFgModel = new SpinnerNumberModel(1.000, 0.900, 2.000, 0.001); spnFG = new JSpinner(); pnlDetails.add(spnFG, new GridBagConstraints( 6, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); spnFG.setModel(spnFgModel); spnFG.setEditor(new JSpinner.NumberEditor(spnFG, "0.000")); spnFG.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent evt) { // set the new FG, and update alc: myRecipe.setEstFg(Double.parseDouble(spnFG.getValue() .toString())); displayRecipe(); } }); } { lblIBUvalue = new JLabel(); pnlDetails.add(lblIBUvalue, new GridBagConstraints( 8, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblIBUvalue.setText("IBUs"); } { lblColourValue = new JLabel(); pnlDetails.add(lblColourValue, new GridBagConstraints( 8, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblColourValue.setText("Colour"); } { lblAlcValue = new JLabel(); pnlDetails.add(lblAlcValue, new GridBagConstraints( 8, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblAlcValue.setText("Alc"); } { scpComments = new JScrollPane(); pnlDetails.add(scpComments, new GridBagConstraints( 6, 4, 3, 2, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); { txtComments = new JTextArea(); scpComments.setViewportView(txtComments); txtComments.setText("Comments"); txtComments.setWrapStyleWord(true); txtComments.setPreferredSize(new java.awt.Dimension(117, 42)); txtComments.addFocusListener(new FocusAdapter() { public void focusLost(FocusEvent evt) { if (!txtComments.getText().equals(myRecipe.getComments())) { myRecipe.setComments(txtComments.getText()); } } }); } } { cmbYeastModel = new ComboModel(); cmbYeast = new JComboBox(); pnlDetails.add(cmbYeast, new GridBagConstraints( 1, 3, 5, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); cmbYeast.setModel(cmbYeastModel); cmbYeast.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { Yeast y = (Yeast) cmbYeastModel.getSelectedItem(); if (myRecipe != null && y != myRecipe.getYeastObj()) { myRecipe.setYeast(y); } cmbYeast.setToolTipText(multiLineToolTip(40,y.getDescription())); } }); } { cmbSizeUnitsModel = new ComboModel(); cmbSizeUnits = new JComboBox(); pnlDetails.add(cmbSizeUnits, new GridBagConstraints( 2, 4, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); cmbSizeUnits.setModel(cmbSizeUnitsModel); cmbSizeUnits.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { String q = (String) cmbSizeUnits.getSelectedItem(); if (myRecipe != null && q != myRecipe.getVolUnits()) { myRecipe.setPostBoilVolUnits(q); displayRecipe(); } } }); } { lblSizeUnits = new JLabel(); pnlDetails.add(lblSizeUnits, new GridBagConstraints( 2, 5, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); lblSizeUnits.setText("Size Units"); } { boilTimeLable = new JLabel(); pnlDetails.add(boilTimeLable, new GridBagConstraints( 4, 4, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); boilTimeLable.setText("Boil Min:"); } { evapLabel = new JLabel(); pnlDetails.add(evapLabel, new GridBagConstraints( 4, 5, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); evapLabel.setText("Evap/hr:"); } { boilMinText = new JTextField(); pnlDetails.add(boilMinText, new GridBagConstraints( 5, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); boilMinText.setText("60"); boilMinText.addFocusListener(this); boilMinText.addActionListener(this); } { evapText = new JTextField(); pnlDetails.add(evapText, new GridBagConstraints( 5, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); evapText.setText("4"); evapText.addFocusListener(this); evapText.addActionListener(this); } } { pnlStyle = new JPanel(); FlowLayout pnlStyleLayout = new FlowLayout(); pnlStyle.setLayout(pnlStyleLayout); jTabbedPane1.addTab("Style", null, pnlStyle, null); { lblStyle2 = new JLabel(); pnlStyle.add(lblStyle2); lblStyle2.setText("Style:"); } { ComboBoxModel cmbStyle2Model = new DefaultComboBoxModel(new String[]{ "Item One", "Item Two"}); cmbStyle2 = new JComboBox(); pnlStyle.add(cmbStyle2); cmbStyle2.setModel(cmbStyle2Model); } { jPanel2 = new JPanel(); GridBagLayout jPanel2Layout1 = new GridBagLayout(); jPanel2Layout1.columnWeights = new double[]{0.1, 0.1, 0.1, 0.1}; jPanel2Layout1.columnWidths = new int[]{7, 7, 7, 7}; jPanel2Layout1.rowWeights = new double[]{0.1, 0.1, 0.1, 0.1, 0.1, 0.1}; jPanel2Layout1.rowHeights = new int[]{7, 7, 7, 7, 7, 7}; jPanel2.setPreferredSize(new java.awt.Dimension(179, 120)); jPanel2.setLayout(jPanel2Layout1); pnlStyle.add(jPanel2); jPanel2.setBorder(BorderFactory.createTitledBorder(new LineBorder( new java.awt.Color(0, 0, 0), 1, false), "Recipe Conformance:", TitledBorder.LEADING, TitledBorder.TOP, new java.awt.Font( "Dialog", 0, 12), new java.awt.Color(0, 0, 0))); { jLabel5 = new JLabel(); jPanel2.add(jLabel5, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel5.setText("OG:"); jLabel5.setBounds(74, 3, 60, 30); } { jLabel1 = new JLabel(); jPanel2.add(jLabel1, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); GridLayout jLabel1Layout = new GridLayout(1, 1); jLabel1.setLayout(jLabel1Layout); jLabel1.setText("Low:"); } { jLabel2 = new JLabel(); jPanel2.add(jLabel2, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel2.setText("Recipe:"); } { jLabel3 = new JLabel(); jPanel2.add(jLabel3, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel3.setText("High:"); } { jLabel4 = new JLabel(); jPanel2.add(jLabel4, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel4.setText("IBU:"); } { jLabel6 = new JLabel(); jPanel2.add(jLabel6, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel6.setText("Colour:"); } { jLabel7 = new JLabel(); jPanel2.add(jLabel7, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel7.setText("ABV:"); } } { jScrollPane3 = new JScrollPane(); pnlStyle.add(jScrollPane3); { txaStyles = new JTextArea(); jScrollPane3.setViewportView(txaStyles); txaStyles.setText("Matched Styles"); } } { sldMatch = new JSlider(); pnlStyle.add(sldMatch); } } { miscPanel = new MiscPanel(myRecipe); jTabbedPane1.addTab("Misc", null, miscPanel, null); } { notesPanel = new NotesPanel(); jTabbedPane1.addTab("Notes", null, notesPanel, null); } } { pnlTables = new JPanel(); BoxLayout pnlMaltsLayout = new BoxLayout(pnlTables, javax.swing.BoxLayout.Y_AXIS); pnlMain.add(pnlTables, new GridBagConstraints(0, 2, 1, 1, 0.5, 0.5, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); pnlTables.setLayout(pnlMaltsLayout); { pnlMalt = new JPanel(); pnlTables.add(pnlMalt); BorderLayout pnlMaltLayout1 = new BorderLayout(); FlowLayout pnlMaltLayout = new FlowLayout(); pnlMalt.setBorder(BorderFactory.createTitledBorder(new LineBorder( new java.awt.Color(0, 0, 0), 1, false), "Fermentables", TitledBorder.LEADING, TitledBorder.TOP, new java.awt.Font("Dialog", 1, 12), new java.awt.Color(51, 51, 51))); pnlMalt.setLayout(pnlMaltLayout1); { jScrollPane1 = new JScrollPane(); pnlMalt.add(jScrollPane1, BorderLayout.CENTER); { tblMaltModel = new MaltTableModel(this); tblMalt = new JTable(){ public String getToolTipText(MouseEvent e) { String tip = null; java.awt.Point p = e.getPoint(); int rowIndex = rowAtPoint(p); tip = multiLineToolTip(40,tblMaltModel.getDescriptionAt(rowIndex)); return tip; } }; jScrollPane1.setViewportView(tblMalt); tblMalt.setModel(tblMaltModel); tblMalt.setAutoCreateColumnsFromModel(false); tblMalt.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { int i = tblMalt.getSelectedRow(); // descriptionTextArea.setText(myRecipe.getMaltDescription(i)); } }); TableColumn maltColumn = tblMalt.getColumnModel().getColumn(0); // set up malt list combo JComboBox maltComboBox = new JComboBox(); cmbMaltModel = new ComboModel(); maltComboBox.setModel(cmbMaltModel); maltColumn.setCellEditor(new DefaultCellEditor(maltComboBox)); maltComboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { Fermentable f = (Fermentable) cmbMaltModel .getSelectedItem(); int i = tblMalt.getSelectedRow(); if (myRecipe != null && i != -1) { Fermentable f2 = myRecipe.getFermentable(i); f2.setLov(f.getLov()); f2.setPppg(f.getPppg()); f2.setDescription(f.getDescription()); f2.setMashed(f.getMashed()); f2.setSteep(f.getSteep()); } } }); // set up malt units combo JComboBox maltUnitsComboBox = new JComboBox(); cmbMaltUnitsModel = new ComboModel(); maltUnitsComboBox.setModel(cmbMaltUnitsModel); maltColumn = tblMalt.getColumnModel().getColumn(2); maltColumn.setCellEditor(new DefaultCellEditor(maltUnitsComboBox)); maltUnitsComboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { String u = (String) cmbMaltUnitsModel.getSelectedItem(); int i = tblMalt.getSelectedRow(); if (myRecipe != null && i != -1) { Fermentable f2 = myRecipe.getFermentable(i); f2.setUnitsFull(u); myRecipe.calcMaltTotals(); displayRecipe(); } } }); } } { tblMaltTotalsModel = new DefaultTableModel(new String[][]{{""}}, new String[]{"Malt", "Amount", "Units", "Points", "Lov", "Cost/U", "%"}); tblMaltTotals = new JTable(); pnlMalt.add(tblMaltTotals, BorderLayout.SOUTH); tblMaltTotals.setModel(tblMaltTotalsModel); tblMaltTotals.getTableHeader().setEnabled(false); tblMaltTotals.setAutoCreateColumnsFromModel(false); } } { pnlMaltButtons = new JPanel(); pnlTables.add(pnlMaltButtons); FlowLayout pnlMaltButtonsLayout = new FlowLayout(); pnlMaltButtonsLayout.setAlignment(FlowLayout.LEFT); pnlMaltButtonsLayout.setVgap(0); pnlMaltButtons.setLayout(pnlMaltButtonsLayout); pnlMaltButtons.setPreferredSize(new java.awt.Dimension(390, 34)); { tlbMalt = new JToolBar(); pnlMaltButtons.add(tlbMalt); tlbMalt.setPreferredSize(new java.awt.Dimension(140, 20)); tlbMalt.setFloatable(false); { btnAddMalt = new JButton(); tlbMalt.add(btnAddMalt); btnAddMalt.setText("+"); btnAddMalt.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (myRecipe != null) { Fermentable f = new Fermentable(myRecipe.getMaltUnits()); myRecipe.addMalt(f); tblMalt.updateUI(); displayRecipe(); } } }); } { btnDelMalt = new JButton(); tlbMalt.add(btnDelMalt); btnDelMalt.setText("-"); btnDelMalt.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (myRecipe != null) { int i = tblMalt.getSelectedRow(); myRecipe.delMalt(i); tblMalt.updateUI(); displayRecipe(); } } }); } } } { pnlHops = new JPanel(); BorderLayout pnlHopsLayout = new BorderLayout(); pnlHops.setBorder(BorderFactory.createTitledBorder(new LineBorder( new java.awt.Color(0, 0, 0), 1, false), "Hops", TitledBorder.LEADING, TitledBorder.TOP, new java.awt.Font("Dialog", 1, 12), new java.awt.Color(51, 51, 51))); pnlHops.setLayout(pnlHopsLayout); pnlTables.add(pnlHops); { tblHopsTotalsModel = new DefaultTableModel(new String[][]{{""}}, new String[]{"1", "2","3","4","5","6","7","8","9"}); tblHopsTotals = new JTable(); pnlHops.add(tblHopsTotals, BorderLayout.SOUTH); tblHopsTotals.setModel(tblHopsTotalsModel); tblHopsTotals.setAutoCreateColumnsFromModel(false); } { jScrollPane2 = new JScrollPane(); pnlHops.add(jScrollPane2, BorderLayout.CENTER); { tblHopsModel = new HopsTableModel(this); tblHops = new JTable(); jScrollPane2.setViewportView(tblHops); tblHops.setModel(tblHopsModel); tblHops.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { int i = tblHops.getSelectedRow(); descriptionTextArea.setText(myRecipe.getHopDescription(i)); } }); TableColumn hopColumn = tblHops.getColumnModel().getColumn(0); JComboBox hopComboBox = new JComboBox(); cmbHopsModel = new ComboModel(); hopComboBox.setModel(cmbHopsModel); hopColumn.setCellEditor(new DefaultCellEditor(hopComboBox)); hopComboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { Hop h = (Hop) cmbHopsModel.getSelectedItem(); int i = tblHops.getSelectedRow(); if (myRecipe != null && i != -1) { Hop h2 = (Hop) myRecipe.getHop(i); h2.setAlpha(h.getAlpha()); h2.setDescription(h.getDescription()); } } }); // set up hop units combo JComboBox hopsUnitsComboBox = new JComboBox(); cmbHopsUnitsModel = new ComboModel(); hopsUnitsComboBox.setModel(cmbHopsUnitsModel); hopColumn = tblHops.getColumnModel().getColumn(4); hopColumn.setCellEditor(new DefaultCellEditor(hopsUnitsComboBox)); hopsUnitsComboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { String u = (String) cmbHopsUnitsModel.getSelectedItem(); int i = tblHops.getSelectedRow(); if (myRecipe != null && i != -1) { Hop h = (Hop) myRecipe.getHop(i); h.setUnitsFull(u); myRecipe.calcHopsTotals(); // tblHops.updateUI(); displayRecipe(); } } }); // set up hop type combo String [] forms = {"Leaf","Pellet","Plug"}; JComboBox hopsFormComboBox = new JComboBox(forms); hopColumn = tblHops.getColumnModel().getColumn(1); hopColumn.setCellEditor(new DefaultCellEditor(hopsFormComboBox)); // set up hop add combo String [] add = {"Boil","FWH","Dry", "Mash"}; JComboBox hopsAddComboBox = new JComboBox(add); hopColumn = tblHops.getColumnModel().getColumn(5); hopColumn.setCellEditor(new DefaultCellEditor(hopsAddComboBox)); } } } { pnlHopsButtons = new JPanel(); FlowLayout pnlHopsButtonsLayout = new FlowLayout(); pnlHopsButtonsLayout.setAlignment(FlowLayout.LEFT); pnlHopsButtonsLayout.setVgap(0); pnlHopsButtons.setLayout(pnlHopsButtonsLayout); pnlTables.add(pnlHopsButtons); pnlHopsButtons.setPreferredSize(new java.awt.Dimension(512, 16)); { tlbHops = new JToolBar(); pnlHopsButtons.add(tlbHops); tlbHops.setPreferredSize(new java.awt.Dimension(70, 19)); tlbHops.setFloatable(false); { btnAddHop = new JButton(); tlbHops.add(btnAddHop); btnAddHop.setText("+"); btnAddHop.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (myRecipe != null) { Hop h = new Hop(myRecipe.getHopUnits()); myRecipe.addHop(h); tblHops.updateUI(); displayRecipe(); } } }); } { btnDelHop = new JButton(); tlbHops.add(btnDelHop); btnDelHop.setText("-"); btnDelHop.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (myRecipe != null) { int i = tblHops.getSelectedRow(); myRecipe.delHop(i); tblHops.updateUI(); displayRecipe(); } } }); } } } } { descriptionPanel = new JPanel(); FlowLayout descriptionPanelLayout = new FlowLayout(); descriptionPanel.setLayout(descriptionPanelLayout); pnlMain.add(descriptionPanel, new GridBagConstraints( 1, 0, 1, 3, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.VERTICAL, new Insets(0, 0, 0, 0), 0, 0)); descriptionPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); { descriptionTextArea = new JTextArea(); descriptionPanel.add(descriptionTextArea); descriptionTextArea.setText("Description"); descriptionTextArea.setFont(new java.awt.Font("Dialog", 0, 10)); descriptionTextArea.setEditable(false); descriptionTextArea.setFocusable(false); descriptionTextArea.setLineWrap(true); descriptionTextArea.setWrapStyleWord(true); } } { statusPanel = new JPanel(); FlowLayout statusPanelLayout = new FlowLayout(); statusPanelLayout.setAlignment(FlowLayout.LEFT); statusPanel.setLayout(statusPanelLayout); pnlMain.add(statusPanel, new GridBagConstraints( 0, 3, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); statusPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); { fileNameLabel = new JLabel(); statusPanel.add(fileNameLabel); fileNameLabel.setText("File Name"); fileNameLabel.setFont(new java.awt.Font("Dialog",1,10)); } } } { jMenuBar1 = new JMenuBar(); setJMenuBar(jMenuBar1); { jMenu3 = new JMenu(); jMenuBar1.add(jMenu3); jMenu3.setText("File"); { newFileMenuItem = new JMenuItem(); jMenu3.add(newFileMenuItem); newFileMenuItem.setText("New"); newFileMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // This is just a test right now to see that // stuff is changed. myRecipe = new Recipe(); attachRecipeData(); displayRecipe(); } }); } { openFileMenuItem = new JMenuItem(); jMenu3.add(openFileMenuItem); openFileMenuItem.setText("Open"); openFileMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // Show open dialog; this method does // not return until the dialog is closed int returnVal = fileChooser.showOpenDialog(jMenuBar1); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); System.out.print("Opening: " + file.getName() + ".\n"); ImportXml imp = new ImportXml(file.toString()); myRecipe = imp.handler.getRecipe(); myRecipe.calcMaltTotals(); myRecipe.calcHopsTotals(); myRecipe.mash.calcMashSchedule(); attachRecipeData(); displayRecipe(); // show true file name fileName = file.getName(); fileNameLabel.setText(fileName); } else { System.out.print("Open command cancelled by user.\n"); } } }); } { saveMenuItem = new JMenuItem(); jMenu3.add(saveMenuItem); saveMenuItem.setText("Save"); } { saveAsMenuItem = new JMenuItem(); jMenu3.add(saveAsMenuItem); saveAsMenuItem.setText("Save As ..."); saveAsMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (DEBUG){ // This is just a test right now to see that // stuff is changed. System.out.print(myRecipe.toXML()); } // Show save dialog; this method does // not return until the dialog is closed int returnVal = fileChooser.showSaveDialog(jMenuBar1); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); //This is where a real application would save the file. try { FileWriter out = new FileWriter(file); out.write(myRecipe.toXML()); out.close(); } catch (Exception e){ // TODO: handle io exception } } else { System.out.print("Save command cancelled by user.\n"); } } }); } { exportMenu = new JMenu(); jMenu3.add(exportMenu); exportMenu.setText("Export"); { exportHTMLmenu = new JMenuItem(); exportMenu.add(exportHTMLmenu); exportHTMLmenu.setText("HTML"); exportHTMLmenu.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // Show save dialog; this method does // not return until the dialog is closed fileChooser.setSelectedFile(new File(myRecipe.getName()+".html")); int returnVal = fileChooser.showSaveDialog(jMenuBar1); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); //This is where a real application would save the file. try { saveAsHTML(file); } catch (Exception e){ // TODO: handle io exception } } else { System.out.print("Save command cancelled by user.\n"); } } }); exportTextMenuItem = new JMenuItem(); exportMenu.add(exportTextMenuItem); exportTextMenuItem.setText("Text"); exportTextMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // Show save dialog; this method does // not return until the dialog is closed fileChooser.setSelectedFile(new File(myRecipe.getName()+".txt")); int returnVal = fileChooser.showSaveDialog(jMenuBar1); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); //This is where a real application would save the file. try { FileWriter out = new FileWriter(file); out.write(myRecipe.toText()); out.close(); } catch (Exception e){ // TODO: handle io exception } } else { System.out.print("Export text command cancelled by user.\n"); } } }); } } { jSeparator2 = new JSeparator(); jMenu3.add(jSeparator2); } { exitMenuItem = new JMenuItem(); jMenu3.add(exitMenuItem); exitMenuItem.setText("Exit"); exitMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // exit program System.exit(0); } }); } } { jMenu4 = new JMenu(); jMenuBar1.add(jMenu4); jMenu4.setText("Edit"); { final JFrame owner = this; editPrefsMenuItem = new JMenuItem(); jMenu4.add(editPrefsMenuItem); editPrefsMenuItem.setText("Preferences..."); editPrefsMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { PreferencesDialog d = new PreferencesDialog(owner, preferences); d.setVisible(true); } }); } { jSeparator1 = new JSeparator(); jMenu4.add(jSeparator1); } { deleteMenuItem = new JMenuItem(); jMenu4.add(deleteMenuItem); deleteMenuItem.setText("Delete"); deleteMenuItem.setEnabled(false); } } { mnuView = new JMenu(); jMenuBar1.add(mnuView); mnuView.setText("View"); { mashManagerMenuItem = new JMenuItem(); mnuView.add(mashManagerMenuItem); mashManagerMenuItem.setText("Mash Manager..."); mashManagerMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { mashMgr = new MashManager(myRecipe); mashMgr.setVisible(true); } }); } } { jMenu5 = new JMenu(); jMenuBar1.add(jMenu5); jMenu5.setText("Help"); { helpMenuItem = new JMenuItem(); jMenu5.add(helpMenuItem); helpMenuItem.setText("Help"); } { aboutMenuItem = new JMenuItem(); jMenu5.add(aboutMenuItem); aboutMenuItem.setText("About..."); final JFrame owner = this; aboutMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { aboutDlg = new AboutDialog(owner); aboutDlg.setVisible(true); } }); } } } } catch (Exception e) { e.printStackTrace(); } } |
|
String u = (String) cmbMaltUnitsModel.getSelectedItem(); | Fermentable f = (Fermentable) cmbMaltModel .getSelectedItem(); | public void actionPerformed(ActionEvent evt) { String u = (String) cmbMaltUnitsModel.getSelectedItem(); int i = tblMalt.getSelectedRow(); if (myRecipe != null && i != -1) { Fermentable f2 = myRecipe.getFermentable(i); f2.setUnitsFull(u); myRecipe.calcMaltTotals(); displayRecipe(); } } |
f2.setUnitsFull(u); myRecipe.calcMaltTotals(); displayRecipe(); | f2.setLov(f.getLov()); f2.setPppg(f.getPppg()); f2.setDescription(f.getDescription()); f2.setMashed(f.getMashed()); f2.setSteep(f.getSteep()); | public void actionPerformed(ActionEvent evt) { String u = (String) cmbMaltUnitsModel.getSelectedItem(); int i = tblMalt.getSelectedRow(); if (myRecipe != null && i != -1) { Fermentable f2 = myRecipe.getFermentable(i); f2.setUnitsFull(u); myRecipe.calcMaltTotals(); displayRecipe(); } } |
if (myRecipe != null) { Fermentable f = new Fermentable(myRecipe.getMaltUnits()); myRecipe.addMalt(f); tblMalt.updateUI(); | String u = (String) cmbMaltUnitsModel.getSelectedItem(); int i = tblMalt.getSelectedRow(); if (myRecipe != null && i != -1) { Fermentable f2 = myRecipe.getFermentable(i); f2.setUnitsFull(u); myRecipe.calcMaltTotals(); | public void actionPerformed(ActionEvent evt) { if (myRecipe != null) { Fermentable f = new Fermentable(myRecipe.getMaltUnits()); myRecipe.addMalt(f); tblMalt.updateUI(); displayRecipe(); } } |
int i = tblMalt.getSelectedRow(); myRecipe.delMalt(i); | Fermentable f = new Fermentable(myRecipe.getMaltUnits()); myRecipe.addMalt(f); | public void actionPerformed(ActionEvent evt) { if (myRecipe != null) { int i = tblMalt.getSelectedRow(); myRecipe.delMalt(i); tblMalt.updateUI(); displayRecipe(); } } |
String u = (String) cmbHopsUnitsModel.getSelectedItem(); | Hop h = (Hop) cmbHopsModel.getSelectedItem(); | public void actionPerformed(ActionEvent evt) { String u = (String) cmbHopsUnitsModel.getSelectedItem(); int i = tblHops.getSelectedRow(); if (myRecipe != null && i != -1) { Hop h = (Hop) myRecipe.getHop(i); h.setUnitsFull(u); myRecipe.calcHopsTotals(); // tblHops.updateUI(); displayRecipe(); } } |
Hop h = (Hop) myRecipe.getHop(i); h.setUnitsFull(u); myRecipe.calcHopsTotals(); displayRecipe(); | Hop h2 = (Hop) myRecipe.getHop(i); h2.setAlpha(h.getAlpha()); h2.setDescription(h.getDescription()); | public void actionPerformed(ActionEvent evt) { String u = (String) cmbHopsUnitsModel.getSelectedItem(); int i = tblHops.getSelectedRow(); if (myRecipe != null && i != -1) { Hop h = (Hop) myRecipe.getHop(i); h.setUnitsFull(u); myRecipe.calcHopsTotals(); // tblHops.updateUI(); displayRecipe(); } } |
if (myRecipe != null) { Hop h = new Hop(myRecipe.getHopUnits()); myRecipe.addHop(h); tblHops.updateUI(); | String u = (String) cmbHopsUnitsModel.getSelectedItem(); int i = tblHops.getSelectedRow(); if (myRecipe != null && i != -1) { Hop h = (Hop) myRecipe.getHop(i); h.setUnitsFull(u); myRecipe.calcHopsTotals(); | public void actionPerformed(ActionEvent evt) { if (myRecipe != null) { Hop h = new Hop(myRecipe.getHopUnits()); myRecipe.addHop(h); tblHops.updateUI(); displayRecipe(); } } |
} | public void actionPerformed(ActionEvent evt) { if (myRecipe != null) { Hop h = new Hop(myRecipe.getHopUnits()); myRecipe.addHop(h); tblHops.updateUI(); displayRecipe(); } } |
|
int i = tblHops.getSelectedRow(); myRecipe.delHop(i); | Hop h = new Hop(myRecipe.getHopUnits()); myRecipe.addHop(h); | public void actionPerformed(ActionEvent evt) { if (myRecipe != null) { int i = tblHops.getSelectedRow(); myRecipe.delHop(i); tblHops.updateUI(); displayRecipe(); } } |
myRecipe = new Recipe(); attachRecipeData(); displayRecipe(); } | if (myRecipe != null) { int i = tblHops.getSelectedRow(); myRecipe.delHop(i); tblHops.updateUI(); displayRecipe(); } } | public void actionPerformed(ActionEvent evt) { // This is just a test right now to see that // stuff is changed. myRecipe = new Recipe(); attachRecipeData(); displayRecipe(); } |
public void actionPerformed(ActionEvent evt) { int returnVal = fileChooser.showOpenDialog(jMenuBar1); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); System.out.print("Opening: " + file.getName() + ".\n"); ImportXml imp = new ImportXml(file.toString()); myRecipe = imp.handler.getRecipe(); myRecipe.calcMaltTotals(); myRecipe.calcHopsTotals(); myRecipe.mash.calcMashSchedule(); attachRecipeData(); displayRecipe(); fileName = file.getName(); fileNameLabel.setText(fileName); } else { System.out.print("Open command cancelled by user.\n"); } | public void actionPerformed(ActionEvent evt) { myRecipe = new Recipe(); attachRecipeData(); displayRecipe(); | public void actionPerformed(ActionEvent evt) { // Show open dialog; this method does // not return until the dialog is closed int returnVal = fileChooser.showOpenDialog(jMenuBar1); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); System.out.print("Opening: " + file.getName() + ".\n"); ImportXml imp = new ImportXml(file.toString()); myRecipe = imp.handler.getRecipe(); myRecipe.calcMaltTotals(); myRecipe.calcHopsTotals(); myRecipe.mash.calcMashSchedule(); attachRecipeData(); displayRecipe(); // show true file name fileName = file.getName(); fileNameLabel.setText(fileName); } else { System.out.print("Open command cancelled by user.\n"); } } |
public void actionPerformed(ActionEvent evt) { if (DEBUG){ System.out.print(myRecipe.toXML()); | public void actionPerformed(ActionEvent evt) { int returnVal = fileChooser.showOpenDialog(jMenuBar1); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); System.out.print("Opening: " + file.getName() + ".\n"); ImportXml imp = new ImportXml(file.toString()); myRecipe = imp.handler.getRecipe(); myRecipe.calcMaltTotals(); myRecipe.calcHopsTotals(); myRecipe.mash.calcMashSchedule(); attachRecipeData(); displayRecipe(); fileName = file.getName(); fileNameLabel.setText(fileName); } else { System.out.print("Open command cancelled by user.\n"); | public void actionPerformed(ActionEvent evt) { if (DEBUG){ // This is just a test right now to see that // stuff is changed. System.out.print(myRecipe.toXML()); } // Show save dialog; this method does // not return until the dialog is closed int returnVal = fileChooser.showSaveDialog(jMenuBar1); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); //This is where a real application would save the file. try { FileWriter out = new FileWriter(file); out.write(myRecipe.toXML()); out.close(); } catch (Exception e){ // TODO: handle io exception } } else { System.out.print("Save command cancelled by user.\n"); } } |
int returnVal = fileChooser.showSaveDialog(jMenuBar1); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); try { FileWriter out = new FileWriter(file); out.write(myRecipe.toXML()); out.close(); } catch (Exception e){ } } else { System.out.print("Save command cancelled by user.\n"); } | public void actionPerformed(ActionEvent evt) { if (DEBUG){ // This is just a test right now to see that // stuff is changed. System.out.print(myRecipe.toXML()); } // Show save dialog; this method does // not return until the dialog is closed int returnVal = fileChooser.showSaveDialog(jMenuBar1); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); //This is where a real application would save the file. try { FileWriter out = new FileWriter(file); out.write(myRecipe.toXML()); out.close(); } catch (Exception e){ // TODO: handle io exception } } else { System.out.print("Save command cancelled by user.\n"); } } |
|
public void actionPerformed(ActionEvent evt) { fileChooser.setSelectedFile(new File(myRecipe.getName()+".html")); int returnVal = fileChooser.showSaveDialog(jMenuBar1); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); try { saveAsHTML(file); } catch (Exception e){ } } else { System.out.print("Save command cancelled by user.\n"); } | public void actionPerformed(ActionEvent evt) { if (DEBUG){ System.out.print(myRecipe.toXML()); } int returnVal = fileChooser.showSaveDialog(jMenuBar1); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); try { FileWriter out = new FileWriter(file); out.write(myRecipe.toXML()); out.close(); } catch (Exception e){ } } else { System.out.print("Save command cancelled by user.\n"); } | public void actionPerformed(ActionEvent evt) { // Show save dialog; this method does // not return until the dialog is closed fileChooser.setSelectedFile(new File(myRecipe.getName()+".html")); int returnVal = fileChooser.showSaveDialog(jMenuBar1); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); //This is where a real application would save the file. try { saveAsHTML(file); } catch (Exception e){ // TODO: handle io exception } } else { System.out.print("Save command cancelled by user.\n"); } } |
fileChooser.setSelectedFile(new File(myRecipe.getName()+".txt")); | fileChooser.setSelectedFile(new File(myRecipe.getName()+".html")); | public void actionPerformed(ActionEvent evt) { // Show save dialog; this method does // not return until the dialog is closed fileChooser.setSelectedFile(new File(myRecipe.getName()+".txt")); int returnVal = fileChooser.showSaveDialog(jMenuBar1); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); //This is where a real application would save the file. try { FileWriter out = new FileWriter(file); out.write(myRecipe.toText()); out.close(); } catch (Exception e){ // TODO: handle io exception } } else { System.out.print("Export text command cancelled by user.\n"); } } |
FileWriter out = new FileWriter(file); out.write(myRecipe.toText()); out.close(); | saveAsHTML(file); | public void actionPerformed(ActionEvent evt) { // Show save dialog; this method does // not return until the dialog is closed fileChooser.setSelectedFile(new File(myRecipe.getName()+".txt")); int returnVal = fileChooser.showSaveDialog(jMenuBar1); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); //This is where a real application would save the file. try { FileWriter out = new FileWriter(file); out.write(myRecipe.toText()); out.close(); } catch (Exception e){ // TODO: handle io exception } } else { System.out.print("Export text command cancelled by user.\n"); } } |
System.out.print("Export text command cancelled by user.\n"); | System.out.print("Save command cancelled by user.\n"); | public void actionPerformed(ActionEvent evt) { // Show save dialog; this method does // not return until the dialog is closed fileChooser.setSelectedFile(new File(myRecipe.getName()+".txt")); int returnVal = fileChooser.showSaveDialog(jMenuBar1); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); //This is where a real application would save the file. try { FileWriter out = new FileWriter(file); out.write(myRecipe.toText()); out.close(); } catch (Exception e){ // TODO: handle io exception } } else { System.out.print("Export text command cancelled by user.\n"); } } |
System.exit(0); } | fileChooser.setSelectedFile(new File(myRecipe.getName()+".txt")); int returnVal = fileChooser.showSaveDialog(jMenuBar1); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); try { FileWriter out = new FileWriter(file); out.write(myRecipe.toText()); out.close(); } catch (Exception e){ } } else { System.out.print("Export text command cancelled by user.\n"); } } | public void actionPerformed(ActionEvent evt) { // exit program System.exit(0); } |
PreferencesDialog d = new PreferencesDialog(owner, preferences); d.setVisible(true); | System.exit(0); | public void actionPerformed(ActionEvent evt) { PreferencesDialog d = new PreferencesDialog(owner, preferences); d.setVisible(true); } |
public void actionPerformed(ActionEvent evt) { mashMgr = new MashManager(myRecipe); mashMgr.setVisible(true); | public void actionPerformed(ActionEvent evt) { PreferencesDialog d = new PreferencesDialog(owner, preferences); d.setVisible(true); | public void actionPerformed(ActionEvent evt) { mashMgr = new MashManager(myRecipe); mashMgr.setVisible(true); } |
public void actionPerformed(ActionEvent evt) { aboutDlg = new AboutDialog(owner); aboutDlg.setVisible(true); | public void actionPerformed(ActionEvent evt) { mashMgr = new MashManager(myRecipe); mashMgr.setVisible(true); | public void actionPerformed(ActionEvent evt) { aboutDlg = new AboutDialog(owner); aboutDlg.setVisible(true); } |
suite.addTest(new LogarithmTest("testLogarithm")); suite.addTest(new NaturalLogarithmTest("testNaturalLogarithm")); | public static Test suite() { TestSuite suite = new TestSuite("All JUnit Tests"); suite.addTest(new JEPTest("testParseExpression")); return suite; } |
|
public FissuresToWAV(SeismogramIterator iterator, int speedUp) { this.iterator = iterator; chunkSize = 36 + 2*iterator.getNumPoints(); | public FissuresToWAV(SeismogramContainer container, int speedUp) { this.container = container; this.speedUp = speedUp; | public FissuresToWAV(SeismogramIterator iterator, int speedUp) { this.iterator = iterator; chunkSize = 36 + 2*iterator.getNumPoints(); numChannels = 1; bitsPerSample = 16; blockAlign = numChannels * (bitsPerSample/8); subchunk2Size = iterator.getNumPoints() * blockAlign; setSpeedUp(speedUp); } |
subchunk2Size = iterator.getNumPoints() * blockAlign; setSpeedUp(speedUp); | public FissuresToWAV(SeismogramIterator iterator, int speedUp) { this.iterator = iterator; chunkSize = 36 + 2*iterator.getNumPoints(); numChannels = 1; bitsPerSample = 16; blockAlign = numChannels * (bitsPerSample/8); subchunk2Size = iterator.getNumPoints() * blockAlign; setSpeedUp(speedUp); } |
|
setInfo(); | public void play(){ ByteArrayOutputStream baos = new ByteArrayOutputStream(); DataOutputStream dos = new DataOutputStream(baos); try{ writeWAVData(dos); } catch(IOException e){ e.printStackTrace(); } if (clip != null) clip.close(); Clip clip = null; AudioFormat audioFormat = new AudioFormat(sampleRate, 16, 1, true, false); DataLine.Info info = new DataLine.Info(Clip.class, audioFormat); if (!AudioSystem.isLineSupported(info)) { System.out.println("Line not supported, apparently..."); } // Obtain and open the line. try { clip = (Clip) AudioSystem.getLine(info); byte[] data = baos.toByteArray(); ByteArrayInputStream bais = new ByteArrayInputStream(data); AudioInputStream ais = new AudioInputStream(bais, audioFormat, data.length); //clip.open(audioFormat, data, 0, 100); try{ clip.open(ais); clip.start(); } catch(IOException e){ e.printStackTrace(); } } catch (LineUnavailableException ex) { ex.printStackTrace(); } try{ baos.close(); dos.close(); } catch(IOException e){ e.printStackTrace(); } } |
|
sampleRate = calculateSampleRate(iterator.getSampling(), newSpeed); byteRate = sampleRate * blockAlign; | setInfo(); | public void setSpeedUp(int newSpeed){ speedUp = newSpeed; sampleRate = calculateSampleRate(iterator.getSampling(), newSpeed); byteRate = sampleRate * blockAlign; } |
setInfo(); | public void writeWAV(DataOutput out) throws IOException { writeChunkData(out); writeWAVData(out); } |
|
SeismogramIterator iterator = container.getIterator(); | private void writeWAVData(DataOutput out) throws IOException{ //calculate maximum amplification factor to avoid either //clipping or dead quiet int amplification = (int)(24000.0/iterator.minMaxMean()[1]); while (iterator.hasNext()){ try{ QuantityImpl next = (QuantityImpl)iterator.next(); writeLittleEndian(out, (short)(amplification * next.getValue())); } catch(NullPointerException e){ writeLittleEndian(out, (short)0); } catch(ArrayIndexOutOfBoundsException e){ writeLittleEndian(out, (short)0); } } } |
|
else if (currentList.equalsIgnoreCase("yeast")){ | else if (currentList.equalsIgnoreCase("yeasts")){ | public void characters(char buf[], int offset, int len) throws SAXException { String s = new String(buf, offset, len); // we're inside a style: if (!s.trim().equals("")) { if (currentElement.equalsIgnoreCase("notes")) descrBuf += s; if (currentList.equalsIgnoreCase("hops")){ if (currentElement.equalsIgnoreCase("name")) h.setName(s.trim()); if (currentElement.equalsIgnoreCase("amount")) h.setAmountAs(Double.parseDouble(s.trim()), "kg"); if (currentElement.equalsIgnoreCase("form")) h.setType(s.trim()); if (currentElement.equalsIgnoreCase("hsi")) h.setStorage(Double.parseDouble(s.trim())); if (currentElement.equalsIgnoreCase("alpha")) h.setAlpha(Double.parseDouble(s.trim())); if (currentElement.equalsIgnoreCase("time")) h.setMinutes(new Double(s.trim()).intValue()); if (currentElement.equalsIgnoreCase("use")){ if (s.trim().equalsIgnoreCase("boil") || s.trim().equalsIgnoreCase("aroma")) h.setAdd("Boil"); if (s.trim().equalsIgnoreCase("dry hop")) h.setAdd("Dry"); if (s.trim().equalsIgnoreCase("first wort")) h.setAdd("FWH"); } } else if (currentList.equalsIgnoreCase("fermentables")){ if (currentElement.equalsIgnoreCase("name")) f.setName(s.trim()); if (currentElement.equalsIgnoreCase("amount")) f.setAmountAs(Double.parseDouble(s.trim()), "kg"); if (currentElement.equalsIgnoreCase("potential")) f.setPppg(Double.parseDouble(s.trim())); if (currentElement.equalsIgnoreCase("color")) f.setLov(Double.parseDouble(s.trim())); if (currentElement.equalsIgnoreCase("RECOMMEND_MASH")) f.setMashed(s.trim().equalsIgnoreCase("true")); } else if (currentList.equalsIgnoreCase("mash")){ if (currentElement.equalsIgnoreCase("type")) myRecipe.mash.setStepMethod(myRecipe.mash.getStepSize()-1, s.trim()); if (currentElement.equalsIgnoreCase("STEP_TIME")) myRecipe.mash.setStepMin(myRecipe.mash.getStepSize()-1, new Double(s.trim()).intValue()); if (currentElement.equalsIgnoreCase("STEP_TEMP")) myRecipe.mash.setStepStartTemp(myRecipe.mash.getStepSize()-1, Double.parseDouble(s.trim())); if (currentElement.equalsIgnoreCase("END_TEMP")) myRecipe.mash.setStepEndTemp(myRecipe.mash.getStepSize()-1, Double.parseDouble(s.trim())); } else if (currentList.equalsIgnoreCase("miscs")){ if (currentElement.equalsIgnoreCase("name")) m.setName(s.trim()); if (currentElement.equalsIgnoreCase("amount")) m.setAmountAs(Double.parseDouble(s.trim()), "kg"); if (currentElement.equalsIgnoreCase("use")) m.setStage(s.trim()); if (currentElement.equalsIgnoreCase("time")) m.setTime(new Double(s.trim()).intValue()); } else if (currentList.equalsIgnoreCase("yeast")){ if (currentElement.equalsIgnoreCase("name")) myRecipe.setYeastName(s.trim()); } else if (currentList.equalsIgnoreCase("style")){ if (currentElement.equalsIgnoreCase("name")) myRecipe.setStyle(s.trim()); } else if (currentList.equalsIgnoreCase("recipe")){ if (currentElement.equalsIgnoreCase("name")) myRecipe.setName(s.trim()); if (currentElement.equalsIgnoreCase("brewer")) myRecipe.setBrewer(s.trim()); if (currentElement.equalsIgnoreCase("BATCH_SIZE")){ myRecipe.setPostBoil(Double.parseDouble(s.trim())); myRecipe.setVolUnits("l"); } if (currentElement.equalsIgnoreCase("BOIL_TIME")) myRecipe.setBoilMinutes(new Double(s.trim()).intValue()); if (currentElement.equalsIgnoreCase("EFFICIENCY")) myRecipe.setEfficiency(Double.parseDouble(s.trim())); if (currentElement.equalsIgnoreCase("EFFICIENCY")) myRecipe.setEfficiency(Double.parseDouble(s.trim())); if (currentElement.equalsIgnoreCase("IBU_METHOD")) myRecipe.setIBUMethod(s.trim()); } } } |
if (currentList.equalsIgnoreCase("yeast")) | if (currentList.equalsIgnoreCase("yeasts")) | public void endElement(String namespaceURI, String sName, // simple name String qName // qualified name ) throws SAXException { if (qName.equalsIgnoreCase("recipe")){ newRecipe = false; numRecipes ++; recipes.add(myRecipe); } if (qName.equalsIgnoreCase("hops") || qName.equalsIgnoreCase("fermentables") || qName.equalsIgnoreCase("miscs") || qName.equalsIgnoreCase("yeasts") || qName.equalsIgnoreCase("waters") || qName.equalsIgnoreCase("style") || qName.equalsIgnoreCase("equipment") || qName.equalsIgnoreCase("mash")) { currentList = "recipe"; } if (qName.equalsIgnoreCase("hop")){ myRecipe.addHop(h); } if (qName.equalsIgnoreCase("fermentable")){ myRecipe.addMalt(f); } if (qName.equalsIgnoreCase("misc")){ myRecipe.addMisc(m); } if (qName.equalsIgnoreCase("notes")){ if (currentList.equalsIgnoreCase("hops")) h.setDescription(descrBuf); if (currentList.equalsIgnoreCase("fermentables")) f.setDescription(descrBuf); if (currentList.equalsIgnoreCase("miscs")) m.setDescription(descrBuf); if (currentList.equalsIgnoreCase("yeast")) myRecipe.getYeastObj().setDescription(descrBuf); } } |
myContainer.setLayout(myLayout); attach(myBrewerLabel.getWidget(), null, 0, 0, 0); attach(myBrewer.getWidget(), myBrewerLabel.getWidget(), 200, 14, 5); attach(myEfficiencyLabel.getWidget(), myBrewer.getWidget(), 0, 0, 10); attach(myEfficiency.getWidget(), myEfficiencyLabel.getWidget(), 25, 14, 5); attach(myAlcoholLabel.getWidget(), myEfficiency.getWidget(), 0, 0, 10); attach(myAlcohol.getWidget(), myAlcoholLabel.getWidget(), 25, 14, 5); attach(myAlcoholPostfix.getWidget(), myAlcohol.getWidget(), 0, 0, 5); | myContainer.setLayout(myLayout); | public void init() { myBrewerLabel = new SWTTextOutput(); myBrewerLabel.init(myContainer); myBrewer = new SWTTextInput(myController); myBrewer.init(myContainer); myEfficiencyLabel = new SWTTextOutput(); myEfficiencyLabel.init(myContainer); myEfficiency = new SWTNumberInput(myController); myEfficiency.init(myContainer); myAlcoholLabel = new SWTTextOutput(); myAlcoholLabel.init(myContainer); myAlcohol = new SWTTextOutput(); myAlcohol.init(myContainer); myAlcoholPostfix = new SWTTextOutput(); myAlcoholPostfix.init(myContainer); myLayout = new FormLayout(); myLayout.marginHeight = 3; myLayout.marginWidth = 3; myContainer.setLayout(myLayout); attach(myBrewerLabel.getWidget(), null, 0, 0, 0); attach(myBrewer.getWidget(), myBrewerLabel.getWidget(), 200, 14, 5); attach(myEfficiencyLabel.getWidget(), myBrewer.getWidget(), 0, 0, 10); attach(myEfficiency.getWidget(), myEfficiencyLabel.getWidget(), 25, 14, 5); attach(myAlcoholLabel.getWidget(), myEfficiency.getWidget(), 0, 0, 10); attach(myAlcohol.getWidget(), myAlcoholLabel.getWidget(), 25, 14, 5); attach(myAlcoholPostfix.getWidget(), myAlcohol.getWidget(), 0, 0, 5); } |
attach(myBrewerLabel.getWidget(), null, 0, 0, 0); attach(myBrewer.getWidget(), myBrewerLabel.getWidget(), 200, 14, 5); attach(myEfficiencyLabel.getWidget(), myBrewer.getWidget(), 0, 0, 10); attach(myEfficiency.getWidget(), myEfficiencyLabel.getWidget(), 25, 14, 5); attach(myAlcoholLabel.getWidget(), myEfficiency.getWidget(), 0, 0, 10); attach(myAlcohol.getWidget(), myAlcoholLabel.getWidget(), 25, 14, 5); attach(myAlcoholPostfix.getWidget(), myAlcohol.getWidget(), 0, 0, 5); | public void layout() { myContainer.layout(); myContainer.pack(); } |
|
Node simp = mjep.simplify(diff); return simp; | return diff; | public Object visitDiff(ASTFunNode node, Object data) throws ParseException { MatrixNodeI children[] = visitChildrenAsArray(node,data); if(children.length != 2) throw new ParseException("Diff opperator should have two children, it has "+children.length); // TODO need to handle diff(x,[x,y]) if(!(children[1] instanceof ASTMVarNode)) throw new ParseException("rhs of diff opperator should be a variable."); ASTMVarNode varNode = (ASTMVarNode) children[1]; Node diff = mjep.differentiate(children[0],varNode.getName()); Node simp = mjep.simplify(diff); return simp; } |
var.setEquation(mjep.deepCopy(children[1])); | Node copy =mjep.deepCopy(children[1]); Node simp = mjep.simplify(copy); var.setEquation(simp); | public Object visitOp(ASTFunNode node, Object data) throws ParseException { PostfixMathCommandI pfmc=node.getPFMC();// if(pfmc instanceof SpecialPreProcessI)// {// SpecialPreProcessI spp = (SpecialPreProcessI) node.getPFMC();// return spp.preprocess(node,this,mjep);// } MatrixNodeI children[] = visitChildrenAsArray(node,data); if(pfmc instanceof Assign) { if(node.jjtGetNumChildren()!=2) throw new ParseException("Operator "+node.getOperator().getName()+" must have two elements, it has "+children.length); Dimensions rhsDim = children[1].getDim(); MatrixVariable var = (MatrixVariable) ((ASTVarNode) children[0]).getVar(); var.setDimensions(rhsDim); var.setEquation(mjep.deepCopy(children[1])); return (ASTMFunNode) nf.buildOperatorNode(node.getOperator(),children,rhsDim); } else if(pfmc instanceof Power) { if(node.jjtGetNumChildren()!=2) throw new ParseException("Operator "+node.getOperator().getName()+" must have two elements, it has "+children.length); Dimensions lhsDim = children[0].getDim(); Dimensions rhsDim = children[1].getDim(); if(rhsDim.equals(Dimensions.ONE)) { Dimensions dim = lhsDim; return (ASTMFunNode) nf.buildOperatorNode( node.getOperator(),children,dim); } else { Operator op = opSet.getCross(); PostfixMathCommandI pfmc2 = op.getPFMC(); BinaryOperatorI bin = (BinaryOperatorI) pfmc2; Dimensions dim = bin.calcDim(lhsDim,rhsDim); return (ASTMFunNode) nf.buildOperatorNode(op,children,dim); } } else if(pfmc instanceof List) { // TODO what if we have x=[1,2]; y = [x,x]; or z=[[1,2],x]; // first check if all arguments are TENSORS boolean flag=true; for(int i=0;i<children.length;++i) { if(children[i] instanceof ASTMFunNode) { if(((ASTMFunNode) children[i]).getOperator() != opSet.getMTensorFun()) { flag=false; break; } } else flag=false; break; } if(flag) { ASTMFunNode opNode1 = (ASTMFunNode) children[0]; Dimensions dim = Dimensions.valueOf(children.length,opNode1.getDim()); ASTMFunNode res = (ASTMFunNode) nf.buildUnfinishedOperatorNode(opSet.getMTensorFun()); int k=0; res.setDim(dim); res.jjtOpen(); for(int i=0;i<children.length;++i) { ASTMFunNode opNode = (ASTMFunNode) children[i]; for(int j=0;j<opNode.jjtGetNumChildren();++j) { Node child = opNode.jjtGetChild(j); res.jjtAddChild(child,k++); child.jjtSetParent(res); } } res.jjtClose(); return res; } else { MatrixNodeI node1 = (MatrixNodeI) children[0]; Dimensions dim = Dimensions.valueOf(children.length,node1.getDim()); ASTMFunNode res = (ASTMFunNode) nf.buildOperatorNode(opSet.getMTensorFun(),children,dim); return res; } } else if(pfmc instanceof BinaryOperatorI) { if(node.jjtGetNumChildren()!=2) throw new ParseException("Operator "+node.getOperator().getName()+" must have two elements, it has "+children.length); BinaryOperatorI bin = (BinaryOperatorI) pfmc; Dimensions dim = bin.calcDim(children[0].getDim(),children[1].getDim()); return (ASTMFunNode) nf.buildOperatorNode(node.getOperator(),children,dim); } else if(pfmc instanceof UnaryOperatorI) { if(children.length!=1) throw new ParseException("Operator "+node.getOperator().getName()+" must have one elements, it has "+children.length); UnaryOperatorI uni = (UnaryOperatorI) pfmc; Dimensions dim = uni.calcDim(children[0].getDim()); return (ASTMFunNode) nf.buildOperatorNode(node.getOperator(),children,dim); } else if(pfmc instanceof NaryOperatorI) { Dimensions dims[] = new Dimensions[children.length]; for(int i=0;i<children.length;++i) dims[i]=((MatrixNodeI) children[i]).getDim(); NaryOperatorI uni = (NaryOperatorI) pfmc; Dimensions dim = uni.calcDim(dims); return (ASTMFunNode) nf.buildOperatorNode(node.getOperator(),children,dim); } else { //throw new ParseException("Operator must be unary or binary. It is "+op); Dimensions dim = Dimensions.ONE; return (ASTMFunNode) nf.buildOperatorNode(node.getOperator(),children,dim); } } |
if(((ASTMFunNode) children[i]).getOperator() != opSet.getMTensorFun()) | if(((ASTMFunNode) children[i]).getOperator() != opSet.getMList()) | public Object visitOp(ASTFunNode node, Object data) throws ParseException { PostfixMathCommandI pfmc=node.getPFMC();// if(pfmc instanceof SpecialPreProcessI)// {// SpecialPreProcessI spp = (SpecialPreProcessI) node.getPFMC();// return spp.preprocess(node,this,mjep);// } MatrixNodeI children[] = visitChildrenAsArray(node,data); if(pfmc instanceof Assign) { if(node.jjtGetNumChildren()!=2) throw new ParseException("Operator "+node.getOperator().getName()+" must have two elements, it has "+children.length); Dimensions rhsDim = children[1].getDim(); MatrixVariable var = (MatrixVariable) ((ASTVarNode) children[0]).getVar(); var.setDimensions(rhsDim); var.setEquation(mjep.deepCopy(children[1])); return (ASTMFunNode) nf.buildOperatorNode(node.getOperator(),children,rhsDim); } else if(pfmc instanceof Power) { if(node.jjtGetNumChildren()!=2) throw new ParseException("Operator "+node.getOperator().getName()+" must have two elements, it has "+children.length); Dimensions lhsDim = children[0].getDim(); Dimensions rhsDim = children[1].getDim(); if(rhsDim.equals(Dimensions.ONE)) { Dimensions dim = lhsDim; return (ASTMFunNode) nf.buildOperatorNode( node.getOperator(),children,dim); } else { Operator op = opSet.getCross(); PostfixMathCommandI pfmc2 = op.getPFMC(); BinaryOperatorI bin = (BinaryOperatorI) pfmc2; Dimensions dim = bin.calcDim(lhsDim,rhsDim); return (ASTMFunNode) nf.buildOperatorNode(op,children,dim); } } else if(pfmc instanceof List) { // TODO what if we have x=[1,2]; y = [x,x]; or z=[[1,2],x]; // first check if all arguments are TENSORS boolean flag=true; for(int i=0;i<children.length;++i) { if(children[i] instanceof ASTMFunNode) { if(((ASTMFunNode) children[i]).getOperator() != opSet.getMTensorFun()) { flag=false; break; } } else flag=false; break; } if(flag) { ASTMFunNode opNode1 = (ASTMFunNode) children[0]; Dimensions dim = Dimensions.valueOf(children.length,opNode1.getDim()); ASTMFunNode res = (ASTMFunNode) nf.buildUnfinishedOperatorNode(opSet.getMTensorFun()); int k=0; res.setDim(dim); res.jjtOpen(); for(int i=0;i<children.length;++i) { ASTMFunNode opNode = (ASTMFunNode) children[i]; for(int j=0;j<opNode.jjtGetNumChildren();++j) { Node child = opNode.jjtGetChild(j); res.jjtAddChild(child,k++); child.jjtSetParent(res); } } res.jjtClose(); return res; } else { MatrixNodeI node1 = (MatrixNodeI) children[0]; Dimensions dim = Dimensions.valueOf(children.length,node1.getDim()); ASTMFunNode res = (ASTMFunNode) nf.buildOperatorNode(opSet.getMTensorFun(),children,dim); return res; } } else if(pfmc instanceof BinaryOperatorI) { if(node.jjtGetNumChildren()!=2) throw new ParseException("Operator "+node.getOperator().getName()+" must have two elements, it has "+children.length); BinaryOperatorI bin = (BinaryOperatorI) pfmc; Dimensions dim = bin.calcDim(children[0].getDim(),children[1].getDim()); return (ASTMFunNode) nf.buildOperatorNode(node.getOperator(),children,dim); } else if(pfmc instanceof UnaryOperatorI) { if(children.length!=1) throw new ParseException("Operator "+node.getOperator().getName()+" must have one elements, it has "+children.length); UnaryOperatorI uni = (UnaryOperatorI) pfmc; Dimensions dim = uni.calcDim(children[0].getDim()); return (ASTMFunNode) nf.buildOperatorNode(node.getOperator(),children,dim); } else if(pfmc instanceof NaryOperatorI) { Dimensions dims[] = new Dimensions[children.length]; for(int i=0;i<children.length;++i) dims[i]=((MatrixNodeI) children[i]).getDim(); NaryOperatorI uni = (NaryOperatorI) pfmc; Dimensions dim = uni.calcDim(dims); return (ASTMFunNode) nf.buildOperatorNode(node.getOperator(),children,dim); } else { //throw new ParseException("Operator must be unary or binary. It is "+op); Dimensions dim = Dimensions.ONE; return (ASTMFunNode) nf.buildOperatorNode(node.getOperator(),children,dim); } } |
ASTMFunNode res = (ASTMFunNode) nf.buildUnfinishedOperatorNode(opSet.getMTensorFun()); | ASTMFunNode res = (ASTMFunNode) nf.buildUnfinishedOperatorNode(opSet.getMList()); | public Object visitOp(ASTFunNode node, Object data) throws ParseException { PostfixMathCommandI pfmc=node.getPFMC();// if(pfmc instanceof SpecialPreProcessI)// {// SpecialPreProcessI spp = (SpecialPreProcessI) node.getPFMC();// return spp.preprocess(node,this,mjep);// } MatrixNodeI children[] = visitChildrenAsArray(node,data); if(pfmc instanceof Assign) { if(node.jjtGetNumChildren()!=2) throw new ParseException("Operator "+node.getOperator().getName()+" must have two elements, it has "+children.length); Dimensions rhsDim = children[1].getDim(); MatrixVariable var = (MatrixVariable) ((ASTVarNode) children[0]).getVar(); var.setDimensions(rhsDim); var.setEquation(mjep.deepCopy(children[1])); return (ASTMFunNode) nf.buildOperatorNode(node.getOperator(),children,rhsDim); } else if(pfmc instanceof Power) { if(node.jjtGetNumChildren()!=2) throw new ParseException("Operator "+node.getOperator().getName()+" must have two elements, it has "+children.length); Dimensions lhsDim = children[0].getDim(); Dimensions rhsDim = children[1].getDim(); if(rhsDim.equals(Dimensions.ONE)) { Dimensions dim = lhsDim; return (ASTMFunNode) nf.buildOperatorNode( node.getOperator(),children,dim); } else { Operator op = opSet.getCross(); PostfixMathCommandI pfmc2 = op.getPFMC(); BinaryOperatorI bin = (BinaryOperatorI) pfmc2; Dimensions dim = bin.calcDim(lhsDim,rhsDim); return (ASTMFunNode) nf.buildOperatorNode(op,children,dim); } } else if(pfmc instanceof List) { // TODO what if we have x=[1,2]; y = [x,x]; or z=[[1,2],x]; // first check if all arguments are TENSORS boolean flag=true; for(int i=0;i<children.length;++i) { if(children[i] instanceof ASTMFunNode) { if(((ASTMFunNode) children[i]).getOperator() != opSet.getMTensorFun()) { flag=false; break; } } else flag=false; break; } if(flag) { ASTMFunNode opNode1 = (ASTMFunNode) children[0]; Dimensions dim = Dimensions.valueOf(children.length,opNode1.getDim()); ASTMFunNode res = (ASTMFunNode) nf.buildUnfinishedOperatorNode(opSet.getMTensorFun()); int k=0; res.setDim(dim); res.jjtOpen(); for(int i=0;i<children.length;++i) { ASTMFunNode opNode = (ASTMFunNode) children[i]; for(int j=0;j<opNode.jjtGetNumChildren();++j) { Node child = opNode.jjtGetChild(j); res.jjtAddChild(child,k++); child.jjtSetParent(res); } } res.jjtClose(); return res; } else { MatrixNodeI node1 = (MatrixNodeI) children[0]; Dimensions dim = Dimensions.valueOf(children.length,node1.getDim()); ASTMFunNode res = (ASTMFunNode) nf.buildOperatorNode(opSet.getMTensorFun(),children,dim); return res; } } else if(pfmc instanceof BinaryOperatorI) { if(node.jjtGetNumChildren()!=2) throw new ParseException("Operator "+node.getOperator().getName()+" must have two elements, it has "+children.length); BinaryOperatorI bin = (BinaryOperatorI) pfmc; Dimensions dim = bin.calcDim(children[0].getDim(),children[1].getDim()); return (ASTMFunNode) nf.buildOperatorNode(node.getOperator(),children,dim); } else if(pfmc instanceof UnaryOperatorI) { if(children.length!=1) throw new ParseException("Operator "+node.getOperator().getName()+" must have one elements, it has "+children.length); UnaryOperatorI uni = (UnaryOperatorI) pfmc; Dimensions dim = uni.calcDim(children[0].getDim()); return (ASTMFunNode) nf.buildOperatorNode(node.getOperator(),children,dim); } else if(pfmc instanceof NaryOperatorI) { Dimensions dims[] = new Dimensions[children.length]; for(int i=0;i<children.length;++i) dims[i]=((MatrixNodeI) children[i]).getDim(); NaryOperatorI uni = (NaryOperatorI) pfmc; Dimensions dim = uni.calcDim(dims); return (ASTMFunNode) nf.buildOperatorNode(node.getOperator(),children,dim); } else { //throw new ParseException("Operator must be unary or binary. It is "+op); Dimensions dim = Dimensions.ONE; return (ASTMFunNode) nf.buildOperatorNode(node.getOperator(),children,dim); } } |
ASTMFunNode res = (ASTMFunNode) nf.buildOperatorNode(opSet.getMTensorFun(),children,dim); | ASTMFunNode res = (ASTMFunNode) nf.buildOperatorNode(opSet.getMList(),children,dim); | public Object visitOp(ASTFunNode node, Object data) throws ParseException { PostfixMathCommandI pfmc=node.getPFMC();// if(pfmc instanceof SpecialPreProcessI)// {// SpecialPreProcessI spp = (SpecialPreProcessI) node.getPFMC();// return spp.preprocess(node,this,mjep);// } MatrixNodeI children[] = visitChildrenAsArray(node,data); if(pfmc instanceof Assign) { if(node.jjtGetNumChildren()!=2) throw new ParseException("Operator "+node.getOperator().getName()+" must have two elements, it has "+children.length); Dimensions rhsDim = children[1].getDim(); MatrixVariable var = (MatrixVariable) ((ASTVarNode) children[0]).getVar(); var.setDimensions(rhsDim); var.setEquation(mjep.deepCopy(children[1])); return (ASTMFunNode) nf.buildOperatorNode(node.getOperator(),children,rhsDim); } else if(pfmc instanceof Power) { if(node.jjtGetNumChildren()!=2) throw new ParseException("Operator "+node.getOperator().getName()+" must have two elements, it has "+children.length); Dimensions lhsDim = children[0].getDim(); Dimensions rhsDim = children[1].getDim(); if(rhsDim.equals(Dimensions.ONE)) { Dimensions dim = lhsDim; return (ASTMFunNode) nf.buildOperatorNode( node.getOperator(),children,dim); } else { Operator op = opSet.getCross(); PostfixMathCommandI pfmc2 = op.getPFMC(); BinaryOperatorI bin = (BinaryOperatorI) pfmc2; Dimensions dim = bin.calcDim(lhsDim,rhsDim); return (ASTMFunNode) nf.buildOperatorNode(op,children,dim); } } else if(pfmc instanceof List) { // TODO what if we have x=[1,2]; y = [x,x]; or z=[[1,2],x]; // first check if all arguments are TENSORS boolean flag=true; for(int i=0;i<children.length;++i) { if(children[i] instanceof ASTMFunNode) { if(((ASTMFunNode) children[i]).getOperator() != opSet.getMTensorFun()) { flag=false; break; } } else flag=false; break; } if(flag) { ASTMFunNode opNode1 = (ASTMFunNode) children[0]; Dimensions dim = Dimensions.valueOf(children.length,opNode1.getDim()); ASTMFunNode res = (ASTMFunNode) nf.buildUnfinishedOperatorNode(opSet.getMTensorFun()); int k=0; res.setDim(dim); res.jjtOpen(); for(int i=0;i<children.length;++i) { ASTMFunNode opNode = (ASTMFunNode) children[i]; for(int j=0;j<opNode.jjtGetNumChildren();++j) { Node child = opNode.jjtGetChild(j); res.jjtAddChild(child,k++); child.jjtSetParent(res); } } res.jjtClose(); return res; } else { MatrixNodeI node1 = (MatrixNodeI) children[0]; Dimensions dim = Dimensions.valueOf(children.length,node1.getDim()); ASTMFunNode res = (ASTMFunNode) nf.buildOperatorNode(opSet.getMTensorFun(),children,dim); return res; } } else if(pfmc instanceof BinaryOperatorI) { if(node.jjtGetNumChildren()!=2) throw new ParseException("Operator "+node.getOperator().getName()+" must have two elements, it has "+children.length); BinaryOperatorI bin = (BinaryOperatorI) pfmc; Dimensions dim = bin.calcDim(children[0].getDim(),children[1].getDim()); return (ASTMFunNode) nf.buildOperatorNode(node.getOperator(),children,dim); } else if(pfmc instanceof UnaryOperatorI) { if(children.length!=1) throw new ParseException("Operator "+node.getOperator().getName()+" must have one elements, it has "+children.length); UnaryOperatorI uni = (UnaryOperatorI) pfmc; Dimensions dim = uni.calcDim(children[0].getDim()); return (ASTMFunNode) nf.buildOperatorNode(node.getOperator(),children,dim); } else if(pfmc instanceof NaryOperatorI) { Dimensions dims[] = new Dimensions[children.length]; for(int i=0;i<children.length;++i) dims[i]=((MatrixNodeI) children[i]).getDim(); NaryOperatorI uni = (NaryOperatorI) pfmc; Dimensions dim = uni.calcDim(dims); return (ASTMFunNode) nf.buildOperatorNode(node.getOperator(),children,dim); } else { //throw new ParseException("Operator must be unary or binary. It is "+op); Dimensions dim = Dimensions.ONE; return (ASTMFunNode) nf.buildOperatorNode(node.getOperator(),children,dim); } } |
openIpAddressSet = new HashSet(); | private ChatManager() { } |
|
if ( alternateLocations != null && alternateLocations.length > DROP_PACKAGE_ALT_LOCATION_LIMIT ) { throw new InvalidMessageException( "Number of query response record alt-locs exceed the acceptable maximum: " + alternateLocations.length + "/" + DROP_PACKAGE_ALT_LOCATION_LIMIT ); } | private void parseExtensionArea(byte[] extensionArea) { try { PushbackInputStream inStream = new PushbackInputStream( new ByteArrayInputStream( extensionArea ) ); byte b; StringBuffer buffer = new StringBuffer(); GGEPBlock[] ggepBlocks = null; GGEPBlock ggepBlock = null; while ( true ) { b = (byte)inStream.read(); if ( b == -1 ) { evaluateExtensionToken( buffer.toString() ); break; } else if ( b == GGEPBlock.MAGIC_NUMBER && buffer.length() == 0 ) { inStream.unread( b ); try { ggepBlocks = GGEPBlock.parseGGEPBlocks( inStream ); ggepBlock = GGEPBlock.mergeGGEPBlocks(ggepBlocks); } catch ( InvalidGGEPBlockException exp ) {// try to continue even though parsing of message might now be completly screwed! NLogger.error( NLoggerNames.MESSAGE_ENCODE_DECODE, exp, exp ); } continue; } else if ( b == 0x1c ) {// evaluate buffer and check for 3c evaluateExtensionToken( buffer.toString() ); buffer.setLength(0); continue; } buffer.append( (char)b ); } if ( ggepBlocks != null ) { alternateLocations = GGEPExtension.parseAltExtensionData( ggepBlocks ); byte[] pathInfoArr = GGEPBlock.getExtensionDataInBlocks( ggepBlocks, GGEPBlock.PATH_INFO_HEADER_ID ); if ( pathInfoArr != null ) { pathInfo = new String( pathInfoArr ); } creationTime = ggepBlock.getLongExtensionData( GGEPBlock.CREATION_TIME_HEADER_ID, -1 ) * 1000; } } catch ( IOException exp ) {// should never happen!! NLogger.error( NLoggerNames.MESSAGE_ENCODE_DECODE, exp, exp ); } } |
|
if(File.separatorChar=='\\') | if(onWindows) | public boolean perform(Build build, Launcher launcher, BuildListener listener) { Project proj = build.getProject(); String cmd; String execName; if(File.separatorChar=='\\') execName = "ant.bat"; else execName = "ant"; AntInstallation ai = getAnt(); if(ai==null) cmd = execName+' '+targets; else { File exec = ai.getExecutable(); if(!ai.getExists()) { listener.fatalError(exec+" doesn't exist"); return false; } cmd = exec.getPath()+' '+targets; } Map<String,String> env = build.getEnvVars(); if(ai!=null) env.put("ANT_HOME",ai.getAntHome()); try { int r = launcher.launch(cmd,env,listener.getLogger(),proj.getModuleRoot()).join(); return r==0; } catch (IOException e) { Util.displayIOException(e,listener); e.printStackTrace( listener.fatalError("command execution failed") ); return false; } } |
if(onWindows) { cmd = "cmd.exe /C "+cmd+" && exit %%ERRORLEVEL%%"; } | public boolean perform(Build build, Launcher launcher, BuildListener listener) { Project proj = build.getProject(); String cmd; String execName; if(File.separatorChar=='\\') execName = "ant.bat"; else execName = "ant"; AntInstallation ai = getAnt(); if(ai==null) cmd = execName+' '+targets; else { File exec = ai.getExecutable(); if(!ai.getExists()) { listener.fatalError(exec+" doesn't exist"); return false; } cmd = exec.getPath()+' '+targets; } Map<String,String> env = build.getEnvVars(); if(ai!=null) env.put("ANT_HOME",ai.getAntHome()); try { int r = launcher.launch(cmd,env,listener.getLogger(),proj.getModuleRoot()).join(); return r==0; } catch (IOException e) { Util.displayIOException(e,listener); e.printStackTrace( listener.fatalError("command execution failed") ); return false; } } |
|
else if(param1 instanceof Matrix && param2 instanceof Matrix) return mul((Matrix) param1,(Matrix) param2); | public Object mul(Object param1, Object param2) throws ParseException { // TODO tensor mult? if(param1 instanceof Matrix && param2 instanceof MVector) return mul((Matrix) param1,(MVector) param2); else if(param1 instanceof MVector && param2 instanceof Matrix) return mul((MVector) param1,(Matrix) param2); else if(param1 instanceof MVector && param2 instanceof MVector) return mul((MVector) param1,(MVector) param2); else if(param1 instanceof MVector) return mul((MVector) param1,param2); else if(param2 instanceof MVector) return mul(param1,(MVector) param2); else if(param1 instanceof Matrix) return mul((Matrix) param1,param2); else if(param2 instanceof Matrix) return mul(param1,(Matrix) param2); else return super.mul(param1,param2); } |
|
if (param instanceof Number) | if (param instanceof Complex) { return ((Complex)param).atan(); } else if (param instanceof Number) | public Object atan(Object param) throws ParseException { if (param instanceof Number) { return new Double(Math.atan(((Number)param).doubleValue())); } else if (param instanceof Complex) { return ((Complex)param).atan(); } throw new ParseException("Invalid parameter type"); } |
} else if (param instanceof Complex) { return ((Complex)param).atan(); | public Object atan(Object param) throws ParseException { if (param instanceof Number) { return new Double(Math.atan(((Number)param).doubleValue())); } else if (param instanceof Complex) { return ((Complex)param).atan(); } throw new ParseException("Invalid parameter type"); } |
|
Map<BuildStepDescriptor,BuildStep> m = new HashMap<BuildStepDescriptor,BuildStep>(); | Map<BuildStepDescriptor,BuildStep> m = new LinkedHashMap<BuildStepDescriptor,BuildStep>(); | public synchronized Map<BuildStepDescriptor,BuildStep> getBuilders() { Map<BuildStepDescriptor,BuildStep> m = new HashMap<BuildStepDescriptor,BuildStep>(); for( int i=builders.size()-1; i>=0; i-- ) { BuildStep b = builders.get(i); m.put(b.getDescriptor(),b); } return m; } |
Map<BuildStepDescriptor,BuildStep> m = new HashMap<BuildStepDescriptor,BuildStep>(); | Map<BuildStepDescriptor,BuildStep> m = new LinkedHashMap<BuildStepDescriptor,BuildStep>(); | public synchronized Map<BuildStepDescriptor,BuildStep> getPublishers() { Map<BuildStepDescriptor,BuildStep> m = new HashMap<BuildStepDescriptor,BuildStep>(); for( int i=publishers.size()-1; i>=0; i-- ) { BuildStep b = publishers.get(i); m.put(b.getDescriptor(),b); } return m; } |
GWebCacheManager.getInstance().invokeQueryMoreHostsRequest( false ); | GWebCacheManager.getInstance().invokeQueryMoreHostsRequest( true ); | private void ensureMinCaughHosts() { int minCount = (int)Math.ceil( NetworkPrefs.MaxHostInHostCache.get().doubleValue()/100.0 ); if ( caughtHosts.getSize() < minCount ) { // Query udpHostCache for new hosts UdpHostCacheManager.getInstance().invokeQueryCachesRequest(); NLogger.info( NLoggerNames.GLOBAL, " Started a UDP HOST CACHE Query" + " to ensure min no of hosts in the caughthost container"); // connect GWebCache for new hosts... GWebCacheManager.getInstance().invokeQueryMoreHostsRequest( false ); } } |
j = new GroupJep(new Quartonians()); | j = new GroupJep(new Quaternions()); | public void testQuartonians() throws Exception { j = new GroupJep(new Quartonians()); j.addStandardConstants(); System.out.println(j.getGroup().toString()); valueToStringTest("i*j","-k"); } |
drawEnd = drawnPixels[1] - 1; | drawEnd = drawnPixels[1]; | private void drag(int dragAmount, int dragFrom, SeismogramShapeIterator iterator){ double pointsPerPixel = iterator.getPointsPerPixel(); int[] seisPoints = currentIterator.getSeisPoints(); seisPoints[0] =(int)-(iterator.getTotalShift() * pointsPerPixel) + iterator.getBaseSeisPoint(); seisPoints[1] = seisPoints[0] + (int)(iterator.getSize().width * pointsPerPixel); //System.out.println("SeisPoints: " + seisPoints[0] + ", " + seisPoints[1] + " PointsPixel: " + pointsPerPixel); iterator.setSeisPoints(seisPoints); int[][] points = currentIterator.getPoints(); int length = points[0].length - Math.abs(dragAmount); System.arraycopy(points[0], dragFrom, points[0], dragFrom + dragAmount, length); System.arraycopy(points[1], dragFrom, points[1], dragFrom + dragAmount, length); int[] drawnPixels = getPixels(iterator); iterator.setDrawnPixels(drawnPixels); int drawStart, drawEnd; if(dragAmount < 0){ drawStart = drawnPixels[1] + dragAmount; drawEnd = drawnPixels[1] - 1; }else{ drawStart = drawnPixels[0]; drawEnd = dragAmount--; ++dragAmount; } //System.out.println("DragAmount: " + dragAmount + " reDrawStart: " + drawStart + // " reDrawEnd: " + drawEnd + " DragFrom: " + dragFrom + // " DrawStart: " + drawnPixels[0] + " DrawEnd: " + drawnPixels[1]); plotPixels(drawStart, drawEnd, iterator); } |
double pixelShift = currentIterator.getSize().width * shiftPercentage; | double pixels = currentIterator.getSize().width * shiftPercentage + currentIterator.getLeftoverPixels(); | public void dragPlot(SeismogramShapeIterator iterator){ iterator.copyBasicInfo(currentIterator); double shiftPercentage = getShiftPercentage(currentIterator.getTime(), iterator.getTime()); double pixelShift = currentIterator.getSize().width * shiftPercentage; //checks if the pixel shift is within 1/1000 of being an even pixel pixelShift = Math.round(pixelShift*1000)/1000; if(pixelShift%1 == 0){//if the shift is an even pixel, it gets shifted int shift = (int)pixelShift; if(shift >= 1){ iterator.setTotalShift(currentIterator.getTotalShift() + shift); drag(shift, 0, iterator); }else if(shift <= -1){ iterator.setTotalShift(currentIterator.getTotalShift() + shift); drag(shift, -shift, iterator); }else{ iterator.setSeisPoints(currentIterator.getSeisPoints()); iterator.setDrawnPixels(currentIterator.getDrawnPixels()); } currentIterator = iterator; }else{//else redraw the whole thing plot(iterator); } } |
pixelShift = Math.round(pixelShift*1000)/1000; if(pixelShift%1 == 0){ int shift = (int)pixelShift; if(shift >= 1){ iterator.setTotalShift(currentIterator.getTotalShift() + shift); drag(shift, 0, iterator); }else if(shift <= -1){ iterator.setTotalShift(currentIterator.getTotalShift() + shift); drag(shift, -shift, iterator); }else{ iterator.setSeisPoints(currentIterator.getSeisPoints()); iterator.setDrawnPixels(currentIterator.getDrawnPixels()); } currentIterator = iterator; }else{ plot(iterator); | pixels *= 1000; pixels = Math.round(pixels); pixels /= 1000; int shift = 0; if(pixels >= 1){ shift = (int)Math.floor(pixels); drag(shift, 0, iterator); }else if(pixels <= -1){ shift = (int)Math.ceil(pixels); drag(shift, -shift, iterator); }else{ iterator.setSeisPoints(currentIterator.getSeisPoints()); iterator.setDrawnPixels(currentIterator.getDrawnPixels()); | public void dragPlot(SeismogramShapeIterator iterator){ iterator.copyBasicInfo(currentIterator); double shiftPercentage = getShiftPercentage(currentIterator.getTime(), iterator.getTime()); double pixelShift = currentIterator.getSize().width * shiftPercentage; //checks if the pixel shift is within 1/1000 of being an even pixel pixelShift = Math.round(pixelShift*1000)/1000; if(pixelShift%1 == 0){//if the shift is an even pixel, it gets shifted int shift = (int)pixelShift; if(shift >= 1){ iterator.setTotalShift(currentIterator.getTotalShift() + shift); drag(shift, 0, iterator); }else if(shift <= -1){ iterator.setTotalShift(currentIterator.getTotalShift() + shift); drag(shift, -shift, iterator); }else{ iterator.setSeisPoints(currentIterator.getSeisPoints()); iterator.setDrawnPixels(currentIterator.getDrawnPixels()); } currentIterator = iterator; }else{//else redraw the whole thing plot(iterator); } } |
} | iterator.setLeftoverPixels(pixels - shift); currentIterator = iterator; } | public void dragPlot(SeismogramShapeIterator iterator){ iterator.copyBasicInfo(currentIterator); double shiftPercentage = getShiftPercentage(currentIterator.getTime(), iterator.getTime()); double pixelShift = currentIterator.getSize().width * shiftPercentage; //checks if the pixel shift is within 1/1000 of being an even pixel pixelShift = Math.round(pixelShift*1000)/1000; if(pixelShift%1 == 0){//if the shift is an even pixel, it gets shifted int shift = (int)pixelShift; if(shift >= 1){ iterator.setTotalShift(currentIterator.getTotalShift() + shift); drag(shift, 0, iterator); }else if(shift <= -1){ iterator.setTotalShift(currentIterator.getTotalShift() + shift); drag(shift, -shift, iterator); }else{ iterator.setSeisPoints(currentIterator.getSeisPoints()); iterator.setDrawnPixels(currentIterator.getDrawnPixels()); } currentIterator = iterator; }else{//else redraw the whole thing plot(iterator); } } |
run.getNextBuild().previousBuild = null; | public synchronized void removeRun(Run run) { builds.remove(run.getNumber()); } |
|
instance.show(); | instance.setVisible(true); | public static void splash(Image image) { if (instance == null && image != null) { Frame f = new Frame(); // Create the splash image instance = new SplashWindow(f, image); // Show the window. instance.show(); // Note: To make sure the user gets a chance to see the // splash window we wait until its paint method has been // called at least once by the AWT event dispatcher thread. // If more than one processor is available, we don't wait, // and maximize CPU throughput instead. if (! EventQueue.isDispatchThread() && Runtime.getRuntime().availableProcessors() == 1) { synchronized (instance) { while (! instance.paintCalled) { try { instance.wait(); } catch (InterruptedException e) {} } } } } } |
Complex temp = new Complex(((Number)param).doubleValue(),0.0); return temp.atanh(); | double val = ((Number)param).doubleValue(); if(val > -1.0 && val < 1) { double res = Math.log((1+val)/(1-val))/2; return new Double(res); } else { Complex temp = new Complex(val,0.0); return temp.atanh(); } | public Object atanh(Object param) throws ParseException { if (param instanceof Complex) { return ((Complex)param).atanh(); } else if (param instanceof Number) { Complex temp = new Complex(((Number)param).doubleValue(),0.0); return temp.atanh(); } throw new ParseException("Invalid parameter type"); } |
volUnitsCombo.addActionListener(new ActionListener() { public void actionPerformed (ActionEvent e){ setEvapLable(); } }); | private void layoutUi() { JPanel buttons = new JPanel(); okButton = new JButton("OK"); okButton.addActionListener(this); cancelButton = new JButton("Cancel"); cancelButton.addActionListener(this); buttons.setLayout(new FlowLayout(FlowLayout.RIGHT)); buttons.add(cancelButton); buttons.add(okButton); getContentPane().setLayout(new BorderLayout()); this.setFocusTraversalKeysEnabled(false); { jTabbedPane1 = new JTabbedPane(); getContentPane().add(jTabbedPane1, BorderLayout.CENTER); { pnlCalculations = new JPanel(); jTabbedPane1.addTab("Calculations", null, pnlCalculations, null); { try { { GridBagLayout thisLayout = new GridBagLayout(); thisLayout.rowWeights = new double[]{0.1, 0.1, 0.1, 0.1}; thisLayout.rowHeights = new int[]{7, 7, 7, 7}; thisLayout.columnWeights = new double[]{0.1, 0.2}; thisLayout.columnWidths = new int[]{7, 7}; pnlCalculations.setLayout(thisLayout); pnlCalculations.setPreferredSize(new java.awt.Dimension(524, 372)); { { bgHopsCalc = new ButtonGroup(); { pnlHops = new JPanel(); GridLayout pnlHopsLayout = new GridLayout(2, 2); pnlHopsLayout.setColumns(2); pnlHopsLayout.setHgap(5); pnlHopsLayout.setVgap(5); pnlHopsLayout.setRows(2); pnlHops.setLayout(pnlHopsLayout); pnlCalculations.add(pnlHops, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); pnlHops .setBorder(BorderFactory .createTitledBorder("Hops:")); { jLabelc1 = new JLabel(); pnlHops.add(jLabelc1); jLabelc1.setText("Pellet Hops +%"); } { txtPellet = new JTextField(); pnlHops.add(txtPellet); txtPellet.setPreferredSize(new java.awt.Dimension(20, 20)); } { jLabelc2 = new JLabel(); pnlHops.add(jLabelc2); jLabelc2.setText("Tinseth Utilization Factor"); } { txtTinsethUtil = new JTextField(); pnlHops.add(txtTinsethUtil); txtTinsethUtil.setText("4.15"); } } { pnlAlc = new JPanel(); BoxLayout pnlAlcLayout = new BoxLayout(pnlAlc, javax.swing.BoxLayout.Y_AXIS); pnlAlc.setLayout(pnlAlcLayout); pnlCalculations.add(pnlAlc, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); pnlAlc.setBorder(BorderFactory .createTitledBorder("Alcohol By:")); { rbABV = new JRadioButton(); pnlAlc.add(rbABV); bgAlc.add(rbABV); rbABV.setText("Volume"); } { rbABW = new JRadioButton(); pnlAlc.add(rbABW); bgAlc.add(rbABW); rbABW.setText("Weight"); } } { pnlHopTimes = new JPanel(); GridLayout pnlHopTimesLayout = new GridLayout(3, 2); pnlHopTimesLayout.setColumns(2); pnlHopTimesLayout.setHgap(5); pnlHopTimesLayout.setVgap(5); pnlHopTimesLayout.setRows(3); pnlHopTimes.setLayout(pnlHopTimesLayout); pnlCalculations.add(pnlHopTimes, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); pnlHopTimes.setBorder(BorderFactory .createTitledBorder("Hop Times:")); { jLabelc3 = new JLabel(); pnlHopTimes.add(jLabelc3); jLabelc3.setText("Dry (min):"); } { txtDryHopTime = new JTextField(); pnlHopTimes.add(txtDryHopTime); txtDryHopTime.setText("0.0"); } { jLabelc4 = new JLabel(); pnlHopTimes.add(jLabelc4); jLabelc4.setText("FWH, boil minus (min):"); } { txtFWHTime = new JTextField(); pnlHopTimes.add(txtFWHTime); txtFWHTime.setText("20.0"); } { jLabelc5 = new JLabel(); pnlHopTimes.add(jLabelc5); jLabelc5.setText("Mash Hop (min):"); } { txtMashHopTime = new JTextField(); pnlHopTimes.add(txtMashHopTime); txtMashHopTime.setText("2.0"); } } } pnlHopsCalc = new JPanel(); BoxLayout pnlHopsCalcLayout = new BoxLayout(pnlHopsCalc, javax.swing.BoxLayout.Y_AXIS); pnlHopsCalc.setLayout(pnlHopsCalcLayout); pnlCalculations.add(pnlHopsCalc, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); pnlCalculations.add(getPnlWaterUsage(), new GridBagConstraints(1, 2, 1, 2, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); pnlCalculations.add(getPnlColourOptions(), new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); pnlCalculations.add(getPnlEvaporation(), new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); pnlHopsCalc.setPreferredSize(new java.awt.Dimension(117, 107)); pnlHopsCalc.setBorder(BorderFactory .createTitledBorder("IBU Calc Method:")); { rbTinseth = new JRadioButton(); pnlHopsCalc.add(rbTinseth); rbTinseth.setText("Tinseth"); bgHopsCalc.add(rbTinseth); } { rbRager = new JRadioButton(); pnlHopsCalc.add(rbRager); rbRager.setText("Rager"); bgHopsCalc.add(rbRager); } { rbGaretz = new JRadioButton(); pnlHopsCalc.add(rbGaretz); rbGaretz.setText("Garetz"); bgHopsCalc.add(rbGaretz); } } } } catch (Exception e) { e.printStackTrace(); } } } { costCarbPanel = new JPanel(); BorderLayout costCarbPanelLayout = new BorderLayout(); costCarbPanel.setLayout(costCarbPanelLayout); jTabbedPane1.addTab("Cost & Carb", null, costCarbPanel, null); { carbPanel = new JPanel(); costCarbPanel.add(carbPanel, BorderLayout.CENTER); carbPanel.setBorder(BorderFactory.createTitledBorder(null, "Carbonation", TitledBorder.LEADING, TitledBorder.TOP)); { jLabel3 = new JLabel(); carbPanel.add(jLabel3); jLabel3.setText("Not implemented"); } } { jPanel2 = new JPanel(); costCarbPanel.add(jPanel2, BorderLayout.NORTH); GridBagLayout jPanel2Layout = new GridBagLayout(); jPanel2Layout.rowWeights = new double[]{0.1, 0.1, 0.4}; jPanel2Layout.rowHeights = new int[]{7, 7, 7}; jPanel2Layout.columnWeights = new double[]{0.1, 0.1, 0.1}; jPanel2Layout.columnWidths = new int[]{7, 7, 7}; jPanel2.setPreferredSize(new java.awt.Dimension(232, 176)); jPanel2.setBorder(BorderFactory.createTitledBorder("Cost")); jPanel2.setLayout(jPanel2Layout); { jLabel1 = new JLabel(); jPanel2.add(jLabel1, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel1.setText("Other Cost:"); } { txtOtherCost = new JTextField(); jPanel2.add(txtOtherCost, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); txtOtherCost.setText("$0.00"); txtOtherCost.setPreferredSize(new java.awt.Dimension(62, 20)); } { jLabel2 = new JLabel(); jPanel2.add(jLabel2, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel2.setText("Bottle Size:"); } { cmbBottleSize = new JComboBox(); cmbBottleSizeModel = new ComboModel(); cmbBottleSizeModel.setList(new Quantity().getListofUnits("vol")); cmbBottleSize.setModel(cmbBottleSizeModel); jPanel2.add(cmbBottleSize, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); cmbBottleSize.setPreferredSize(new java.awt.Dimension(89, 20)); jPanel2.add(getTxtBottleSize(), new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); } } { } } { pnlBrewer = new JPanel(); GridBagLayout pnlBrewerLayout = new GridBagLayout(); pnlBrewerLayout.rowWeights = new double[]{0.1, 0.1, 0.3, 0.3}; pnlBrewerLayout.rowHeights = new int[]{2, 2, 7, 7}; pnlBrewerLayout.columnWeights = new double[]{0.1, 0.1, 0.1, 0.1}; pnlBrewerLayout.columnWidths = new int[]{7, 7, 7, 7}; pnlBrewer.setLayout(pnlBrewerLayout); jTabbedPane1.addTab("Brewer", null, pnlBrewer, null); { jLabel4 = new JLabel(); pnlBrewer.add(jLabel4, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel4.setText("Name:"); } { txtBrewerName = new JTextField(); pnlBrewer.add(txtBrewerName, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); txtBrewerName.setText("Your Name"); } { jLabel5 = new JLabel(); pnlBrewer.add(jLabel5, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel5.setText("Phone:"); } { txtPhone = new JTextField(); pnlBrewer.add(txtPhone, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); txtPhone.setText("Your Phone"); } { jLabel6 = new JLabel(); pnlBrewer.add(jLabel6, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel6.setText("Club Name:"); } { txtClubName = new JTextField(); pnlBrewer.add(txtClubName, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); txtClubName.setText("Club Name"); } { jLabel7 = new JLabel(); pnlBrewer.add(jLabel7, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel7.setText("Email:"); } { txtEmail = new JTextField(); pnlBrewer.add(txtEmail, new GridBagConstraints(3, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); txtEmail.setText("Email"); } } { pnlDatabase = new JPanel(); BorderLayout pnlDatabaseLayout = new BorderLayout(); pnlDatabase.setLayout(pnlDatabaseLayout); pnlDatabase.add(getPnlDefaultDB(), BorderLayout.NORTH); pnlDatabase.add(getPnlSortOrder(), BorderLayout.WEST); jTabbedPane1.addTab("Database", null, pnlDatabase, null); pnlDatabase.setVisible(false); } newRecipePanel = new JPanel(); GridBagLayout newRecipePanelLayout = new GridBagLayout(); newRecipePanelLayout.rowWeights = new double[]{0.1, 0.1, 0.1, 0.1}; newRecipePanelLayout.rowHeights = new int[]{7, 7, 7, 7}; newRecipePanelLayout.columnWeights = new double[]{0.1, 0.1, 0.1, 0.1}; newRecipePanelLayout.columnWidths = new int[]{7, 7, 7, 7}; newRecipePanel.setLayout(newRecipePanelLayout); jTabbedPane1.addTab("New Recipe Defaults", null, newRecipePanel, null); appearancePanel = new JPanel(); BorderLayout appearancePanelLayout = new BorderLayout(); appearancePanel.setLayout(appearancePanelLayout); jTabbedPane1.addTab("Appearance", null, appearancePanel, null);/* landfPanel = new JPanel(); appearancePanel.add(landfPanel, BorderLayout.NORTH); jLabel19 = new JLabel(); landfPanel.add(jLabel19); jLabel19.setText("Look and Feel:"); landfCombo = new JComboBox(looks.toArray()); landfPanel.add(landfCombo);*/ colourPanel = new JPanel(); appearancePanel.add(colourPanel, BorderLayout.CENTER); GridBagLayout colourPanelLayout = new GridBagLayout(); colourPanelLayout.rowWeights = new double[] {0.1, 0.1, 0.1, 0.1, 0.1, 0.1}; colourPanelLayout.rowHeights = new int[] {7, 7, 7, 7, 7, 7}; colourPanelLayout.columnWeights = new double[] {0.1, 0.1, 0.1, 0.1, 0.1, 0.1}; colourPanelLayout.columnWidths = new int[] {7, 7, 7, 7, 7, 7}; colourPanel.setLayout(colourPanelLayout); colourPanel.setPreferredSize(new java.awt.Dimension(340, 223)); colourPanel.setBorder(BorderFactory.createTitledBorder("Colour Swatch")); colMethod1rb = new JRadioButton(); colMethod1rb.addActionListener(this); colourGroup.add(colMethod1rb); colourPanel.add(colMethod1rb, new GridBagConstraints(0, 0, 3, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); colMethod1rb.setText("Colour Method 1"); colMethod2rb = new JRadioButton(); colMethod2rb.addActionListener(this); colourGroup.add(colMethod2rb); colourPanel.add(colMethod2rb, new GridBagConstraints(3, 0, 3, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); colMethod2rb.setText("Colour Method 2"); jLabel13 = new JLabel(); colourPanel.add(jLabel13, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); jLabel13.setText("Straw \n(2)"); jLabel14 = new JLabel(); colourPanel.add(jLabel14, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); jLabel14.setText("Pale\n(4)"); jLabel15 = new JLabel(); colourPanel.add(jLabel15, new GridBagConstraints(2, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); jLabel15.setText("Amber\n(8)"); jLabel16 = new JLabel(); colourPanel.add(jLabel16, new GridBagConstraints(3, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); jLabel16.setText("Copper (15)"); jLabel17 = new JLabel(); colourPanel.add(jLabel17, new GridBagConstraints(4, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); jLabel17.setText("Brown (20)"); jLabel18 = new JLabel(); colourPanel.add(jLabel18, new GridBagConstraints(5, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); jLabel18.setText("Black (30)"); stawPanel = new JPanel(); colourPanel.add(stawPanel, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); stawPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); palePanel = new JPanel(); colourPanel.add(palePanel, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); palePanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); amberPanel = new JPanel(); colourPanel.add(amberPanel, new GridBagConstraints(2, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); amberPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); copperPanel = new JPanel(); colourPanel.add(copperPanel, new GridBagConstraints(3, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); copperPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); brownPanel = new JPanel(); colourPanel.add(brownPanel, new GridBagConstraints(4, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); brownPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); blackPanel = new JPanel(); colourPanel.add(blackPanel, new GridBagConstraints(5, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); blackPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); SpinnerNumberModel redSpnModel = new SpinnerNumberModel(8,0,255,1); redSpn = new JSpinner(); colourPanel.add(redSpn, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); redSpn.setModel(redSpnModel); redSpn.addChangeListener(this); SpinnerNumberModel greenSpnModel = new SpinnerNumberModel(30,0,255,1); greenSpn = new JSpinner(); colourPanel.add(greenSpn, new GridBagConstraints(3, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); greenSpn.setModel(greenSpnModel); greenSpn.addChangeListener(this); SpinnerNumberModel blueSpnModel = new SpinnerNumberModel(20,0,255,1); blueSpn = new JSpinner(); colourPanel.add(blueSpn, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); blueSpn.setModel(blueSpnModel); blueSpn.addChangeListener(this); SpinnerNumberModel alphaSpnModel = new SpinnerNumberModel(255,0,255,1); alphaSpn = new JSpinner(); colourPanel.add(alphaSpn, new GridBagConstraints(3, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); alphaSpn.setModel(alphaSpnModel); alphaSpn.addChangeListener(this); jLabel20 = new JLabel(); colourPanel.add(jLabel20, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel20.setText("Red:"); jLabel21 = new JLabel(); colourPanel.add(jLabel21, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel21.setText("Blue:"); jLabel22 = new JLabel(); colourPanel.add(jLabel22, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel22.setText("Green:"); jLabel23 = new JLabel(); colourPanel.add(jLabel23, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel23.setText("Alpha:"); mashPanel = new JPanel(); newRecipePanel.add(mashPanel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); mashPanel.setBorder(BorderFactory.createTitledBorder("Mash")); jPanel1 = new JPanel(); GridBagLayout jPanel1Layout = new GridBagLayout(); jPanel1Layout.rowWeights = new double[] {0.1, 0.1, 0.1, 0.1}; jPanel1Layout.rowHeights = new int[] {7, 7, 7, 7}; jPanel1Layout.columnWeights = new double[] {0.1, 0.1}; jPanel1Layout.columnWidths = new int[] {7, 7}; jPanel1.setLayout(jPanel1Layout); newRecipePanel.add(jPanel1, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); jPanel1.setBorder(BorderFactory.createTitledBorder("Units")); jLabel19 = new JLabel(); jPanel1.add(jLabel19, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel19.setText("Malt Units:"); maltUnitsCombo = new JComboBox(); jPanel1.add(maltUnitsCombo, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); maltUnitsComboModel = new ComboModel(); maltUnitsComboModel.setList(new Quantity().getListofUnits("weight")); maltUnitsCombo.setModel(maltUnitsComboModel); jLabel24 = new JLabel(); jPanel1.add(jLabel24, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel24.setText("Hops Units:"); hopsUnitsCombo = new JComboBox(); jPanel1.add(hopsUnitsCombo, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); hopsUnitsComboModel = new ComboModel(); hopsUnitsComboModel.setList(new Quantity().getListofUnits("weight")); hopsUnitsCombo.setModel(hopsUnitsComboModel); jLabel25 = new JLabel(); jPanel1.add(jLabel25, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel25.setText("Vol Units:"); volUnitsCombo = new JComboBox(); jPanel1.add(volUnitsCombo, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); volUnitsComboModel = new ComboModel(); volUnitsComboModel.setList(new Quantity().getListofUnits("vol")); volUnitsCombo.setModel(volUnitsComboModel); jLabel26 = new JLabel(); jPanel1.add(jLabel26, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel26.setText("Batch Size:"); batchSizeTxt = new JTextField(); jPanel1.add(batchSizeTxt, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); batchSizeTxt.setText("jTextField1"); jLabel12 = new JLabel(); mashPanel.add(jLabel12); jLabel12.setText("Boil Temp (F):"); boilTempTxt = new JTextField(); mashPanel.add(boilTempTxt); boilTempTxt.setText("212"); boilTempTxt.setPreferredSize(new java.awt.Dimension(43, 20)); } getContentPane().add(BorderLayout.CENTER, jTabbedPane1); getContentPane().add(BorderLayout.SOUTH, buttons); setSize(500, 500); } |
|
if (opts.getProperty("optEvapCalcMethod").equalsIgnoreCase("Percent")) evapAmountLbl.setText("%"); else evapAmountLbl.setText(opts.getProperty("optSizeU") + "/hr"); | setEvapLable(); | private void setOptions() { // cost tab: txtOtherCost.setText(opts.getProperty("optMiscCost")); txtBottleSize.setText(opts.getProperty("optBottleSize")); cmbBottleSizeModel.addOrInsert(opts.getProperty("optBottleU")); // brewer tab: txtBrewerName.setText(opts.getProperty("optBrewer")); txtPhone.setText(opts.getProperty("optPhone")); txtClubName.setText(opts.getProperty("optClub")); txtEmail.setText(opts.getProperty("optEmail")); // calculations tab: rbTinseth.setSelected(opts.getProperty("optIBUCalcMethod").equalsIgnoreCase("Tinseth")); rbRager.setSelected(opts.getProperty("optIBUCalcMethod").equalsIgnoreCase("Rager")); rbGaretz.setSelected(opts.getProperty("optIBUCalcMethod").equalsIgnoreCase("Garetz")); rbABV.setSelected((opts.getProperty("optAlcCalcMethod").equalsIgnoreCase("Volume"))); rbABW.setSelected((opts.getProperty("optAlcCalcMethod").equalsIgnoreCase("Weight"))); rbSRM.setSelected((opts.getProperty("optColourMethod").equalsIgnoreCase("SRM"))); rbEBC.setSelected((opts.getProperty("optColourMethod").equalsIgnoreCase("EBC"))); rbPercent.setSelected((opts.getProperty("optEvapCalcMethod").equalsIgnoreCase("Percent"))); rbConstant.setSelected((opts.getProperty("optEvapCalcMethod").equalsIgnoreCase("Constant"))); evapAmountTxt.setText(opts.getProperty("optEvaporation")); if (opts.getProperty("optEvapCalcMethod").equalsIgnoreCase("Percent")) evapAmountLbl.setText("%"); else evapAmountLbl.setText(opts.getProperty("optSizeU") + "/hr"); txtPellet.setText(opts.getProperty("optPelletHopsPct")); txtTinsethUtil.setText(opts.getProperty("optHopsUtil")); txtDryHopTime.setText(opts.getProperty("optDryHopTime")); txtFWHTime.setText(opts.getProperty("optFWHTime")); txtMashHopTime.setText(opts.getProperty("optMashHopTime")); txtLeftInKettle.setText(opts.getProperty("optKettleLoss")); txtMiscLosses.setText(opts.getProperty("optMiscLoss")); txtLostInTrub.setText(opts.getProperty("optTrubLoss")); // new recipe tab: boilTempTxt.setText(opts.getProperty("optBoilTempF")); batchSizeTxt.setText(opts.getProperty("optPostBoilVol")); maltUnitsComboModel.addOrInsert(opts.getProperty("optMaltU")); hopsUnitsComboModel.addOrInsert(opts.getProperty("optHopsU")); volUnitsComboModel.addOrInsert(opts.getProperty("optSizeU")); // appearances tab: redSpn.setValue(new Integer(opts.getIProperty("optRed"))); greenSpn.setValue(new Integer(opts.getIProperty("optGreen"))); blueSpn.setValue(new Integer(opts.getIProperty("optBlue"))); alphaSpn.setValue(new Integer(opts.getIProperty("optAlpha"))); colMethod1rb.setSelected(opts.getProperty("optRGBMethod").equals("1")); colMethod2rb.setSelected(opts.getProperty("optRGBMethod").equals("2")); displayColour(); } |
txtLostInTrub.setText(opts.getProperty("optTrubLoss")); boilTempTxt.setText(opts.getProperty("optBoilTempF")); batchSizeTxt.setText(opts.getProperty("optPostBoilVol")); maltUnitsComboModel.addOrInsert(opts.getProperty("optMaltU")); hopsUnitsComboModel.addOrInsert(opts.getProperty("optHopsU")); volUnitsComboModel.addOrInsert(opts.getProperty("optSizeU")); | txtLostInTrub.setText(opts.getProperty("optTrubLoss")); | private void setOptions() { // cost tab: txtOtherCost.setText(opts.getProperty("optMiscCost")); txtBottleSize.setText(opts.getProperty("optBottleSize")); cmbBottleSizeModel.addOrInsert(opts.getProperty("optBottleU")); // brewer tab: txtBrewerName.setText(opts.getProperty("optBrewer")); txtPhone.setText(opts.getProperty("optPhone")); txtClubName.setText(opts.getProperty("optClub")); txtEmail.setText(opts.getProperty("optEmail")); // calculations tab: rbTinseth.setSelected(opts.getProperty("optIBUCalcMethod").equalsIgnoreCase("Tinseth")); rbRager.setSelected(opts.getProperty("optIBUCalcMethod").equalsIgnoreCase("Rager")); rbGaretz.setSelected(opts.getProperty("optIBUCalcMethod").equalsIgnoreCase("Garetz")); rbABV.setSelected((opts.getProperty("optAlcCalcMethod").equalsIgnoreCase("Volume"))); rbABW.setSelected((opts.getProperty("optAlcCalcMethod").equalsIgnoreCase("Weight"))); rbSRM.setSelected((opts.getProperty("optColourMethod").equalsIgnoreCase("SRM"))); rbEBC.setSelected((opts.getProperty("optColourMethod").equalsIgnoreCase("EBC"))); rbPercent.setSelected((opts.getProperty("optEvapCalcMethod").equalsIgnoreCase("Percent"))); rbConstant.setSelected((opts.getProperty("optEvapCalcMethod").equalsIgnoreCase("Constant"))); evapAmountTxt.setText(opts.getProperty("optEvaporation")); if (opts.getProperty("optEvapCalcMethod").equalsIgnoreCase("Percent")) evapAmountLbl.setText("%"); else evapAmountLbl.setText(opts.getProperty("optSizeU") + "/hr"); txtPellet.setText(opts.getProperty("optPelletHopsPct")); txtTinsethUtil.setText(opts.getProperty("optHopsUtil")); txtDryHopTime.setText(opts.getProperty("optDryHopTime")); txtFWHTime.setText(opts.getProperty("optFWHTime")); txtMashHopTime.setText(opts.getProperty("optMashHopTime")); txtLeftInKettle.setText(opts.getProperty("optKettleLoss")); txtMiscLosses.setText(opts.getProperty("optMiscLoss")); txtLostInTrub.setText(opts.getProperty("optTrubLoss")); // new recipe tab: boilTempTxt.setText(opts.getProperty("optBoilTempF")); batchSizeTxt.setText(opts.getProperty("optPostBoilVol")); maltUnitsComboModel.addOrInsert(opts.getProperty("optMaltU")); hopsUnitsComboModel.addOrInsert(opts.getProperty("optHopsU")); volUnitsComboModel.addOrInsert(opts.getProperty("optSizeU")); // appearances tab: redSpn.setValue(new Integer(opts.getIProperty("optRed"))); greenSpn.setValue(new Integer(opts.getIProperty("optGreen"))); blueSpn.setValue(new Integer(opts.getIProperty("optBlue"))); alphaSpn.setValue(new Integer(opts.getIProperty("optAlpha"))); colMethod1rb.setSelected(opts.getProperty("optRGBMethod").equals("1")); colMethod2rb.setSelected(opts.getProperty("optRGBMethod").equals("2")); displayColour(); } |
else return error.getMessage(); | return error.getMessage(); | public String getErrorsMessage() { if(error==null) return null; else return error.getMessage(); } |
float hVal = getVal(hIt, hMin, hMax, size.height); float vVal = getVal(vIt, vMin, vMax, size.height); | double hVal = getVal(hIt, hMin, hMax, size.height); double vVal = getVal(vIt, vMin, vMax, size.height); | public void draw(Graphics g, Dimension size) { if(visible){ Graphics2D g2D = (Graphics2D) g; if(horiz.getIterator(tr).numPointsLeft() <= 0 || vert.getIterator(tr).numPointsLeft() <= 0){ return; } g2D.setColor(color); g2D.setStroke(DisplayUtils.TWO_PIXEL_STROKE); GeneralPath generalPath = new GeneralPath(GeneralPath.WIND_EVEN_ODD); boolean prevPointBad = true;//first point needs to be a move to SeismogramIterator hIt = horiz.getIterator(tr); double hMin = ae.getAmp(horiz.getDataSetSeismogram()).getMinValue(); double hMax = ae.getAmp(horiz.getDataSetSeismogram()).getMaxValue(); SeismogramIterator vIt = vert.getIterator(tr); double vMin = ae.getAmp(vert.getDataSetSeismogram()).getMinValue(); double vMax = ae.getAmp(vert.getDataSetSeismogram()).getMaxValue(); while(hIt.hasNext() && vIt.hasNext()){ float hVal = getVal(hIt, hMin, hMax, size.height); float vVal = getVal(vIt, vMin, vMax, size.height); if(hVal == Integer.MAX_VALUE || vVal == Integer.MAX_VALUE){ prevPointBad = true; }else{ hVal *= -1; hVal += size.height; if(prevPointBad){ generalPath.moveTo(hVal, vVal); prevPointBad = false; }else{ generalPath.lineTo(hVal, vVal); } } } g2D.draw(generalPath); } Iterator it = filterToParMo.keySet().iterator(); while(it.hasNext()){ ((ParticleMotion)filterToParMo.get(it.next())).draw(g, size); } } |
hVal *= -1; hVal += size.height; | vVal *= -1; vVal += size.height; | public void draw(Graphics g, Dimension size) { if(visible){ Graphics2D g2D = (Graphics2D) g; if(horiz.getIterator(tr).numPointsLeft() <= 0 || vert.getIterator(tr).numPointsLeft() <= 0){ return; } g2D.setColor(color); g2D.setStroke(DisplayUtils.TWO_PIXEL_STROKE); GeneralPath generalPath = new GeneralPath(GeneralPath.WIND_EVEN_ODD); boolean prevPointBad = true;//first point needs to be a move to SeismogramIterator hIt = horiz.getIterator(tr); double hMin = ae.getAmp(horiz.getDataSetSeismogram()).getMinValue(); double hMax = ae.getAmp(horiz.getDataSetSeismogram()).getMaxValue(); SeismogramIterator vIt = vert.getIterator(tr); double vMin = ae.getAmp(vert.getDataSetSeismogram()).getMinValue(); double vMax = ae.getAmp(vert.getDataSetSeismogram()).getMaxValue(); while(hIt.hasNext() && vIt.hasNext()){ float hVal = getVal(hIt, hMin, hMax, size.height); float vVal = getVal(vIt, vMin, vMax, size.height); if(hVal == Integer.MAX_VALUE || vVal == Integer.MAX_VALUE){ prevPointBad = true; }else{ hVal *= -1; hVal += size.height; if(prevPointBad){ generalPath.moveTo(hVal, vVal); prevPointBad = false; }else{ generalPath.lineTo(hVal, vVal); } } } g2D.draw(generalPath); } Iterator it = filterToParMo.keySet().iterator(); while(it.hasNext()){ ((ParticleMotion)filterToParMo.get(it.next())).draw(g, size); } } |
generalPath.moveTo(hVal, vVal); | generalPath.moveTo((int)hVal, (int)vVal); | public void draw(Graphics g, Dimension size) { if(visible){ Graphics2D g2D = (Graphics2D) g; if(horiz.getIterator(tr).numPointsLeft() <= 0 || vert.getIterator(tr).numPointsLeft() <= 0){ return; } g2D.setColor(color); g2D.setStroke(DisplayUtils.TWO_PIXEL_STROKE); GeneralPath generalPath = new GeneralPath(GeneralPath.WIND_EVEN_ODD); boolean prevPointBad = true;//first point needs to be a move to SeismogramIterator hIt = horiz.getIterator(tr); double hMin = ae.getAmp(horiz.getDataSetSeismogram()).getMinValue(); double hMax = ae.getAmp(horiz.getDataSetSeismogram()).getMaxValue(); SeismogramIterator vIt = vert.getIterator(tr); double vMin = ae.getAmp(vert.getDataSetSeismogram()).getMinValue(); double vMax = ae.getAmp(vert.getDataSetSeismogram()).getMaxValue(); while(hIt.hasNext() && vIt.hasNext()){ float hVal = getVal(hIt, hMin, hMax, size.height); float vVal = getVal(vIt, vMin, vMax, size.height); if(hVal == Integer.MAX_VALUE || vVal == Integer.MAX_VALUE){ prevPointBad = true; }else{ hVal *= -1; hVal += size.height; if(prevPointBad){ generalPath.moveTo(hVal, vVal); prevPointBad = false; }else{ generalPath.lineTo(hVal, vVal); } } } g2D.draw(generalPath); } Iterator it = filterToParMo.keySet().iterator(); while(it.hasNext()){ ((ParticleMotion)filterToParMo.get(it.next())).draw(g, size); } } |
generalPath.lineTo(hVal, vVal); | generalPath.lineTo((int)hVal, (int)vVal); | public void draw(Graphics g, Dimension size) { if(visible){ Graphics2D g2D = (Graphics2D) g; if(horiz.getIterator(tr).numPointsLeft() <= 0 || vert.getIterator(tr).numPointsLeft() <= 0){ return; } g2D.setColor(color); g2D.setStroke(DisplayUtils.TWO_PIXEL_STROKE); GeneralPath generalPath = new GeneralPath(GeneralPath.WIND_EVEN_ODD); boolean prevPointBad = true;//first point needs to be a move to SeismogramIterator hIt = horiz.getIterator(tr); double hMin = ae.getAmp(horiz.getDataSetSeismogram()).getMinValue(); double hMax = ae.getAmp(horiz.getDataSetSeismogram()).getMaxValue(); SeismogramIterator vIt = vert.getIterator(tr); double vMin = ae.getAmp(vert.getDataSetSeismogram()).getMinValue(); double vMax = ae.getAmp(vert.getDataSetSeismogram()).getMaxValue(); while(hIt.hasNext() && vIt.hasNext()){ float hVal = getVal(hIt, hMin, hMax, size.height); float vVal = getVal(vIt, vMin, vMax, size.height); if(hVal == Integer.MAX_VALUE || vVal == Integer.MAX_VALUE){ prevPointBad = true; }else{ hVal *= -1; hVal += size.height; if(prevPointBad){ generalPath.moveTo(hVal, vVal); prevPointBad = false; }else{ generalPath.lineTo(hVal, vVal); } } } g2D.draw(generalPath); } Iterator it = filterToParMo.keySet().iterator(); while(it.hasNext()){ ((ParticleMotion)filterToParMo.get(it.next())).draw(g, size); } } |
private int getVal(SeismogramIterator it, double minAmp, double maxAmp, int size){ | private double getVal(SeismogramIterator it, double minAmp, double maxAmp, int size){ | private int getVal(SeismogramIterator it, double minAmp, double maxAmp, int size){ double itVal = ((QuantityImpl)it.next()).getValue(); if(Double.isNaN(itVal)){//Gap in trace itVal = Integer.MAX_VALUE; }else{ itVal= Math.round(SimplePlotUtil.linearInterp(minAmp, 0, maxAmp, size, itVal)); } return (int)itVal; } |
return (int)itVal; | return itVal; | private int getVal(SeismogramIterator it, double minAmp, double maxAmp, int size){ double itVal = ((QuantityImpl)it.next()).getValue(); if(Double.isNaN(itVal)){//Gap in trace itVal = Integer.MAX_VALUE; }else{ itVal= Math.round(SimplePlotUtil.linearInterp(minAmp, 0, maxAmp, size, itVal)); } return (int)itVal; } |
tc.addListener(ParticleMotionView.this); | private void setUpConfigs(){ DataSetSeismogram[] seis = { horiz.getDataSetSeismogram(), vert.getDataSetSeismogram()}; AmpConfig ac = (AmpConfig)keysToAmpConfigs.get(key); if(ac == null){ ac = new RMeanAmpConfig(); keysToAmpConfigs.put(key, ac); } if(!tc.contains(seis[0])){ tc.add(seis); } tc.addListener(ac); tc.addListener(this); tc.addListener(ParticleMotionView.this); ac.add(seis); ac.addListener(this); } |
|
repaint(); | public void updateTime(TimeEvent timeEvent) { this.tr = timeEvent.getTime(); } |
|
pmd.setActiveAmpConfig((AmpConfig)keysToAmpConfigs.get(displayKey)); | public void setDisplayKey(String key) { displayKey = key; } |
|
for(int i=numberOfParameters-1;i>0;) vars[i] = mySymTab.addVariable("x"+String.valueOf(i),null); | for(int i=numberOfParameters;i>0;--i) vars[i-1] = mySymTab.addVariable("x"+String.valueOf(i),null); | public MacroFunction(String inName,int nargs,String expression,XJep jep) throws IllegalArgumentException,ParseException { super(); name = inName; XSymbolTable jepSymTab = (XSymbolTable) jep.getSymbolTable(); mySymTab = (XSymbolTable) jepSymTab.newInstance(); mySymTab.copyConstants(jepSymTab); XJep localJep = jep.newInstance(mySymTab); numberOfParameters = nargs; if(numberOfParameters == 0) {} else if(numberOfParameters == 1) vars = new Variable[]{mySymTab.addVariable("x",null)}; else if(numberOfParameters == 2) { vars = new Variable[]{ mySymTab.addVariable("x",null), mySymTab.addVariable("y",null)}; } else { vars = new Variable[numberOfParameters]; for(int i=numberOfParameters-1;i>0;) vars[i] = mySymTab.addVariable("x"+String.valueOf(i),null); } topNode = localJep.parse(expression); } |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.