bugged
stringlengths
6
599k
fixed
stringlengths
10
599k
__index_level_0__
int64
0
1.13M
public void actionPerformed(ActionEvent evt) { // exit program System.exit(0); }
public void actionPerformed(ActionEvent evt) { // exit program System.exit(0); }
1,116,848
public void actionPerformed(ActionEvent evt) { PreferencesDialog d = new PreferencesDialog(owner, preferences); d.setVisible(true); }
public void actionPerformed(ActionEvent evt) { PreferencesDialog d = new PreferencesDialog(owner, preferences); d.setVisible(true); }
1,116,849
public void actionPerformed(ActionEvent evt) { mashMgr = new MashManager(myRecipe); mashMgr.setVisible(true); }
public void actionPerformed(ActionEvent evt) { mashMgr = new MashManager(myRecipe); mashMgr.setVisible(true); }
1,116,850
public void actionPerformed(ActionEvent evt) { aboutDlg = new AboutDialog(owner); aboutDlg.setVisible(true); }
public void actionPerformed(ActionEvent evt) { aboutDlg = new AboutDialog(owner); aboutDlg.setVisible(true); }
1,116,851
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); }
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); }
1,116,853
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); }
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); }
1,116,854
public void setSpeedUp(int newSpeed){ speedUp = newSpeed; sampleRate = calculateSampleRate(iterator.getSampling(), newSpeed); byteRate = sampleRate * blockAlign; }
public void setSpeedUp(int newSpeed){ speedUp = newSpeed; sampleRate = calculateSampleRate(iterator.getSampling(), newSpeed); byteRate = sampleRate * blockAlign; }
1,116,856
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()); } } }
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("yeasts")){ 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()); } } }
1,116,859
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); } }
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("yeasts")) myRecipe.getYeastObj().setDescription(descrBuf); } }
1,116,860
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); }
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); }
1,116,861
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; }
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; }
1,116,863
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); } }
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); Node copy =mjep.deepCopy(children[1]); Node simp = mjep.simplify(copy); var.setEquation(simp); 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); } }
1,116,864
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); } }
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.getMList()) { 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); } }
1,116,865
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); } }
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.getMList()); 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); } }
1,116,866
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); } }
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.getMList(),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); } }
1,116,867
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; } }
public boolean perform(Build build, Launcher launcher, BuildListener listener) { Project proj = build.getProject(); String cmd; String execName; if(onWindows) 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; } }
1,116,870
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"); }
public Object atan(Object param) throws ParseException { if (param instanceof Complex) { return ((Complex)param).atan(); } else 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"); }
1,116,873
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"); }
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"); }
1,116,874
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; }
public synchronized Map<BuildStepDescriptor,BuildStep> getBuilders() { Map<BuildStepDescriptor,BuildStep> m = new LinkedHashMap<BuildStepDescriptor,BuildStep>(); for( int i=builders.size()-1; i>=0; i-- ) { BuildStep b = builders.get(i); m.put(b.getDescriptor(),b); } return m; }
1,116,875
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; }
public synchronized Map<BuildStepDescriptor,BuildStep> getPublishers() { Map<BuildStepDescriptor,BuildStep> m = new LinkedHashMap<BuildStepDescriptor,BuildStep>(); for( int i=publishers.size()-1; i>=0; i-- ) { BuildStep b = publishers.get(i); m.put(b.getDescriptor(),b); } return m; }
1,116,876
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 ); } }
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( true ); } }
1,116,877
public void testQuartonians() throws Exception { j = new GroupJep(new Quartonians()); j.addStandardConstants(); System.out.println(j.getGroup().toString()); valueToStringTest("i*j","-k"); }
public void testQuartonians() throws Exception { j = new GroupJep(new Quaternions()); j.addStandardConstants(); System.out.println(j.getGroup().toString()); valueToStringTest("i*j","-k"); }
1,116,878
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); }
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]; }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); }
1,116,879
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); } }
public void dragPlot(SeismogramShapeIterator iterator){ iterator.copyBasicInfo(currentIterator); double shiftPercentage = getShiftPercentage(currentIterator.getTime(), iterator.getTime()); double pixels = currentIterator.getSize().width * shiftPercentage + currentIterator.getLeftoverPixels(); //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); } }
1,116,880
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); } }
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); } }
1,116,881
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); } }
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); iterator.setLeftoverPixels(pixels - shift); currentIterator = iterator; }else if(shift <= -1){ iterator.setTotalShift(currentIterator.getTotalShift() + shift); drag(shift, -shift, iterator); iterator.setLeftoverPixels(pixels - shift); currentIterator = iterator; }else{ iterator.setSeisPoints(currentIterator.getSeisPoints()); iterator.setDrawnPixels(currentIterator.getDrawnPixels()); iterator.setLeftoverPixels(pixels - shift); currentIterator = iterator; } currentIterator = iterator; iterator.setLeftoverPixels(pixels - shift); currentIterator = iterator; }else{//else redraw the whole thing plot(iterator); iterator.setLeftoverPixels(pixels - shift); currentIterator = iterator; } iterator.setLeftoverPixels(pixels - shift); currentIterator = iterator; }
1,116,882
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) {} } } } } }
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.setVisible(true); // 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) {} } } } } }
1,116,884
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"); }
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"); }
1,116,885
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(); }
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(); }
1,116,887
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(); }
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(); }
1,116,888
public String getErrorsMessage() { if(error==null) return null; else return error.getMessage(); }
public String getErrorsMessage() { if(error==null) return null; return error.getMessage(); }
1,116,889
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); } }
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); } }
1,116,890
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); } }
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); } }
1,116,891
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); } }
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((int)hVal, (int)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); } }
1,116,892
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); } }
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((int)hVal, (int)vVal); } } } g2D.draw(generalPath); } Iterator it = filterToParMo.keySet().iterator(); while(it.hasNext()){ ((ParticleMotion)filterToParMo.get(it.next())).draw(g, size); } }
1,116,893
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; }
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; }
1,116,894
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; }
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 itVal; }
1,116,895
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); }
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); ac.add(seis); ac.addListener(this); }
1,116,896
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); }
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); }
1,116,899
public void run(Stack stack) throws ParseException { if(numberOfParameters == 0) {} else if(numberOfParameters == 1) vars[0].setValue(stack.pop()); else if(numberOfParameters == 2) { vars[1].setValue(stack.pop()); vars[0].setValue(stack.pop()); } else { for(int i=numberOfParameters-1;i>0;) vars[i].setValue(stack.pop()); } try { Object res = ev.getValue(topNode,mySymTab); stack.push(res); } catch(Exception e1) { throw new ParseException("MacroFunction eval: "+e1.getMessage()); } }
public void run(Stack stack) throws ParseException { if(numberOfParameters == 0) {} else if(numberOfParameters == 1) vars[0].setValue(stack.pop()); else if(numberOfParameters == 2) { vars[1].setValue(stack.pop()); vars[0].setValue(stack.pop()); } else { for(int i=numberOfParameters-1;i>0;) vars[i].setValue(stack.pop()); } try { Object res = ev.getValue(topNode,mySymTab); stack.push(res); } catch(Exception e1) { throw new ParseException("MacroFunction eval: "+e1.getMessage()); } }
1,116,900
public PrintWriter error(String msg) { out.println(msg); return new PrintWriter(out); }
public PrintWriter error(String msg) { out.println(msg); return new PrintWriter(new OutputStreamWriter(out),true); }
1,116,901
public void printOps() { println("Known operators"); Operator ops[] = j.getOperatorSet().getOperators(); int maxPrec = -1; for(int i=0;i<ops.length;++i) if(((XOperator) ops[i]).getPrecedence()>maxPrec) maxPrec=((XOperator) ops[i]).getPrecedence(); for(int j=-1;j<=maxPrec;++j) for(int i=0;i<ops.length;++i) if(((XOperator) ops[i]).getPrecedence()==j) println(((XOperator) ops[i]).toFullString()); }
public void printOps() { println("Known operators"); Operator ops[] = j.getOperatorSet().getOperators(); int maxPrec = -1; for(int i=0;i<ops.length;++i) if(((XOperator) ops[i]).getPrecedence()>maxPrec) maxPrec=((XOperator) ops[i]).getPrecedence(); for(int jj=-1;jj<=maxPrec;++jj) for(int i=0;i<ops.length;++i) if(((XOperator) ops[i]).getPrecedence()==j) println(((XOperator) ops[i]).toFullString()); }
1,116,904
public void printOps() { println("Known operators"); Operator ops[] = j.getOperatorSet().getOperators(); int maxPrec = -1; for(int i=0;i<ops.length;++i) if(((XOperator) ops[i]).getPrecedence()>maxPrec) maxPrec=((XOperator) ops[i]).getPrecedence(); for(int j=-1;j<=maxPrec;++j) for(int i=0;i<ops.length;++i) if(((XOperator) ops[i]).getPrecedence()==j) println(((XOperator) ops[i]).toFullString()); }
public void printOps() { println("Known operators"); Operator ops[] = j.getOperatorSet().getOperators(); int maxPrec = -1; for(int i=0;i<ops.length;++i) if(((XOperator) ops[i]).getPrecedence()>maxPrec) maxPrec=((XOperator) ops[i]).getPrecedence(); for(int j=-1;j<=maxPrec;++j) for(int i=0;i<ops.length;++i) if(((XOperator) ops[i]).getPrecedence()==jj) println(((XOperator) ops[i]).toFullString()); }
1,116,905
public BasicSeismogramDisplay(LocalSeismogram seis, String name, VerticalSeismogramDisplay parent){ timeRegistrar = new TimeConfigRegistrar(); ampRegistrar = new AmpConfigRegistrar(); initializeDisplay(seis, name, parent); }
public BasicSeismogramDisplay(LocalSeismogram seis, String name, VerticalSeismogramDisplay parent){ timeRegistrar = new TimeConfigRegistrar(); ampRegistrar = new AmpConfigRegistrar(); initializeDisplay(seis, name, parent); }
1,116,906
public void removeAll(MouseEvent me){ logger.debug("remove all called"); parent.removeAll(me); }
public void removeAll(MouseEvent me){ logger.debug("remove all called"); parent.removeAll(); }
1,116,907
public void remove(){ display.remove(); }
public void remove(){ if(display != null) display.remove(); }
1,116,908
public Number re(Object param) throws ParseException { if (param instanceof Number) { return ((Number)param); } else if (param instanceof Complex) { return new Double(((Complex)param).re()); } throw new ParseException("Invalid parameter type"); }
public Number re(Object param) throws ParseException { if (param instanceof Complex) return new Double(((Complex)param).re()); else if (param instanceof Number) return ((Number)param); } else if (param instanceof Complex) { return new Double(((Complex)param).re()); } throw new ParseException("Invalid parameter type"); }
1,116,909
public Number re(Object param) throws ParseException { if (param instanceof Number) { return ((Number)param); } else if (param instanceof Complex) { return new Double(((Complex)param).re()); } throw new ParseException("Invalid parameter type"); }
public Number re(Object param) throws ParseException { if (param instanceof Number) { return ((Number)param); } else if (param instanceof Complex) { return new Double(((Complex)param).re()); } throw new ParseException("Invalid parameter type"); }
1,116,910
public void validate(Object obj, Errors errors) { if (obj==null) { errors.reject("user.error.nullpointer", "Null user received"); } else { User user = (User) obj; validatePrincipal(user.getCredential(), errors); } }
public void validate(Object obj, Errors errors) { if (obj==null) { errors.reject("user.error.nullpointer", "Null user received"); } else { User user = (User) obj; } }
1,116,911
private String getCommand() throws IOException { String s; if (br == null) return null; if ( (s = br.readLine()) == null) return null; if( s.equals("rules")) { j.dv.printDiffRules(); System.out.println("dJEPdx - Enter q to quit, rules to print the differentation rules,\ndiff(x^2,x) to differentiate,\neval(x^y,x,2,y,3) to evaluate"); System.out.print(prompt); return getCommand(); } if (s.equals("q") || s.equals("quit") || s.equals("exit")) return null; return s; }
private String getCommand() throws IOException { String s; if (br == null) return null; if ( (s = br.readLine()) == null) return null; if( s.equals("rules")) { j.getDifferentationVisitor().printDiffRules(); System.out.println("dJEPdx - Enter q to quit, rules to print the differentation rules,\ndiff(x^2,x) to differentiate,\neval(x^y,x,2,y,3) to evaluate"); System.out.print(prompt); return getCommand(); } if (s.equals("q") || s.equals("quit") || s.equals("exit")) return null; return s; }
1,116,912
public void initialise() { j = new DJep(); j.addStandardConstants(); j.addStandardFunctions(); j.addComplex(); j.setAllowUndeclared(true); j.setAllowAssignment(true); j.setImplicitMul(true); j.dv.addStandardDiffRules(); //j.setTraverse(true); }
public void initialise() { j = new DJep(); j.addStandardConstants(); j.addStandardFunctions(); j.addComplex(); j.setAllowUndeclared(true); j.setAllowAssignment(true); j.setImplicitMul(true); j.addStandardDiffRules(); //j.setTraverse(true); }
1,116,913
public void processEquation(Node node) { try { System.out.print("fun:\t\t"); j.println(node); Node processed = j.commandv.process(node,j); System.out.print("Processed:\t"); j.println(processed); Node simp = j.simplify(processed); System.out.print("Simplified:\t"); j.println(simp); System.out.print("Full Brackets:\t"); j.pv.setFullBrackets(true); j.println(simp); j.pv.setFullBrackets(false); try { Object res = j.evaluate(simp); System.out.println("Value:\t"+res.toString()); } catch(Exception e2) { System.out.println("Value:\tnull "+e2.getMessage()); } // Node diff = dv.differentiate(simp,"x"); // System.out.print("dfun/dx:\t"); // bpv.println(diff); // simp = sv.simplify(diff); // System.out.print("Simplified:\t"); // bpv.println(simp); System.out.println("Variables"); ((DSymbolTable) j.getSymbolTable()).print(j.pv); } catch(ParseException e1) { System.out.println("Parse Error: "+e1.getMessage()); } catch(IllegalArgumentException e2) { System.out.println(e2.getMessage()); } catch(Exception e3) { System.out.println(e3.getMessage()); } }
public void processEquation(Node node) { try { System.out.print("fun:\t\t"); j.println(node); Node processed = j.preprocess(node); System.out.print("Processed:\t"); j.println(processed); Node simp = j.simplify(processed); System.out.print("Simplified:\t"); j.println(simp); System.out.print("Full Brackets:\t"); j.pv.setFullBrackets(true); j.println(simp); j.pv.setFullBrackets(false); try { Object res = j.evaluate(simp); System.out.println("Value:\t"+res.toString()); } catch(Exception e2) { System.out.println("Value:\tnull "+e2.getMessage()); } // Node diff = dv.differentiate(simp,"x"); // System.out.print("dfun/dx:\t"); // bpv.println(diff); // simp = sv.simplify(diff); // System.out.print("Simplified:\t"); // bpv.println(simp); System.out.println("Variables"); ((DSymbolTable) j.getSymbolTable()).print(j.pv); } catch(ParseException e1) { System.out.println("Parse Error: "+e1.getMessage()); } catch(IllegalArgumentException e2) { System.out.println(e2.getMessage()); } catch(Exception e3) { System.out.println(e3.getMessage()); } }
1,116,914
public void processEquation(Node node) { try { System.out.print("fun:\t\t"); j.println(node); Node processed = j.commandv.process(node,j); System.out.print("Processed:\t"); j.println(processed); Node simp = j.simplify(processed); System.out.print("Simplified:\t"); j.println(simp); System.out.print("Full Brackets:\t"); j.pv.setFullBrackets(true); j.println(simp); j.pv.setFullBrackets(false); try { Object res = j.evaluate(simp); System.out.println("Value:\t"+res.toString()); } catch(Exception e2) { System.out.println("Value:\tnull "+e2.getMessage()); } // Node diff = dv.differentiate(simp,"x"); // System.out.print("dfun/dx:\t"); // bpv.println(diff); // simp = sv.simplify(diff); // System.out.print("Simplified:\t"); // bpv.println(simp); System.out.println("Variables"); ((DSymbolTable) j.getSymbolTable()).print(j.pv); } catch(ParseException e1) { System.out.println("Parse Error: "+e1.getMessage()); } catch(IllegalArgumentException e2) { System.out.println(e2.getMessage()); } catch(Exception e3) { System.out.println(e3.getMessage()); } }
public void processEquation(Node node) { try { System.out.print("fun:\t\t"); j.println(node); Node processed = j.commandv.process(node,j); System.out.print("Processed:\t"); j.println(processed); Node simp = j.simplify(processed); System.out.print("Simplified:\t"); j.println(simp); System.out.print("Full Brackets:\t"); j.getPrintVisitor().setFullBrackets(true); j.println(simp); j.pv.setFullBrackets(false); try { Object res = j.evaluate(simp); System.out.println("Value:\t"+res.toString()); } catch(Exception e2) { System.out.println("Value:\tnull "+e2.getMessage()); } // Node diff = dv.differentiate(simp,"x"); // System.out.print("dfun/dx:\t"); // bpv.println(diff); // simp = sv.simplify(diff); // System.out.print("Simplified:\t"); // bpv.println(simp); System.out.println("Variables"); ((DSymbolTable) j.getSymbolTable()).print(j.pv); } catch(ParseException e1) { System.out.println("Parse Error: "+e1.getMessage()); } catch(IllegalArgumentException e2) { System.out.println(e2.getMessage()); } catch(Exception e3) { System.out.println(e3.getMessage()); } }
1,116,915
public void processEquation(Node node) { try { System.out.print("fun:\t\t"); j.println(node); Node processed = j.commandv.process(node,j); System.out.print("Processed:\t"); j.println(processed); Node simp = j.simplify(processed); System.out.print("Simplified:\t"); j.println(simp); System.out.print("Full Brackets:\t"); j.pv.setFullBrackets(true); j.println(simp); j.pv.setFullBrackets(false); try { Object res = j.evaluate(simp); System.out.println("Value:\t"+res.toString()); } catch(Exception e2) { System.out.println("Value:\tnull "+e2.getMessage()); } // Node diff = dv.differentiate(simp,"x"); // System.out.print("dfun/dx:\t"); // bpv.println(diff); // simp = sv.simplify(diff); // System.out.print("Simplified:\t"); // bpv.println(simp); System.out.println("Variables"); ((DSymbolTable) j.getSymbolTable()).print(j.pv); } catch(ParseException e1) { System.out.println("Parse Error: "+e1.getMessage()); } catch(IllegalArgumentException e2) { System.out.println(e2.getMessage()); } catch(Exception e3) { System.out.println(e3.getMessage()); } }
public void processEquation(Node node) { try { System.out.print("fun:\t\t"); j.println(node); Node processed = j.commandv.process(node,j); System.out.print("Processed:\t"); j.println(processed); Node simp = j.simplify(processed); System.out.print("Simplified:\t"); j.println(simp); System.out.print("Full Brackets:\t"); j.pv.setFullBrackets(true); j.println(simp); j.getPrintVisitor().setFullBrackets(false); try { Object res = j.evaluate(simp); System.out.println("Value:\t"+res.toString()); } catch(Exception e2) { System.out.println("Value:\tnull "+e2.getMessage()); } // Node diff = dv.differentiate(simp,"x"); // System.out.print("dfun/dx:\t"); // bpv.println(diff); // simp = sv.simplify(diff); // System.out.print("Simplified:\t"); // bpv.println(simp); System.out.println("Variables"); ((DSymbolTable) j.getSymbolTable()).print(j.pv); } catch(ParseException e1) { System.out.println("Parse Error: "+e1.getMessage()); } catch(IllegalArgumentException e2) { System.out.println(e2.getMessage()); } catch(Exception e3) { System.out.println(e3.getMessage()); } }
1,116,916
public void processEquation(Node node) { try { System.out.print("fun:\t\t"); j.println(node); Node processed = j.commandv.process(node,j); System.out.print("Processed:\t"); j.println(processed); Node simp = j.simplify(processed); System.out.print("Simplified:\t"); j.println(simp); System.out.print("Full Brackets:\t"); j.pv.setFullBrackets(true); j.println(simp); j.pv.setFullBrackets(false); try { Object res = j.evaluate(simp); System.out.println("Value:\t"+res.toString()); } catch(Exception e2) { System.out.println("Value:\tnull "+e2.getMessage()); } // Node diff = dv.differentiate(simp,"x"); // System.out.print("dfun/dx:\t"); // bpv.println(diff); // simp = sv.simplify(diff); // System.out.print("Simplified:\t"); // bpv.println(simp); System.out.println("Variables"); ((DSymbolTable) j.getSymbolTable()).print(j.pv); } catch(ParseException e1) { System.out.println("Parse Error: "+e1.getMessage()); } catch(IllegalArgumentException e2) { System.out.println(e2.getMessage()); } catch(Exception e3) { System.out.println(e3.getMessage()); } }
public void processEquation(Node node) { try { System.out.print("fun:\t\t"); j.println(node); Node processed = j.commandv.process(node,j); System.out.print("Processed:\t"); j.println(processed); Node simp = j.simplify(processed); System.out.print("Simplified:\t"); j.println(simp); System.out.print("Full Brackets:\t"); j.pv.setFullBrackets(true); j.println(simp); j.pv.setFullBrackets(false); try { Object res = j.evaluate(simp); System.out.println("Value:\t"+res.toString()); } catch(Exception e2) { System.out.println("Value:\tnull "+e2.getMessage()); } // Node diff = dv.differentiate(simp,"x"); // System.out.print("dfun/dx:\t"); // bpv.println(diff); // simp = sv.simplify(diff); // System.out.print("Simplified:\t"); // bpv.println(simp); System.out.println("Variables"); ((DSymbolTable) j.getSymbolTable()).print(j.getPrintVisitor()); } catch(ParseException e1) { System.out.println("Parse Error: "+e1.getMessage()); } catch(IllegalArgumentException e2) { System.out.println(e2.getMessage()); } catch(Exception e3) { System.out.println(e3.getMessage()); } }
1,116,917
public Object div(Object param1, Object param2) throws ParseException { if (param1 instanceof Number) { if (param2 instanceof Number) return div((Number)param1, (Number)param2); else if (param2 instanceof Complex) return div((Number)param1, (Complex)param2); else if (param2 instanceof Vector) return div((Number)param1, (Vector)param2); } else if (param1 instanceof Complex) { if (param2 instanceof Number) return div((Complex)param1, (Number)param2); else if (param2 instanceof Complex) return div((Complex)param1, (Complex)param2); else if (param2 instanceof Vector) return div((Complex)param1, (Vector)param2); } else if (param1 instanceof Vector) { if (param2 instanceof Number) return div((Vector)param1, (Number)param2); else if (param2 instanceof Complex) return div((Vector)param1, (Complex)param2); } throw new ParseException("Invalid parameter type"); }
public Object div(Object param1, Object param2) throws ParseException { if (param1 instanceof Complex) { if (param2 instanceof Number) return div((Number)param1, (Number)param2); else if (param2 instanceof Complex) return div((Number)param1, (Complex)param2); else if (param2 instanceof Vector) return div((Number)param1, (Vector)param2); } else if (param1 instanceof Complex) { if (param2 instanceof Number) return div((Complex)param1, (Number)param2); else if (param2 instanceof Complex) return div((Complex)param1, (Complex)param2); else if (param2 instanceof Vector) return div((Complex)param1, (Vector)param2); } else if (param1 instanceof Vector) { if (param2 instanceof Number) return div((Vector)param1, (Number)param2); else if (param2 instanceof Complex) return div((Vector)param1, (Complex)param2); } throw new ParseException("Invalid parameter type"); }
1,116,919
public Object div(Object param1, Object param2) throws ParseException { if (param1 instanceof Number) { if (param2 instanceof Number) return div((Number)param1, (Number)param2); else if (param2 instanceof Complex) return div((Number)param1, (Complex)param2); else if (param2 instanceof Vector) return div((Number)param1, (Vector)param2); } else if (param1 instanceof Complex) { if (param2 instanceof Number) return div((Complex)param1, (Number)param2); else if (param2 instanceof Complex) return div((Complex)param1, (Complex)param2); else if (param2 instanceof Vector) return div((Complex)param1, (Vector)param2); } else if (param1 instanceof Vector) { if (param2 instanceof Number) return div((Vector)param1, (Number)param2); else if (param2 instanceof Complex) return div((Vector)param1, (Complex)param2); } throw new ParseException("Invalid parameter type"); }
public Object div(Object param1, Object param2) throws ParseException { if (param1 instanceof Number) { if (param2 instanceof Complex) return div((Complex)param1, (Complex)param2); else if (param2 instanceof Number) return div((Complex)param1, (Number)param2); else if (param2 instanceof Vector) return div((Complex)param1, (Vector)param2); } else if (param1 instanceof Number) { if (param2 instanceof Complex) return div((Number)param1, (Complex)param2); else if (param2 instanceof Number) return div((Number)param1, (Number)param2); else if (param2 instanceof Complex) return div((Number)param1, (Complex)param2); else if (param2 instanceof Vector) return div((Number)param1, (Vector)param2); } else if (param1 instanceof Complex) { if (param2 instanceof Complex) return div((Complex)param1, (Complex)param2); else if (param2 instanceof Number) return div((Complex)param1, (Number)param2); else if (param2 instanceof Vector) return div((Complex)param1, (Vector)param2); } else if (param1 instanceof Number) { if (param2 instanceof Complex) return div((Number)param1, (Complex)param2); else if (param2 instanceof Number) return div((Complex)param1, (Number)param2); else if (param2 instanceof Complex) return div((Complex)param1, (Complex)param2); else if (param2 instanceof Vector) return div((Complex)param1, (Vector)param2); } else if (param1 instanceof Vector) { if (param2 instanceof Complex) return div((Complex)param1, (Complex)param2); else if (param2 instanceof Number) return div((Complex)param1, (Number)param2); else if (param2 instanceof Vector) return div((Complex)param1, (Vector)param2); } else if (param1 instanceof Number) { if (param2 instanceof Complex) return div((Number)param1, (Complex)param2); else if (param2 instanceof Number) return div((Vector)param1, (Number)param2); else if (param2 instanceof Complex) return div((Vector)param1, (Complex)param2); } throw new ParseException("Invalid parameter type"); }
1,116,920
public Object div(Object param1, Object param2) throws ParseException { if (param1 instanceof Number) { if (param2 instanceof Number) return div((Number)param1, (Number)param2); else if (param2 instanceof Complex) return div((Number)param1, (Complex)param2); else if (param2 instanceof Vector) return div((Number)param1, (Vector)param2); } else if (param1 instanceof Complex) { if (param2 instanceof Number) return div((Complex)param1, (Number)param2); else if (param2 instanceof Complex) return div((Complex)param1, (Complex)param2); else if (param2 instanceof Vector) return div((Complex)param1, (Vector)param2); } else if (param1 instanceof Vector) { if (param2 instanceof Number) return div((Vector)param1, (Number)param2); else if (param2 instanceof Complex) return div((Vector)param1, (Complex)param2); } throw new ParseException("Invalid parameter type"); }
public Object div(Object param1, Object param2) throws ParseException { if (param1 instanceof Number) { if (param2 instanceof Number) return div((Number)param1, (Number)param2); else if (param2 instanceof Complex) return div((Number)param1, (Complex)param2); else if (param2 instanceof Vector) return div((Number)param1, (Vector)param2); } else if (param1 instanceof Complex) { if (param2 instanceof Number) return div((Complex)param1, (Number)param2); else if (param2 instanceof Complex) return div((Complex)param1, (Complex)param2); else if (param2 instanceof Vector) return div((Complex)param1, (Vector)param2); } else if (param1 instanceof Vector) { if (param2 instanceof Number) return div((Vector)param1, (Number)param2); else if (param2 instanceof Complex) return div((Vector)param1, (Complex)param2); } throw new ParseException("Invalid parameter type"); }
1,116,921
public Object div(Object param1, Object param2) throws ParseException { if (param1 instanceof Number) { if (param2 instanceof Number) return div((Number)param1, (Number)param2); else if (param2 instanceof Complex) return div((Number)param1, (Complex)param2); else if (param2 instanceof Vector) return div((Number)param1, (Vector)param2); } else if (param1 instanceof Complex) { if (param2 instanceof Number) return div((Complex)param1, (Number)param2); else if (param2 instanceof Complex) return div((Complex)param1, (Complex)param2); else if (param2 instanceof Vector) return div((Complex)param1, (Vector)param2); } else if (param1 instanceof Vector) { if (param2 instanceof Number) return div((Vector)param1, (Number)param2); else if (param2 instanceof Complex) return div((Vector)param1, (Complex)param2); } throw new ParseException("Invalid parameter type"); }
public Object div(Object param1, Object param2) throws ParseException { if (param1 instanceof Number) { if (param2 instanceof Number) return div((Number)param1, (Number)param2); else if (param2 instanceof Complex) return div((Number)param1, (Complex)param2); else if (param2 instanceof Vector) return div((Number)param1, (Vector)param2); } else if (param1 instanceof Complex) { if (param2 instanceof Number) return div((Complex)param1, (Number)param2); else if (param2 instanceof Complex) return div((Complex)param1, (Complex)param2); else if (param2 instanceof Vector) return div((Complex)param1, (Vector)param2); } else if (param1 instanceof Vector) { if (param2 instanceof Number) return div((Vector)param1, (Number)param2); else if (param2 instanceof Complex) return div((Vector)param1, (Complex)param2); } throw new ParseException("Invalid parameter type"); }
1,116,922
public Object div(Object param1, Object param2) throws ParseException { if (param1 instanceof Number) { if (param2 instanceof Number) return div((Number)param1, (Number)param2); else if (param2 instanceof Complex) return div((Number)param1, (Complex)param2); else if (param2 instanceof Vector) return div((Number)param1, (Vector)param2); } else if (param1 instanceof Complex) { if (param2 instanceof Number) return div((Complex)param1, (Number)param2); else if (param2 instanceof Complex) return div((Complex)param1, (Complex)param2); else if (param2 instanceof Vector) return div((Complex)param1, (Vector)param2); } else if (param1 instanceof Vector) { if (param2 instanceof Number) return div((Vector)param1, (Number)param2); else if (param2 instanceof Complex) return div((Vector)param1, (Complex)param2); } throw new ParseException("Invalid parameter type"); }
public Object div(Object param1, Object param2) throws ParseException { if (param1 instanceof Number) { if (param2 instanceof Complex) return div((Vector)param1, (Complex)param2); else if (param2 instanceof Number) return div((Number)param1, (Number)param2); else if (param2 instanceof Complex) return div((Number)param1, (Complex)param2); else if (param2 instanceof Vector) return div((Number)param1, (Vector)param2); } else if (param1 instanceof Complex) { if (param2 instanceof Complex) return div((Vector)param1, (Complex)param2); else if (param2 instanceof Number) return div((Complex)param1, (Number)param2); else if (param2 instanceof Complex) return div((Complex)param1, (Complex)param2); else if (param2 instanceof Vector) return div((Complex)param1, (Vector)param2); } else if (param1 instanceof Vector) { if (param2 instanceof Complex) return div((Vector)param1, (Complex)param2); else if (param2 instanceof Number) return div((Vector)param1, (Number)param2); else if (param2 instanceof Complex) return div((Vector)param1, (Complex)param2); } throw new ParseException("Invalid parameter type"); }
1,116,923
public Object div(Object param1, Object param2) throws ParseException { if (param1 instanceof Number) { if (param2 instanceof Number) return div((Number)param1, (Number)param2); else if (param2 instanceof Complex) return div((Number)param1, (Complex)param2); else if (param2 instanceof Vector) return div((Number)param1, (Vector)param2); } else if (param1 instanceof Complex) { if (param2 instanceof Number) return div((Complex)param1, (Number)param2); else if (param2 instanceof Complex) return div((Complex)param1, (Complex)param2); else if (param2 instanceof Vector) return div((Complex)param1, (Vector)param2); } else if (param1 instanceof Vector) { if (param2 instanceof Number) return div((Vector)param1, (Number)param2); else if (param2 instanceof Complex) return div((Vector)param1, (Complex)param2); } throw new ParseException("Invalid parameter type"); }
public Object div(Object param1, Object param2) throws ParseException { if (param1 instanceof Number) { if (param2 instanceof Number) return div((Number)param1, (Number)param2); else if (param2 instanceof Complex) return div((Number)param1, (Complex)param2); else if (param2 instanceof Vector) return div((Number)param1, (Vector)param2); } else if (param1 instanceof Complex) { if (param2 instanceof Number) return div((Complex)param1, (Number)param2); else if (param2 instanceof Complex) return div((Complex)param1, (Complex)param2); else if (param2 instanceof Vector) return div((Complex)param1, (Vector)param2); } else if (param1 instanceof Vector) { if (param2 instanceof Number) return div((Vector)param1, (Number)param2); else if (param2 instanceof Complex) return div((Vector)param1, (Complex)param2); } throw new ParseException("Invalid parameter type"); }
1,116,924
public void setValueAt(Object value, int row, int col) { Fermentable m = (Fermentable) data.get(row); try { switch (col) { case 0 : m.setName(value.toString()); /* if (NewSwingApp.DEBUG){ System.out.println("value is:" + value); }*/ case 1 : m.setAmount(Double.parseDouble(value.toString())); break; case 2 : m.setUnits(value.toString()); break; case 3 : m.setPppg(Double.parseDouble(value.toString())); break; case 4 : m.setLov(Double.parseDouble(value.toString())); break; case 5 : m.setCost(Double.parseDouble(value.toString())); break; case 6 : m.setPercent(Double.parseDouble(value.toString())); break; } } catch (Exception e) { }; fireTableCellUpdated(row, col); fireTableDataChanged(); app.myRecipe.calcMaltTotals(); app.displayRecipe(); }
public void setValueAt(Object value, int row, int col) { Fermentable m = (Fermentable) data.get(row); try { switch (col) { case 0 : m.setName(value.toString()); /* if (NewSwingApp.DEBUG){ System.out.println("value is:" + value); }*/ case 1 : m.setAmount(Double.parseDouble(value.toString())); break; case 2 : m.setUnits(value.toString()); break; case 3 : m.setPppg(Double.parseDouble(value.toString())); break; case 4 : m.setLov(Double.parseDouble(value.toString())); break; case 5 : m.setCost(value.toString()); break; case 6 : m.setPercent(Double.parseDouble(value.toString())); break; } } catch (Exception e) { }; fireTableCellUpdated(row, col); fireTableDataChanged(); app.myRecipe.calcMaltTotals(); app.displayRecipe(); }
1,116,925
private List<Entity> createEntities() { List<Entity> entities = new ArrayList<Entity>(); for (int i = 1; i<=10; i++) { Entity e = entityCreator.entityFactory(home, "ENTITY"+i); entities.add(e); } return entities; }
private List<Entity> createEntities() { List<Entity> entities = new ArrayList<Entity>(); for (int i = 1; i<=3; i++) { Entity e = entityCreator.entityFactory(home, "ENTITY"+i); entities.add(e); } return entities; }
1,116,926
private List<User> populateUsersAndLogs(List<Entity> entities) { List<Identity> identities = new ArrayList<Identity>(); for (int i = 1; i<=3; i++) { Identity c = userCreator.identityFactory("CRED"+i, "ALIAS"+i); identities.add(c); } List<User> users = new ArrayList<User>(); for (Entity e: entities) { Random r = new Random(); int repeat1 = r.nextInt(2); for (int i=0; i<=repeat1;i++) { User u = userCreator.userFactory(e, identities.get(i)); userDao.persistUser(u); users.add(u); int repeat2 = r.nextInt(8); for (int j=0; j<=repeat2;j++) { Date date = randomDateGenerator(r); if (logger.isDebugEnabled()) { logger.debug("Repeat ("+i+", "+j+") UserLog to: "+u+" - "+date); } // there is a very small chance to have a duplicated date here ((UserDaoImpl) userDao).createAndPersistUserLog(u, date); } } } hibernateTemplate.flush(); return users; }
private List<User> populateUsersAndLogs(List<Entity> entities) { List<Identity> identities = new ArrayList<Identity>(); for (int i = 1; i<=3; i++) { Identity c = userCreator.identityFactory("CRED"+i, "ALIAS"+i); identities.add(c); } List<User> users = new ArrayList<User>(); for (Entity e: entities) { Random r = new Random(); int repeat1 = r.nextInt(2); for (int i=0; i<=repeat1;i++) { User u = userCreator.userFactory(e, identities.get(i)); userDao.persistUser(u); users.add(u); int repeat2 = r.nextInt(8); for (int j=0; j<=repeat2;j++) { Date date = randomDateGenerator(r); if (logger.isDebugEnabled()) { logger.debug("Repeat ("+i+", "+j+") UserLog to: "+u+" - "+date); } // there is a very small chance to have a duplicated date here ((UserDaoImpl) userDao).createAndPersistUserLog(u, date); } } } hibernateTemplate.flush(); return users; }
1,116,927
private List<User> populateUsersAndLogs(List<Entity> entities) { List<Identity> identities = new ArrayList<Identity>(); for (int i = 1; i<=3; i++) { Identity c = userCreator.identityFactory("CRED"+i, "ALIAS"+i); identities.add(c); } List<User> users = new ArrayList<User>(); for (Entity e: entities) { Random r = new Random(); int repeat1 = r.nextInt(2); for (int i=0; i<=repeat1;i++) { User u = userCreator.userFactory(e, identities.get(i)); userDao.persistUser(u); users.add(u); int repeat2 = r.nextInt(8); for (int j=0; j<=repeat2;j++) { Date date = randomDateGenerator(r); if (logger.isDebugEnabled()) { logger.debug("Repeat ("+i+", "+j+") UserLog to: "+u+" - "+date); } // there is a very small chance to have a duplicated date here ((UserDaoImpl) userDao).createAndPersistUserLog(u, date); } } } hibernateTemplate.flush(); return users; }
private List<User> populateUsersAndLogs(List<Entity> entities) { List<Identity> identities = new ArrayList<Identity>(); for (int i = 1; i<=3; i++) { Identity c = userCreator.identityFactory("CRED"+i, "ALIAS"+i); identities.add(c); } List<User> users = new ArrayList<User>(); for (Entity e: entities) { Random r = new Random(); int repeat1 = r.nextInt(2); for (int i=0; i<=repeat1;i++) { User u = userCreator.userFactory(e, identities.get(i)); userDao.persistUser(u); users.add(u); int repeat2 = r.nextInt(8); for (int j=0; j<=repeat2;j++) { Date date = randomDateGenerator(r); if (logger.isDebugEnabled()) { logger.debug("Repeat ("+i+", "+j+") UserLog to: "+u+" - "+date); } // there is a very small chance to have a duplicated date here ((UserDaoImpl) userDao).createAndPersistUserLog(u, date); } } } hibernateTemplate.flush(); return users; }
1,116,928
private List<User> populateUsersAndLogs(List<Entity> entities) { List<Identity> identities = new ArrayList<Identity>(); for (int i = 1; i<=3; i++) { Identity c = userCreator.identityFactory("CRED"+i, "ALIAS"+i); identities.add(c); } List<User> users = new ArrayList<User>(); for (Entity e: entities) { Random r = new Random(); int repeat1 = r.nextInt(2); for (int i=0; i<=repeat1;i++) { User u = userCreator.userFactory(e, identities.get(i)); userDao.persistUser(u); users.add(u); int repeat2 = r.nextInt(8); for (int j=0; j<=repeat2;j++) { Date date = randomDateGenerator(r); if (logger.isDebugEnabled()) { logger.debug("Repeat ("+i+", "+j+") UserLog to: "+u+" - "+date); } // there is a very small chance to have a duplicated date here ((UserDaoImpl) userDao).createAndPersistUserLog(u, date); } } } hibernateTemplate.flush(); return users; }
private List<User> populateUsersAndLogs(List<Entity> entities) { List<Identity> identities = new ArrayList<Identity>(); for (int i = 1; i<=3; i++) { Identity c = userCreator.identityFactory("CRED"+i, "ALIAS"+i); identities.add(c); } List<User> users = new ArrayList<User>(); for (Entity e: entities) { Random r = new Random(); int repeat1 = r.nextInt(2); for (int i=0; i<=repeat1;i++) { User u = userCreator.userFactory(e, identities.get(i)); userDao.persistUser(u); users.add(u); int repeat2 = r.nextInt(8); for (int j=0; j<=repeat2;j++) { Date date = randomDateGenerator(r); if (logger.isDebugEnabled()) { logger.debug("Repeat ("+i+", "+j+") UserLog to: "+u+" - "+date); } // there is a very small chance to have a duplicated date here ((UserDaoImpl) userDao).createAndPersistUserLog(u, date); } } } hibernateTemplate.flush(); return users; }
1,116,929
private List<User> populateUsersAndLogs(List<Entity> entities) { List<Identity> identities = new ArrayList<Identity>(); for (int i = 1; i<=3; i++) { Identity c = userCreator.identityFactory("CRED"+i, "ALIAS"+i); identities.add(c); } List<User> users = new ArrayList<User>(); for (Entity e: entities) { Random r = new Random(); int repeat1 = r.nextInt(2); for (int i=0; i<=repeat1;i++) { User u = userCreator.userFactory(e, identities.get(i)); userDao.persistUser(u); users.add(u); int repeat2 = r.nextInt(8); for (int j=0; j<=repeat2;j++) { Date date = randomDateGenerator(r); if (logger.isDebugEnabled()) { logger.debug("Repeat ("+i+", "+j+") UserLog to: "+u+" - "+date); } // there is a very small chance to have a duplicated date here ((UserDaoImpl) userDao).createAndPersistUserLog(u, date); } } } hibernateTemplate.flush(); return users; }
private List<User> populateUsersAndLogs(List<Entity> entities) { List<Identity> identities = new ArrayList<Identity>(); for (int i = 1; i<=3; i++) { Identity c = userCreator.identityFactory("CRED"+i, "ALIAS"+i); identities.add(c); } List<User> users = new ArrayList<User>(); for (Entity e: entities) { Random r = new Random(); int repeat1 = r.nextInt(2); for (int i=0; i<=repeat1;i++) { User u = userCreator.userFactory(e, identities.get(i)); userDao.persistUser(u); users.add(u); int repeat2 = r.nextInt(8); for (int j=0; j<=repeat2;j++) { Date date = randomDateGenerator(r); if (logger.isDebugEnabled()) { logger.debug("Repeat ("+i+", "+j+") UserLog to: "+u+" - "+date); } // there is a very small chance to have a duplicated date here ((UserDaoImpl) userDao).createAndPersistUserLog(u, date); } } } hibernateTemplate.flush(); return users; }
1,116,930
public static SvnInfo parse(String subject, Map env, FilePath workspace, TaskListener listener) throws IOException { String cmd = DESCRIPTOR.getSvnExe()+" info --xml "+subject; listener.getLogger().println("$ "+cmd); ByteArrayOutputStream baos = new ByteArrayOutputStream(); int r = new Proc(cmd,env,baos,workspace.getLocal()).join(); if(r!=0) { // failed. to allow user to diagnose the problem, send output to log listener.getLogger().write(baos.toByteArray()); throw new IOException("revision check failed"); } SvnInfo info = new SvnInfo(); Digester digester = new Digester(); digester.push(info); digester.addBeanPropertySetter("info/entry/url"); digester.addSetProperties("info/entry","revision","revision"); // set attributes. in particular @revision try { digester.parse(new ByteArrayInputStream(baos.toByteArray())); } catch (SAXException e) { // failed. to allow user to diagnose the problem, send output to log listener.getLogger().write(baos.toByteArray()); e.printStackTrace(listener.fatalError("Failed to parse Subversion output")); throw new IOException("Unabled to parse svn info output"); } if(!info.isComplete()) throw new IOException("No revision in the svn info output"); return info; }
public static SvnInfo parse(String subject, Map env, FilePath workspace, TaskListener listener) throws IOException { String cmd = DESCRIPTOR.getSvnExe()+" info --xml "+subject; listener.getLogger().println("$ "+cmd); ByteArrayOutputStream baos = new ByteArrayOutputStream(); int r = new Proc(cmd,env,baos,workspace.getLocal()).join(); if(r!=0) { // failed. to allow user to diagnose the problem, send output to log listener.getLogger().write(baos.toByteArray()); throw new IOException("revision check failed"); } SvnInfo info = new SvnInfo(); Digester digester = new Digester(); digester.push(info); digester.addBeanPropertySetter("info/entry/url"); digester.addSetProperties("info/entry/commit","revision","revision"); // set attributes. in particular @revision try { digester.parse(new ByteArrayInputStream(baos.toByteArray())); } catch (SAXException e) { // failed. to allow user to diagnose the problem, send output to log listener.getLogger().write(baos.toByteArray()); e.printStackTrace(listener.fatalError("Failed to parse Subversion output")); throw new IOException("Unabled to parse svn info output"); } if(!info.isComplete()) throw new IOException("No revision in the svn info output"); return info; }
1,116,931
public void testPersistDefaultEntitySuccess() { simpleCoreMgr.persistDefaultEntity(defaultEntity); hibernateTemplate.flush(); List<Home> homeList = hibernateTemplate.find("from Home"); assertEquals(1, homeList.size()); Home h = homeList.get(0); assertEquals (defaultEntity.getEntity().getHome(), h); List<Entity> entityList = hibernateTemplate.find("from Entity"); assertEquals(1, entityList.size()); Entity e = entityList.get(0); assertEquals(defaultEntity.getEntity(), e); }
public void testPersistDefaultEntitySuccess() { simpleCoreMgr.persistDefaultEntity(defaultEntity); hibernateTemplate.flush(); List<Home> homeList = (ArrayList<Home>) hibernateTemplate.find("from Home"); assertEquals(1, homeList.size()); Home h = homeList.get(0); assertEquals (defaultEntity.getEntity().getHome(), h); List<Entity> entityList = hibernateTemplate.find("from Entity"); assertEquals(1, entityList.size()); Entity e = entityList.get(0); assertEquals(defaultEntity.getEntity(), e); }
1,116,932
public void testPersistDefaultEntitySuccess() { simpleCoreMgr.persistDefaultEntity(defaultEntity); hibernateTemplate.flush(); List<Home> homeList = hibernateTemplate.find("from Home"); assertEquals(1, homeList.size()); Home h = homeList.get(0); assertEquals (defaultEntity.getEntity().getHome(), h); List<Entity> entityList = hibernateTemplate.find("from Entity"); assertEquals(1, entityList.size()); Entity e = entityList.get(0); assertEquals(defaultEntity.getEntity(), e); }
public void testPersistDefaultEntitySuccess() { simpleCoreMgr.persistDefaultEntity(defaultEntity); hibernateTemplate.flush(); List<Home> homeList = hibernateTemplate.find("from Home"); assertEquals(1, homeList.size()); Home h = homeList.get(0); assertEquals (defaultEntity.getEntity().getHome(), h); List<Entity> entityList = (ArrayList<Entity>) hibernateTemplate.find("from Entity"); assertEquals(1, entityList.size()); Entity e = entityList.get(0); assertEquals(defaultEntity.getEntity(), e); }
1,116,933
private void addColumnWidthListeners() { TableColumnModel mtcm = maltTable.getColumnModel(); TableColumnModel htcm = hopsTable.getColumnModel(); //: listener that watches the width of a column PropertyChangeListener mpcl = new PropertyChangeListener() { private int columnCount = maltTable.getColumnCount(); private int[] width = new int[columnCount]; public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals("preferredWidth")) { TableColumnModel tcm = maltTable.getColumnModel(); TableColumnModel tcmt = tblMaltTotals.getColumnModel(); int colCount = tcm.getColumnCount(); // for each column, get its width for (int i = 0; i < colCount; i++) { tcmt.getColumn(i).setPreferredWidth(tcm.getColumn(i).getPreferredWidth()); } } } }; //: listener that watches the width of a column PropertyChangeListener hpcl = new PropertyChangeListener() { private int columnCount = hopsTable.getColumnCount(); private int[] width = new int[columnCount]; public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals("preferredWidth")) { TableColumnModel tcm = hopsTable.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()); } } } }; //: add the column width lister to each column for (Enumeration e = mtcm.getColumns(); e.hasMoreElements();) { TableColumn tc = (TableColumn) e.nextElement(); tc.addPropertyChangeListener(mpcl); } //: add the column width lister to each column for (Enumeration e = htcm.getColumns(); e.hasMoreElements();) { TableColumn tc = (TableColumn) e.nextElement(); tc.addPropertyChangeListener(hpcl); } }
private void addColumnWidthListeners() { TableColumnModel mtcm = maltTable.getColumnModel(); TableColumnModel htcm = hopsTable.getColumnModel(); //: listener that watches the width of a column PropertyChangeListener mpcl = new PropertyChangeListener() { private int columnCount = maltTable.getColumnCount(); private int[] width = new int[columnCount]; public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals("preferredWidth")) { TableColumnModel tcm = maltTable.getColumnModel(); TableColumnModel tcmt = tblMaltTotals.getColumnModel(); int colCount = tcm.getColumnCount(); // for each column, get its width for (int i = 0; i < colCount; i++) { tcmt.getColumn(i).setPreferredWidth(tcm.getColumn(i).getPreferredWidth()); } } } }; //: listener that watches the width of a column PropertyChangeListener hpcl = new PropertyChangeListener() { private int columnCount = hopsTable.getColumnCount(); private int[] width = new int[columnCount]; public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals("preferredWidth")) { TableColumnModel tcm = hopsTable.getColumnModel(); TableColumnModel tcmt = tblHopsTotals.getColumnModel(); int colCount = tcm.getColumnCount(); // for each column, get its width for (int i = 0; i < columnCount; i++) { tcmt.getColumn(i).setPreferredWidth(tcm.getColumn(i).getPreferredWidth()); } } } }; //: add the column width lister to each column for (Enumeration e = mtcm.getColumns(); e.hasMoreElements();) { TableColumn tc = (TableColumn) e.nextElement(); tc.addPropertyChangeListener(mpcl); } //: add the column width lister to each column for (Enumeration e = htcm.getColumns(); e.hasMoreElements();) { TableColumn tc = (TableColumn) e.nextElement(); tc.addPropertyChangeListener(hpcl); } }
1,116,934
private void addColumnWidthListeners() { TableColumnModel mtcm = maltTable.getColumnModel(); TableColumnModel htcm = hopsTable.getColumnModel(); //: listener that watches the width of a column PropertyChangeListener mpcl = new PropertyChangeListener() { private int columnCount = maltTable.getColumnCount(); private int[] width = new int[columnCount]; public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals("preferredWidth")) { TableColumnModel tcm = maltTable.getColumnModel(); TableColumnModel tcmt = tblMaltTotals.getColumnModel(); int colCount = tcm.getColumnCount(); // for each column, get its width for (int i = 0; i < colCount; i++) { tcmt.getColumn(i).setPreferredWidth(tcm.getColumn(i).getPreferredWidth()); } } } }; //: listener that watches the width of a column PropertyChangeListener hpcl = new PropertyChangeListener() { private int columnCount = hopsTable.getColumnCount(); private int[] width = new int[columnCount]; public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals("preferredWidth")) { TableColumnModel tcm = hopsTable.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()); } } } }; //: add the column width lister to each column for (Enumeration e = mtcm.getColumns(); e.hasMoreElements();) { TableColumn tc = (TableColumn) e.nextElement(); tc.addPropertyChangeListener(mpcl); } //: add the column width lister to each column for (Enumeration e = htcm.getColumns(); e.hasMoreElements();) { TableColumn tc = (TableColumn) e.nextElement(); tc.addPropertyChangeListener(hpcl); } }
private void addColumnWidthListeners() { TableColumnModel mtcm = maltTable.getColumnModel(); TableColumnModel htcm = hopsTable.getColumnModel(); //: listener that watches the width of a column PropertyChangeListener mpcl = new PropertyChangeListener() { private int columnCount = maltTable.getColumnCount(); private int[] width = new int[columnCount]; public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals("preferredWidth")) { TableColumnModel tcm = maltTable.getColumnModel(); TableColumnModel tcmt = tblMaltTotals.getColumnModel(); int colCount = tcm.getColumnCount(); // for each column, get its width for (int i = 0; i < colCount; i++) { tcmt.getColumn(i).setPreferredWidth(tcm.getColumn(i).getPreferredWidth()); } } } }; //: listener that watches the width of a column PropertyChangeListener hpcl = new PropertyChangeListener() { private int columnCount = hopsTable.getColumnCount(); private int[] width = new int[columnCount]; public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals("preferredWidth")) { TableColumnModel tcm = hopsTable.getColumnModel(); TableColumnModel tcmt = tblHopsTotals.getColumnModel(); int columnCount = tcm.getColumnCount(); // for each column, get its width for (int i = 0; i < colCount; i++) { tcmt.getColumn(i).setPreferredWidth(tcm.getColumn(i).getPreferredWidth()); } } } }; //: add the column width lister to each column for (Enumeration e = mtcm.getColumns(); e.hasMoreElements();) { TableColumn tc = (TableColumn) e.nextElement(); tc.addPropertyChangeListener(mpcl); } //: add the column width lister to each column for (Enumeration e = htcm.getColumns(); e.hasMoreElements();) { TableColumn tc = (TableColumn) e.nextElement(); tc.addPropertyChangeListener(hpcl); } }
1,116,935
public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals("preferredWidth")) { TableColumnModel tcm = hopsTable.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()); } } }
public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals("preferredWidth")) { TableColumnModel tcm = hopsTable.getColumnModel(); TableColumnModel tcmt = tblHopsTotals.getColumnModel(); int colCount = tcm.getColumnCount(); // for each column, get its width for (int i = 0; i < columnCount; i++) { tcmt.getColumn(i).setPreferredWidth(tcm.getColumn(i).getPreferredWidth()); } } }
1,116,936
public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals("preferredWidth")) { TableColumnModel tcm = hopsTable.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()); } } }
public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals("preferredWidth")) { TableColumnModel tcm = hopsTable.getColumnModel(); TableColumnModel tcmt = tblHopsTotals.getColumnModel(); int columnCount = tcm.getColumnCount(); // for each column, get its width for (int i = 0; i < colCount; i++) { tcmt.getColumn(i).setPreferredWidth(tcm.getColumn(i).getPreferredWidth()); } } }
1,116,937
public String toXml() { StringBuffer sb = new StringBuffer(); sb.append(" <MASH>\n"); sb.append(SBStringUtils.xmlElement("VOLUME", getMashTotalVol(), 4)); for (int i = 0; i < steps.size(); i++) { MashStep st = (MashStep) steps.get(i); sb.append(" <ITEM>\n"); sb.append(" <TYPE>" + st.type + "</TYPE>\n"); sb.append(" <TEMP>" + st.startTemp + "</TEMP>\n"); if (tempUnits.equals("C")) sb.append(" <DISPL_TEMP>" + SBStringUtils.format(fToC(st.startTemp), 1) + "</DISPL_TEMP>\n"); else sb.append(" <DISPL_TEMP>" + st.startTemp + "</DISPL_TEMP>\n"); sb.append(" <END_TEMP>" + st.endTemp + "</END_TEMP>\n"); if (tempUnits.equals("C")) sb.append(" <DISPL_END_TEMP>" + SBStringUtils.format(fToC(st.endTemp), 1) + "</DISPL_END_TEMP>\n"); else sb.append(" <DISPL_END_TEMP>" + st.endTemp + "</DISPL_END_TEMP>\n"); sb.append(" <MIN>" + st.minutes + "</MIN>\n"); sb.append(" <RAMP_MIN>" + st.rampMin + "</RAMP_MIN>\n"); sb.append(" <METHOD>" + st.method + "</METHOD>\n"); sb.append(" <DIRECTIONS>" + st.directions + "</DIRECTIONS>\n"); sb.append(" </ITEM>\n"); } sb.append(" </MASH>\n"); return sb.toString(); }
public String toXml() { StringBuffer sb = new StringBuffer(); sb.append(" <MASH>\n"); sb.append(SBStringUtils.xmlElement("MASH_VOLUME", getMashTotalVol(), 4)); sb.append(SBStringUtils.xmlElement("MASH_RATIO", "" + mashRatio, 4)); sb.append(SBStringUtils.xmlElement("MASH_TIME", "" + totalTime, 4)); sb.append(SBStringUtils.xmlElement("MASH_TMP_U", "" + mashTempU, 4)); if (tempUnits.equals("C")) sb.append(SBStringUtils.xmlElement("MASH_TUNLOSS_TEMP", "" + (tunLossF/1.8), 4)); else sb.append(SBStringUtils.xmlElement("MASH_TUNLOSS_TEMP", "" + tunLossF, 4)); for (int i = 0; i < steps.size(); i++) { MashStep st = (MashStep) steps.get(i); sb.append(" <ITEM>\n"); sb.append(" <TYPE>" + st.type + "</TYPE>\n"); sb.append(" <TEMP>" + st.startTemp + "</TEMP>\n"); if (tempUnits.equals("C")) sb.append(" <DISPL_TEMP>" + SBStringUtils.format(fToC(st.startTemp), 1) + "</DISPL_TEMP>\n"); else sb.append(" <DISPL_TEMP>" + st.startTemp + "</DISPL_TEMP>\n"); sb.append(" <END_TEMP>" + st.endTemp + "</END_TEMP>\n"); if (tempUnits.equals("C")) sb.append(" <DISPL_END_TEMP>" + SBStringUtils.format(fToC(st.endTemp), 1) + "</DISPL_END_TEMP>\n"); else sb.append(" <DISPL_END_TEMP>" + st.endTemp + "</DISPL_END_TEMP>\n"); sb.append(" <MIN>" + st.minutes + "</MIN>\n"); sb.append(" <RAMP_MIN>" + st.rampMin + "</RAMP_MIN>\n"); sb.append(" <METHOD>" + st.method + "</METHOD>\n"); sb.append(" <DIRECTIONS>" + st.directions + "</DIRECTIONS>\n"); sb.append(" </ITEM>\n"); } sb.append(" </MASH>\n"); return sb.toString(); }
1,116,939
protected String[] getConfigLocations() { return new String[] { "deploy/dataSource.xml", "deploy/sessionFactory.xml", "deploy/support.xml", "deploy/transaction.xml", "deploy/partner.xml"}; }
protected String[] getConfigLocations() { return new String[] { "deploy/dataSource.xml", "deploy/sessionFactory.xml", "deploy/support.xml", "deploy/transaction.xml", "deploy/core.xml"}; }
1,116,940
public Object dot(Object param1, Object param2) throws ParseException { if(param1 instanceof MVector && param2 instanceof MVector) return dot((MVector) param1,(MVector) param2); return super.mul(param1,param2); }
public Object dot(Object param1, Object param2) throws ParseException { if(param1 instanceof MVector && param2 instanceof MVector) return dot((MVector) param1,(MVector) param2); else return super.mul(param1,param2); }
1,116,941
public void parseExpression(String expression_in) { Reader reader = new StringReader(expression_in); try { // try parsing errorList.clear(); topNode = parser.parseStream(reader, this); } catch (Throwable e) { // an exception was thrown, so there is no parse tree topNode = null; // check the type of error if (e instanceof ParseException) { // the ParseException object contains additional error // information errorList.add(((ParseException)e).getErrorInfo()); } else { // if the exception was not a ParseException, it was most // likely a syntax error if (debug) { System.out.println(e.getMessage()); e.printStackTrace(); } errorList.add("Syntax error"); } } // If traversing is enabled, print a dump of the tree to // standard output if (traverse && !hasError()) { ParserVisitor v = new ParserDumpVisitor(); topNode.jjtAccept(v, null); } }
public void parseExpression(String expression_in) { Reader reader = new StringReader(expression_in); try { // try parsing errorList.removeAllElements(); topNode = parser.parseStream(reader, this); } catch (Throwable e) { // an exception was thrown, so there is no parse tree topNode = null; // check the type of error if (e instanceof ParseException) { // the ParseException object contains additional error // information errorList.add(((ParseException)e).getErrorInfo()); } else { // if the exception was not a ParseException, it was most // likely a syntax error if (debug) { System.out.println(e.getMessage()); e.printStackTrace(); } errorList.add("Syntax error"); } } // If traversing is enabled, print a dump of the tree to // standard output if (traverse && !hasError()) { ParserVisitor v = new ParserDumpVisitor(); topNode.jjtAccept(v, null); } }
1,116,942
public void parseExpression(String expression_in) { Reader reader = new StringReader(expression_in); try { // try parsing errorList.clear(); topNode = parser.parseStream(reader, this); } catch (Throwable e) { // an exception was thrown, so there is no parse tree topNode = null; // check the type of error if (e instanceof ParseException) { // the ParseException object contains additional error // information errorList.add(((ParseException)e).getErrorInfo()); } else { // if the exception was not a ParseException, it was most // likely a syntax error if (debug) { System.out.println(e.getMessage()); e.printStackTrace(); } errorList.add("Syntax error"); } } // If traversing is enabled, print a dump of the tree to // standard output if (traverse && !hasError()) { ParserVisitor v = new ParserDumpVisitor(); topNode.jjtAccept(v, null); } }
public void parseExpression(String expression_in) { Reader reader = new StringReader(expression_in); try { // try parsing errorList.clear(); topNode = parser.parseStream(reader, this); } catch (Throwable e) { // an exception was thrown, so there is no parse tree topNode = null; // check the type of error if (e instanceof ParseException) { // the ParseException object contains additional error // information errorList.addElement(((ParseException)e).getErrorInfo()); } else { // if the exception was not a ParseException, it was most // likely a syntax error if (debug) { System.out.println(e.getMessage()); e.printStackTrace(); } errorList.add("Syntax error"); } } // If traversing is enabled, print a dump of the tree to // standard output if (traverse && !hasError()) { ParserVisitor v = new ParserDumpVisitor(); topNode.jjtAccept(v, null); } }
1,116,943
public void parseExpression(String expression_in) { Reader reader = new StringReader(expression_in); try { // try parsing errorList.clear(); topNode = parser.parseStream(reader, this); } catch (Throwable e) { // an exception was thrown, so there is no parse tree topNode = null; // check the type of error if (e instanceof ParseException) { // the ParseException object contains additional error // information errorList.add(((ParseException)e).getErrorInfo()); } else { // if the exception was not a ParseException, it was most // likely a syntax error if (debug) { System.out.println(e.getMessage()); e.printStackTrace(); } errorList.add("Syntax error"); } } // If traversing is enabled, print a dump of the tree to // standard output if (traverse && !hasError()) { ParserVisitor v = new ParserDumpVisitor(); topNode.jjtAccept(v, null); } }
public void parseExpression(String expression_in) { Reader reader = new StringReader(expression_in); try { // try parsing errorList.clear(); topNode = parser.parseStream(reader, this); } catch (Throwable e) { // an exception was thrown, so there is no parse tree topNode = null; // check the type of error if (e instanceof ParseException) { // the ParseException object contains additional error // information errorList.add(((ParseException)e).getErrorInfo()); } else { // if the exception was not a ParseException, it was most // likely a syntax error if (debug) { System.out.println(e.getMessage()); e.printStackTrace(); } errorList.addElement("Syntax error"); } } // If traversing is enabled, print a dump of the tree to // standard output if (traverse && !hasError()) { ParserVisitor v = new ParserDumpVisitor(); topNode.jjtAccept(v, null); } }
1,116,944
public int getValue() { return value; }
public char getValue() { return value; }
1,116,945
public void testFindIdentities() { // write list int e = 2; int d = 3; List<UserGroup> userList = AuthorizationTestSupport.createAndPersistUserGroupList(hibernateTemplate, e, d); assertEquals(e*d, userList.size()); UserGroup parent = AuthorizationTestSupport.createUserGroup(); parent.getIdentity().setPrincipal("USER"); for (UserGroup u:userList) { UserAssociation assoc = new UserAssociation(); assoc.setParent(parent); assoc.setChild(u); u.getParents().add(assoc); } // read UserGroup userGroup = userList.get((int) Math.random()*e*d);// assertEquals(identity, authenticationDao.findIdentityByPrincipal(identity.getPrincipal()));// IdentityFilter identityFilter = new IdentityFilter();// //// assertEquals(i, authenticationDao.findIdentityByCriteria(identityFilter, "").size());//// somente um parmetro//// // assertEquals(i, authenticationDao.findIdentityByCriteria(identityFilter).size());// //// assertEquals(identity, authenticationDao.findIdentityByCriteria("where identity.principal='"+identity.getPrincipal()+"' ").get(0));//// assertEquals(identity, authenticationDao.findIdentityByCriteria(identityFilter, "");// // assertEquals(identity, authenticationDao.findIdentityByCriteria(identityFilter)); }
public void testFindIdentities() { // write list int e = 2; int d = 3; List<UserGroup> userList = AuthorizationTestSupport.createAndPersistUserGroupList(hibernateTemplate, e, d); assertEquals(e*d, userList.size()); UserGroup parent = AuthorizationTestSupport.createUserGroup(); parent.getIdentity().setPrincipal("USER"); for (UserGroup u:userList) { UserAssociation assoc = new UserAssociation(); assoc.setParent(parent); assoc.setChild(u); u.getParents().add(assoc); } // read IdentityFilter identityFilter = new IdentityFilter();// assertEquals(identity, authenticationDao.findIdentityByPrincipal(identity.getPrincipal()));// IdentityFilter identityFilter = new IdentityFilter();// //// assertEquals(i, authenticationDao.findIdentityByCriteria(identityFilter, "").size());//// somente um parmetro//// // assertEquals(i, authenticationDao.findIdentityByCriteria(identityFilter).size());// //// assertEquals(identity, authenticationDao.findIdentityByCriteria("where identity.principal='"+identity.getPrincipal()+"' ").get(0));//// assertEquals(identity, authenticationDao.findIdentityByCriteria(identityFilter, "");// // assertEquals(identity, authenticationDao.findIdentityByCriteria(identityFilter)); }
1,116,946
public MatrixNodeI preprocess( ASTFunNode node, MatrixPreprocessor visitor, MatrixJep jep, MatrixNodeFactory nf) throws ParseException { MatrixNodeI children[] = visitor.visitChildrenAsArray(node,null); 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 = jep.getOperatorSet().getCross(); BinaryOperatorI bin = (BinaryOperatorI) op.getPFMC(); Dimensions dim = bin.calcDim(lhsDim,rhsDim); return (ASTMFunNode) nf.buildOperatorNode(op,children,dim); } }
public MatrixNodeI preprocess( ASTFunNode node, MatrixPreprocessor visitor, MatrixJep jep, MatrixNodeFactory nf) throws ParseException { MatrixNodeI children[] = visitor.visitChildrenAsArray(node,null); 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 = jep.getOperatorSet().getCross(); BinaryOperatorI bin = (BinaryOperatorI) op.getPFMC(); Dimensions dim = bin.calcDim(lhsDim,rhsDim); return (ASTMFunNode) nf.buildOperatorNode(op,children,dim); } }
1,116,948
public Number im(Object param) throws ParseException { if (param instanceof Number) { return new Double(0); } else if (param instanceof Complex) { return new Double(((Complex)param).im()); } throw new ParseException("Invalid parameter type"); }
public Number im(Object param) throws ParseException { if (param instanceof Complex) return new Double(((Complex)param).im()); else if (param instanceof Number) return new Double(0); } else if (param instanceof Complex) { return new Double(((Complex)param).im()); } throw new ParseException("Invalid parameter type"); }
1,116,949
public Number im(Object param) throws ParseException { if (param instanceof Number) { return new Double(0); } else if (param instanceof Complex) { return new Double(((Complex)param).im()); } throw new ParseException("Invalid parameter type"); }
public Number im(Object param) throws ParseException { if (param instanceof Number) { return new Double(0); } else if (param instanceof Complex) { return new Double(((Complex)param).im()); } throw new ParseException("Invalid parameter type"); }
1,116,950
public PluginManager(ServletContext context) { this.context = context; rootDir = new File(Hudson.getInstance().getRootDir(),"plugins"); if(!rootDir.exists()) rootDir.mkdirs(); File[] archives = rootDir.listFiles(new FilenameFilter() { public boolean accept(File dir, String name) { return name.endsWith(".hudson-plugin"); } }); for( File arc : archives ) { try { PluginWrapper p = new PluginWrapper(this, arc); plugins.add(p); if(p.isActive()) activePlugins.add(p); } catch (IOException e) { System.err.println("Failed to load a plug-in "+arc); e.printStackTrace(); } } }
public PluginManager(ServletContext context) { this.context = context; rootDir = new File(Hudson.getInstance().getRootDir(),"plugins"); if(!rootDir.exists()) rootDir.mkdirs(); File[] archives = rootDir.listFiles(new FilenameFilter() { public boolean accept(File dir, String name) { return name.endsWith(".hudson-plugin"); } }); for( File arc : archives ) { try { PluginWrapper p = new PluginWrapper(this, arc); plugins.add(p); if(p.isActive()) activePlugins.add(p); } catch (IOException e) { System.err.println("Failed to load a plug-in "+arc); e.printStackTrace(); } } }
1,116,951
public boolean accept(File dir, String name) { return name.endsWith(".hudson-plugin"); }
public boolean accept(File dir, String name) { return name.endsWith(".hudson-plugin"); }
1,116,952
public void updateAmp(AmpEvent event){ if(event instanceof LazyAmpEvent){ ((LazyAmpEvent)event).addCalculateListener(this); }else{ setUnitRange(event.getAmp()); } }
public void updateAmp(AmpEvent event){ if(event instanceof LazyAmpEvent){ ((LazyAmpEvent)event).addCalculateListener(this); }else{ setUnitRange(event.getAmp()); } }
1,116,953
public void write(int b) throws IOException { // this call will always return at least 1 directly or after blocking. bandwidthController.getAvailableByteCount( true ); outStream.write(b); bandwidthController.markBytesUsed( 1 ); }
public void write(int b) throws IOException { // this call will always return at least 1 directly or after blocking. bandwidthController.getAvailableByteCount( 1, true, true ); outStream.write(b); bandwidthController.markBytesUsed( 1 ); }
1,116,954
public void write(int b) throws IOException { // this call will always return at least 1 directly or after blocking. bandwidthController.getAvailableByteCount( true ); outStream.write(b); bandwidthController.markBytesUsed( 1 ); }
public void write(int b) throws IOException { // this call will always return at least 1 directly or after blocking. bandwidthController.getAvailableByteCount( true ); outStream.write(b); }
1,116,955
public synchronized void doDoDelete( StaplerRequest req, StaplerResponse rsp ) throws IOException { Util.deleteRecursive(root); getParent().jobs.remove(name); rsp.sendRedirect(req.getContextPath()); }
public synchronized void doDoDelete( StaplerRequest req, StaplerResponse rsp ) throws IOException { Util.deleteRecursive(root); getParent().deleteJob(this); rsp.sendRedirect(req.getContextPath()); }
1,116,956
private void initGUI() { try { // restore the saved size and location: this.setSize(preferences.getIProperty("winWidth"), preferences.getIProperty("winHeight")); this.setLocation(preferences.getIProperty("winX"), preferences.getIProperty("winY")); imgURL = getClass().getClassLoader().getResource("ca/strangebrew/icons/sb2.gif"); icon = new ImageIcon(imgURL); this.setIconImage(icon.getImage()); this.setTitle("StrangeBrew " + version); 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}; jPanel2Layout.columnWidths = new int[]{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); { 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:"); } { brewerNameText = new JTextField(); pnlDetails.add(brewerNameText, new GridBagConstraints(1, 0, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); brewerNameText.setPreferredSize(new java.awt.Dimension(69, 20)); brewerNameText.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:"); lblEffic.setPreferredSize(new java.awt.Dimension(31, 14)); } { 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:"); lblAtten.setPreferredSize(new java.awt.Dimension(34, 14)); } { 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(); txtDate = new DatePicker(); 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.setPreferredSize(new java.awt.Dimension(73, 20)); txtDate.setDateStyle(DateFormat.SHORT); } { 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.setPreferredSize(new java.awt.Dimension(190, 20)); } { preBoilText = new JFormattedTextField(); pnlDetails.add(preBoilText, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); preBoilText.setText("Pre Boil"); preBoilText.setPreferredSize(new java.awt.Dimension(37, 20)); } { 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.setPreferredSize(new java.awt.Dimension(46, 20)); } { lblComments = new JLabel(); pnlDetails.add(lblComments, new GridBagConstraints(6, 4, 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)); spnEffic.setPreferredSize(new java.awt.Dimension(53, 18)); } { 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.#")); spnAtten.setPreferredSize(new java.awt.Dimension(49, 20)); } { 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)); spnOG.setPreferredSize(new java.awt.Dimension(67, 18)); } { 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.setPreferredSize(new java.awt.Dimension(69, 20)); 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(7, 4, 3, 2, 0.0, 0.0, GridBagConstraints.EAST, 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.setLineWrap(true); txtComments.setPreferredSize(new java.awt.Dimension(263, 40)); 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.setPreferredSize(new java.awt.Dimension(193, 20)); } { 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); } { 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.setPreferredSize(new java.awt.Dimension(22, 20)); } { 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.setPreferredSize(new java.awt.Dimension(23, 20)); } { alcMethodComboModel = new DefaultComboBoxModel(new String[]{"Volume", "Weight"}); alcMethodCombo = new JComboBox(alcMethodComboModel); pnlDetails.add(alcMethodCombo, new GridBagConstraints(9, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); alcMethodCombo.setPreferredSize(new java.awt.Dimension(58, 20)); } { ibuMethodComboModel = new DefaultComboBoxModel(new String[]{"Tinseth", "Garetz", "Rager"}); ibuMethodCombo = new JComboBox(ibuMethodComboModel); pnlDetails.add(ibuMethodCombo, new GridBagConstraints(9, 1, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); ibuMethodCombo.setPreferredSize(new java.awt.Dimension(59, 20)); } { colourMethodComboModel = new DefaultComboBoxModel(new String[]{"SRM", "EBC"}); colourMethodCombo = new JComboBox(colourMethodComboModel); pnlDetails.add(colourMethodCombo, new GridBagConstraints(9, 2, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); colourMethodCombo.setPreferredSize(new java.awt.Dimension(44, 20)); } ComboBoxModel evapMethodComboModel = new DefaultComboBoxModel(new String[] { "Constant", "Percent" }); { 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); mainToolBar = new JToolBar(); getContentPane().add(mainToolBar, BorderLayout.NORTH); mainToolBar.setFloatable(false); mainToolBar.setRollover(true); saveButton = new JButton(); mainToolBar.add(saveButton); saveButton.setMnemonic(java.awt.event.KeyEvent.VK_S); saveButton.setIcon(new ImageIcon(getClass().getClassLoader().getResource( "ca/strangebrew/icons/save.gif"))); saveButton.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent evt) { saveFile(evt); } }); jButton2 = new JButton(); mainToolBar.add(jButton2); jButton2.setIcon(new ImageIcon(getClass().getClassLoader().getResource( "ca/strangebrew/icons/find.gif"))); final JFrame owner = this; jButton2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { FindDialog fd = new FindDialog(owner); fd.setModal(true); fd.setVisible(true); } }); { lblName = new JLabel(); jPanel1.add(lblName); lblName.setText("Name:"); } { txtName = new JTextField(); jPanel1.add(txtName); txtName.setText("Name"); txtName.setPreferredSize(new java.awt.Dimension(297, 20)); } } evapMethodCombo = new JComboBox(); pnlDetails.add(evapMethodCombo, new GridBagConstraints(6, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); evapMethodCombo.setModel(evapMethodComboModel); evapMethodCombo.setPreferredSize(new java.awt.Dimension(64, 20)); colourPanel = new JPanel(); pnlDetails.add(colourPanel, new GridBagConstraints(9, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); colourPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); } { SBNotifier sbn = new SBNotifier(); stylePanel = new StylePanel(sbn); jTabbedPane1.addTab("Style", null, stylePanel, null); miscPanel = new MiscPanel(myRecipe); jTabbedPane1.addTab("Misc", null, miscPanel, null); notesPanel = new NotesPanel(); jTabbedPane1.addTab("Notes", null, notesPanel, null); dilutionPanel = new DilutionPanel(); jTabbedPane1.addTab("Dilution", null, dilutionPanel, null); mashPanel = new MashPanel(myRecipe); jTabbedPane1.addTab("Mash", null, mashPanel, null); waterPanel = new WaterPanel(); jTabbedPane1.addTab("Water", null, waterPanel, null); costPanel = new CostPanel(); jTabbedPane1.addTab("Cost", null, costPanel, null); // SBNotifier sbn = new SBNotifier(); settingsPanel = new SettingsPanel(sbn); jTabbedPane1.addTab("Settings", null, settingsPanel, 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(); 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); { maltTableModel = new MaltTableModel(this); maltTable = new JTable() { public String getToolTipText(MouseEvent e) { java.awt.Point p = e.getPoint(); int rowIndex = rowAtPoint(p); return SBStringUtils.multiLineToolTip(40, maltTableModel .getDescriptionAt(rowIndex)); } }; jScrollPane1.setViewportView(maltTable); maltTable.setModel(maltTableModel); // maltTable.setAutoCreateColumnsFromModel(false); maltTable.getTableHeader().setReorderingAllowed(false); TableColumn maltColumn = maltTable.getColumnModel().getColumn(2); // set up malt list combo maltComboBox = new JComboBox(); cmbMaltModel = new ComboModel(); maltComboBox.setModel(cmbMaltModel); maltColumn.setCellEditor(new DefaultCellEditor(maltComboBox)); // set up malt amount editor amountEditor = new SBCellEditor(new JTextField()); maltColumn = maltTable.getColumnModel().getColumn(3); maltColumn.setCellEditor(amountEditor); // set up malt units combo maltUnitsComboBox = new JComboBox(); cmbMaltUnitsModel = new ComboModel(); maltUnitsComboBox.setModel(cmbMaltUnitsModel); maltColumn = maltTable.getColumnModel().getColumn(4); maltColumn.setCellEditor(new DefaultCellEditor(maltUnitsComboBox)); } } { tblMaltTotalsModel = new DefaultTableModel(new String[][]{{""}}, new String[]{"S", "M", "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); // set up the units combobox maltTotalUnitsComboBox = new JComboBox(); maltTotalUnitsComboModel = new ComboModel(); maltTotalUnitsComboModel.setList(new Quantity().getListofUnits("weight")); maltTotalUnitsComboBox.setModel(maltTotalUnitsComboModel); TableColumn t = tblMaltTotals.getColumnModel().getColumn(4); t.setCellEditor(new DefaultCellEditor(maltTotalUnitsComboBox)); maltTotalUnitsComboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { String u = (String) maltTotalUnitsComboModel.getSelectedItem(); if (myRecipe != null) { myRecipe.setMaltUnits(u); displayRecipe(); } } }); } } { 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(592, 27)); { tlbMalt = new JToolBar(); pnlMaltButtons.add(tlbMalt); tlbMalt.setPreferredSize(new java.awt.Dimension(386, 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); maltTable.updateUI(); displayRecipe(); } } }); } { btnDelMalt = new JButton(); tlbMalt.add(btnDelMalt); btnDelMalt.setText("-"); btnDelMalt.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (myRecipe != null) { int i = maltTable.getSelectedRow(); myRecipe.delMalt(i); maltTable.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); // set up the units combobox hopsTotalUnitsComboBox = new JComboBox(); hopsTotalUnitsComboModel = new ComboModel(); hopsTotalUnitsComboModel.setList(new Quantity().getListofUnits("weight")); hopsTotalUnitsComboBox.setModel(hopsTotalUnitsComboModel); TableColumn t = tblHopsTotals.getColumnModel().getColumn(4); t.setCellEditor(new DefaultCellEditor(hopsTotalUnitsComboBox)); hopsTotalUnitsComboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { String u = (String) hopsTotalUnitsComboModel.getSelectedItem(); if (myRecipe != null) { myRecipe.setHopsUnits(u); displayRecipe(); } } }); } { jScrollPane2 = new JScrollPane(); pnlHops.add(jScrollPane2, BorderLayout.CENTER); { hopsTableModel = new HopsTableModel(this); hopsTable = new JTable() { public String getToolTipText(MouseEvent e) { java.awt.Point p = e.getPoint(); int rowIndex = rowAtPoint(p); return SBStringUtils.multiLineToolTip(40, hopsTableModel .getDescriptionAt(rowIndex)); } }; jScrollPane2.setViewportView(hopsTable); hopsTable.setModel(hopsTableModel); hopsTable.getTableHeader().setReorderingAllowed(false); TableColumn hopColumn = hopsTable.getColumnModel().getColumn(0); hopComboBox = new JComboBox(); cmbHopsModel = new ComboModel(); hopComboBox.setModel(cmbHopsModel); hopColumn.setCellEditor(new DefaultCellEditor(hopComboBox)); // set up hop units combo hopsUnitsComboBox = new JComboBox(); cmbHopsUnitsModel = new ComboModel(); hopsUnitsComboBox.setModel(cmbHopsUnitsModel); hopColumn = hopsTable.getColumnModel().getColumn(4); hopColumn.setCellEditor(new DefaultCellEditor(hopsUnitsComboBox)); // set up hop type combo String[] forms = {"Leaf", "Pellet", "Plug"}; JComboBox hopsFormComboBox = new JComboBox(forms); hopColumn = hopsTable.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 = hopsTable.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(413, 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); hopsTable.updateUI(); displayRecipe(); } } }); } { btnDelHop = new JButton(); tlbHops.add(btnDelHop); btnDelHop.setText("-"); btnDelHop.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (myRecipe != null) { int i = hopsTable.getSelectedRow(); myRecipe.delHop(i); hopsTable.updateUI(); displayRecipe(); } } }); } } } } { statusPanel = new JPanel(); FlowLayout statusPanelLayout = new FlowLayout(); statusPanelLayout.setAlignment(FlowLayout.LEFT); statusPanelLayout.setHgap(2); statusPanelLayout.setVgap(2); statusPanel.setLayout(statusPanelLayout); pnlMain.add(statusPanel, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); { fileNamePanel = new JPanel(); statusPanel.add(fileNamePanel); fileNamePanel.setBorder(BorderFactory .createBevelBorder(BevelBorder.LOWERED)); { fileNameLabel = new JLabel(); fileNamePanel.add(fileNameLabel); fileNameLabel.setText("File Name"); fileNameLabel.setFont(new java.awt.Font("Dialog", 1, 10)); } } { ibuMethodPanel = new JPanel(); statusPanel.add(ibuMethodPanel); ibuMethodPanel.setBorder(BorderFactory .createBevelBorder(BevelBorder.LOWERED)); { ibuMethodLabel = new JLabel(); ibuMethodPanel.add(ibuMethodLabel); ibuMethodLabel.setText("IBU Method:"); ibuMethodLabel.setFont(new java.awt.Font("Dialog", 1, 10)); } } { alcMethodPanel = new JPanel(); statusPanel.add(alcMethodPanel); alcMethodPanel.setBorder(BorderFactory .createBevelBorder(BevelBorder.LOWERED)); { alcMethodLabel = new JLabel(); alcMethodPanel.add(alcMethodLabel); alcMethodLabel.setText("Alc Method:"); alcMethodLabel.setFont(new java.awt.Font("Dialog", 1, 10)); } } } } { jMenuBar1 = new JMenuBar(); setJMenuBar(jMenuBar1); { fileMenu = new JMenu(); jMenuBar1.add(fileMenu); fileMenu.setText("File"); { newFileMenuItem = new JMenuItem(); fileMenu.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(); myRecipe.setVersion(version); currentFile = null; attachRecipeData(); displayRecipe(); } }); } { openFileMenuItem = new JMenuItem(); fileMenu.add(openFileMenuItem); openFileMenuItem.setText("Open"); openFileMenuItem.setAccelerator(KeyStroke.getKeyStroke( KeyEvent.VK_O, ActionEvent.CTRL_MASK)); openFileMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // Show open dialog; this method does // not return until the dialog is closed String[] ext = {"xml", "qbrew", "rec"}; String desc = "StrangBrew and importable formats"; sbFileFilter openFileFilter = new sbFileFilter(ext, desc); // fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); fileChooser.setFileFilter(openFileFilter); int returnVal = fileChooser.showOpenDialog(jMenuBar1); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); Debug.print("Opening: " + file.getName() + ".\n"); OpenImport oi = new OpenImport(); myRecipe = oi.openFile(file); if (oi.getFileType().equals("")){ JOptionPane.showMessageDialog( null, "The file you've tried to open isn't a recognized format. \n" + "You can open: \n" + "StrangeBrew 1.x and Java files (.xml)\n" + "QBrew files (.qbrew)\n" + "BeerXML files (.xml)\n" + "Promash files (.rec)", "Unrecognized Format!", JOptionPane.INFORMATION_MESSAGE); } if (oi.getFileType().equals("beerxml")){ JOptionPane.showMessageDialog( null, "The file you've opened is in BeerXML format. It may contain \n" + "several recipes. Only the first recipe is opened. Use the Find \n" + "dialog to open other recipes in a BeerXML file.", "BeerXML!", JOptionPane.INFORMATION_MESSAGE); } myRecipe.setVersion(version); myRecipe.calcMaltTotals(); myRecipe.calcHopsTotals(); myRecipe.mash.calcMashSchedule(); checkIngredientsInDB(); attachRecipeData(); currentFile = file; displayRecipe(); } else { Debug.print("Open command cancelled by user.\n"); } } }); } { imgURL = getClass().getClassLoader().getResource("ca/strangebrew/icons/find.gif"); icon = new ImageIcon(imgURL); findFileMenuItem = new JMenuItem("Find", icon); findFileMenuItem.setAccelerator(KeyStroke.getKeyStroke( KeyEvent.VK_F, ActionEvent.CTRL_MASK)); fileMenu.add(findFileMenuItem); final JFrame owner = this; findFileMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // open the find dialog FindDialog fd = new FindDialog(owner); fd.setModal(true); fd.setVisible(true); } }); } { imgURL = getClass().getClassLoader().getResource("ca/strangebrew/icons/save.gif"); icon = new ImageIcon(imgURL); saveMenuItem = new JMenuItem("Save", icon); fileMenu.add(saveMenuItem); saveMenuItem.setAccelerator(KeyStroke.getKeyStroke( KeyEvent.VK_S, ActionEvent.CTRL_MASK)); saveMenuItem.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent evt) { saveFile(evt); } }); } { imgURL = getClass().getClassLoader().getResource("ca/strangebrew/icons/saveas.gif"); icon = new ImageIcon(imgURL); saveAsMenuItem = new JMenuItem("Save As ...", icon); fileMenu.add(saveAsMenuItem); saveAsMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { saveAs(); } }); } { exportMenu = new JMenu(); fileMenu.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 String[] ext = {"html", "htm"}; sbFileFilter saveFileFilter = new sbFileFilter(ext, "HTML"); fileChooser.setFileFilter(saveFileFilter); 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, "recipeToHtml.xslt", null); } catch (Exception e) { showError(e); } } else { Debug.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 String[] ext = {"txt"}; sbFileFilter saveFileFilter = new sbFileFilter(ext, "Text"); fileChooser.setFileFilter(saveFileFilter); 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) { showError(e); } } else { Debug.print("Export text command cancelled by user.\n"); } } }); } } { JMenuItem clipboardMenuItem = new JMenuItem("Copy to Clipboard"); fileMenu.add(clipboardMenuItem); clipboardMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // Copy current recipe to clipboard Clipboard clipboard = getToolkit ().getSystemClipboard (); StringSelection s = new StringSelection(myRecipe.toText()); clipboard.setContents(s, s); } }); JMenuItem printMenuItem = new JMenuItem("Print..."); fileMenu.add(printMenuItem); final JFrame owner = this; printMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { PrintDialog pd = new PrintDialog(owner); pd.setModal(true); pd.setVisible(true); } }); } { jSeparator2 = new JSeparator(); fileMenu.add(jSeparator2); } { exitMenuItem = new JMenuItem(); fileMenu.add(exitMenuItem); exitMenuItem.setText("Exit"); exitMenuItem.setAccelerator(KeyStroke.getKeyStroke( KeyEvent.VK_Q, ActionEvent.CTRL_MASK)); final JFrame owner = this; exitMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // exit program processWindowEvent(new WindowEvent(owner,WindowEvent.WINDOW_CLOSING)); 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); } } { mnuTools = new JMenu(); jMenuBar1.add(mnuTools); mnuTools.setText("Tools"); { final JFrame owner = this; JMenuItem scalRecipeMenuItem = new JMenuItem(); mnuTools.add(scalRecipeMenuItem); scalRecipeMenuItem.setText("Scale Recipe..."); scalRecipeMenuItem.setAccelerator(KeyStroke.getKeyStroke( KeyEvent.VK_R, ActionEvent.CTRL_MASK)); scalRecipeMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { ScaleRecipeDialog scaleRecipe = new ScaleRecipeDialog(owner); scaleRecipe.setModal(true); scaleRecipe.setVisible(true); } }); JMenuItem maltPercentMenuItem = new JMenuItem(); mnuTools.add(maltPercentMenuItem); maltPercentMenuItem.setText("Malt Percent..."); maltPercentMenuItem.setAccelerator(KeyStroke.getKeyStroke( KeyEvent.VK_M, ActionEvent.CTRL_MASK)); maltPercentMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { MaltPercentDialog maltPercent = new MaltPercentDialog(owner); maltPercent.setModal(true); maltPercent.setVisible(true); } }); } } { jMenu5 = new JMenu(); jMenuBar1.add(jMenu5); jMenu5.setText("Help"); { helpMenuItem = new JMenuItem(); jMenu5.add(helpMenuItem); helpMenuItem.setText("Help"); helpMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { String urlString = "file://" + appRoot + slash + "help" + slash + "index.html"; Debug.print(urlString); AbstractLogger logger = new SystemLogger(); BrowserLauncher launcher; try { launcher = new BrowserLauncher(logger); BrowserLauncherRunner runner = new BrowserLauncherRunner( launcher, urlString, null); Thread launcherThread = new Thread(runner); launcherThread.start(); } catch (BrowserLaunchingInitializingException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (UnsupportedOperatingSystemException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }); } { 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, version); aboutDlg.setVisible(true); } }); } } } } catch (Exception e) { e.printStackTrace(); } }
private void initGUI() { try { // restore the saved size and location: this.setSize(preferences.getIProperty("winWidth"), preferences.getIProperty("winHeight")); this.setLocation(preferences.getIProperty("winX"), preferences.getIProperty("winY")); imgURL = getClass().getClassLoader().getResource("ca/strangebrew/icons/sb2.gif"); icon = new ImageIcon(imgURL); this.setIconImage(icon.getImage()); this.setTitle("StrangeBrew " + version); 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}; jPanel2Layout.columnWidths = new int[]{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); { 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:"); } { brewerNameText = new JTextField(); pnlDetails.add(brewerNameText, new GridBagConstraints(1, 0, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); brewerNameText.setPreferredSize(new java.awt.Dimension(69, 20)); brewerNameText.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:"); lblEffic.setPreferredSize(new java.awt.Dimension(31, 14)); } { 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:"); lblAtten.setPreferredSize(new java.awt.Dimension(34, 14)); } { 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(); txtDate = new DatePicker(); 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.setPreferredSize(new java.awt.Dimension(73, 20)); txtDate.setDateStyle(DateFormat.SHORT); } { 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.setPreferredSize(new java.awt.Dimension(190, 20)); } { preBoilText = new JFormattedTextField(); pnlDetails.add(preBoilText, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); preBoilText.setText("Pre Boil"); preBoilText.setPreferredSize(new java.awt.Dimension(37, 20)); } { 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.setPreferredSize(new java.awt.Dimension(46, 20)); } { lblComments = new JLabel(); pnlDetails.add(lblComments, new GridBagConstraints(6, 4, 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)); spnEffic.setPreferredSize(new java.awt.Dimension(53, 18)); } { 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.#")); spnAtten.setPreferredSize(new java.awt.Dimension(49, 20)); } { 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)); spnOG.setPreferredSize(new java.awt.Dimension(67, 18)); } { 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.setPreferredSize(new java.awt.Dimension(69, 20)); 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(7, 4, 3, 2, 0.0, 0.0, GridBagConstraints.EAST, 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.setLineWrap(true); txtComments.setPreferredSize(new java.awt.Dimension(263, 40)); 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.setPreferredSize(new java.awt.Dimension(193, 20)); } { 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); } { 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.setPreferredSize(new java.awt.Dimension(22, 20)); } { 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.setPreferredSize(new java.awt.Dimension(23, 20)); } { alcMethodComboModel = new DefaultComboBoxModel(new String[]{"Volume", "Weight"}); alcMethodCombo = new JComboBox(alcMethodComboModel); pnlDetails.add(alcMethodCombo, new GridBagConstraints(9, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); alcMethodCombo.setPreferredSize(new java.awt.Dimension(58, 20)); } { ibuMethodComboModel = new DefaultComboBoxModel(new String[]{"Tinseth", "Garetz", "Rager"}); ibuMethodCombo = new JComboBox(ibuMethodComboModel); pnlDetails.add(ibuMethodCombo, new GridBagConstraints(9, 1, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); ibuMethodCombo.setPreferredSize(new java.awt.Dimension(59, 20)); } { colourMethodComboModel = new DefaultComboBoxModel(new String[]{"SRM", "EBC"}); colourMethodCombo = new JComboBox(colourMethodComboModel); pnlDetails.add(colourMethodCombo, new GridBagConstraints(9, 2, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); colourMethodCombo.setPreferredSize(new java.awt.Dimension(44, 20)); } ComboBoxModel evapMethodComboModel = new DefaultComboBoxModel(new String[] { "Constant", "Percent" }); { 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); mainToolBar = new JToolBar(); getContentPane().add(mainToolBar, BorderLayout.NORTH); mainToolBar.setFloatable(false); mainToolBar.setRollover(true); saveButton = new JButton(); mainToolBar.add(saveButton); saveButton.setMnemonic(java.awt.event.KeyEvent.VK_S); saveButton.setIcon(new ImageIcon(getClass().getClassLoader().getResource( "ca/strangebrew/icons/save.gif"))); saveButton.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent evt) { saveFile(evt); } }); jButton2 = new JButton(); mainToolBar.add(jButton2); jButton2.setIcon(new ImageIcon(getClass().getClassLoader().getResource( "ca/strangebrew/icons/find.gif"))); final JFrame owner = this; jButton2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { FindDialog fd = new FindDialog(owner); fd.setModal(true); fd.setVisible(true); } }); { lblName = new JLabel(); jPanel1.add(lblName); lblName.setText("Name:"); } { txtName = new JTextField(); jPanel1.add(txtName); txtName.setText("Name"); txtName.setPreferredSize(new java.awt.Dimension(297, 20)); } } evapMethodCombo = new JComboBox(); pnlDetails.add(evapMethodCombo, new GridBagConstraints(6, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); evapMethodCombo.setModel(evapMethodComboModel); evapMethodCombo.setPreferredSize(new java.awt.Dimension(64, 20)); colourPanel = new JPanel(); pnlDetails.add(colourPanel, new GridBagConstraints(9, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); colourPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); } { SBNotifier sbn = new SBNotifier(); stylePanel = new StylePanel(sbn); jTabbedPane1.addTab("Style", null, stylePanel, null); miscPanel = new MiscPanel(myRecipe); jTabbedPane1.addTab("Misc", null, miscPanel, null); notesPanel = new NotesPanel(); jTabbedPane1.addTab("Notes", null, notesPanel, null); dilutionPanel = new DilutionPanel(); jTabbedPane1.addTab("Dilution", null, dilutionPanel, null); mashPanel = new MashPanel(myRecipe); jTabbedPane1.addTab("Mash", null, mashPanel, null); waterPanel = new WaterPanel(); jTabbedPane1.addTab("Water", null, waterPanel, null); costPanel = new CostPanel(); jTabbedPane1.addTab("Cost", null, costPanel, null); // SBNotifier sbn = new SBNotifier(); settingsPanel = new SettingsPanel(sbn); jTabbedPane1.addTab("Settings", null, settingsPanel, 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(); 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); { maltTableModel = new MaltTableModel(this); maltTable = new JTable() { public String getToolTipText(MouseEvent e) { java.awt.Point p = e.getPoint(); int rowIndex = rowAtPoint(p); return SBStringUtils.multiLineToolTip(40, maltTableModel .getDescriptionAt(rowIndex)); } }; jScrollPane1.setViewportView(maltTable); maltTable.setModel(maltTableModel); // maltTable.setAutoCreateColumnsFromModel(false); maltTable.getTableHeader().setReorderingAllowed(false); TableColumn maltColumn = maltTable.getColumnModel().getColumn(2); // set up malt list combo maltComboBox = new JComboBox(); cmbMaltModel = new ComboModel(); maltComboBox.setModel(cmbMaltModel); maltColumn.setCellEditor(new DefaultCellEditor(maltComboBox)); // set up malt amount editor amountEditor = new SBCellEditor(new JTextField()); maltColumn = maltTable.getColumnModel().getColumn(3); maltColumn.setCellEditor(amountEditor); // set up malt units combo maltUnitsComboBox = new JComboBox(); cmbMaltUnitsModel = new ComboModel(); maltUnitsComboBox.setModel(cmbMaltUnitsModel); maltColumn = maltTable.getColumnModel().getColumn(4); maltColumn.setCellEditor(new DefaultCellEditor(maltUnitsComboBox)); } } { tblMaltTotalsModel = new DefaultTableModel(new String[][]{{""}}, new String[]{"S", "M", "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); // set up the units combobox maltTotalUnitsComboBox = new JComboBox(); maltTotalUnitsComboModel = new ComboModel(); maltTotalUnitsComboModel.setList(new Quantity().getListofUnits("weight")); maltTotalUnitsComboBox.setModel(maltTotalUnitsComboModel); TableColumn t = tblMaltTotals.getColumnModel().getColumn(4); t.setCellEditor(new DefaultCellEditor(maltTotalUnitsComboBox)); maltTotalUnitsComboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { String u = (String) maltTotalUnitsComboModel.getSelectedItem(); if (myRecipe != null) { myRecipe.setMaltUnits(u); displayRecipe(); } } }); } } { 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(592, 27)); { tlbMalt = new JToolBar(); pnlMaltButtons.add(tlbMalt); tlbMalt.setPreferredSize(new java.awt.Dimension(386, 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); maltTable.updateUI(); displayRecipe(); } } }); } { btnDelMalt = new JButton(); tlbMalt.add(btnDelMalt); btnDelMalt.setText("-"); btnDelMalt.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (myRecipe != null) { int i = maltTable.getSelectedRow(); myRecipe.delMalt(i); maltTable.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); // set up the units combobox hopsTotalUnitsComboBox = new JComboBox(); hopsTotalUnitsComboModel = new ComboModel(); hopsTotalUnitsComboModel.setList(new Quantity().getListofUnits("weight")); hopsTotalUnitsComboBox.setModel(hopsTotalUnitsComboModel); TableColumn t = tblHopsTotals.getColumnModel().getColumn(4); t.setCellEditor(new DefaultCellEditor(hopsTotalUnitsComboBox)); hopsTotalUnitsComboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { String u = (String) hopsTotalUnitsComboModel.getSelectedItem(); if (myRecipe != null) { myRecipe.setHopsUnits(u); displayRecipe(); } } }); } { jScrollPane2 = new JScrollPane(); pnlHops.add(jScrollPane2, BorderLayout.CENTER); { hopsTableModel = new HopsTableModel(this); hopsTable = new JTable() { public String getToolTipText(MouseEvent e) { java.awt.Point p = e.getPoint(); int rowIndex = rowAtPoint(p); return SBStringUtils.multiLineToolTip(40, hopsTableModel .getDescriptionAt(rowIndex)); } }; jScrollPane2.setViewportView(hopsTable); hopsTable.setModel(hopsTableModel); hopsTable.getTableHeader().setReorderingAllowed(false); TableColumn hopColumn = hopsTable.getColumnModel().getColumn(0); hopComboBox = new JComboBox(); cmbHopsModel = new ComboModel(); hopComboBox.setModel(cmbHopsModel); hopColumn.setCellEditor(new DefaultCellEditor(hopComboBox)); // set up hop units combo hopsUnitsComboBox = new JComboBox(); cmbHopsUnitsModel = new ComboModel(); hopsUnitsComboBox.setModel(cmbHopsUnitsModel); hopColumn = hopsTable.getColumnModel().getColumn(4); hopColumn.setCellEditor(new DefaultCellEditor(hopsUnitsComboBox)); // set up hop type combo String[] forms = {"Leaf", "Pellet", "Plug"}; JComboBox hopsFormComboBox = new JComboBox(forms); hopColumn = hopsTable.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 = hopsTable.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(413, 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); hopsTable.updateUI(); displayRecipe(); } } }); } { btnDelHop = new JButton(); tlbHops.add(btnDelHop); btnDelHop.setText("-"); btnDelHop.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (myRecipe != null) { int i = hopsTable.getSelectedRow(); myRecipe.delHop(i); hopsTable.updateUI(); displayRecipe(); } } }); } } } } { statusPanel = new JPanel(); FlowLayout statusPanelLayout = new FlowLayout(); statusPanelLayout.setAlignment(FlowLayout.LEFT); statusPanelLayout.setHgap(2); statusPanelLayout.setVgap(2); statusPanel.setLayout(statusPanelLayout); pnlMain.add(statusPanel, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); { fileNamePanel = new JPanel(); statusPanel.add(fileNamePanel); fileNamePanel.setBorder(BorderFactory .createBevelBorder(BevelBorder.LOWERED)); { fileNameLabel = new JLabel(); fileNamePanel.add(fileNameLabel); fileNameLabel.setText("File Name"); fileNameLabel.setFont(new java.awt.Font("Dialog", 1, 10)); } } { ibuMethodPanel = new JPanel(); statusPanel.add(ibuMethodPanel); ibuMethodPanel.setBorder(BorderFactory .createBevelBorder(BevelBorder.LOWERED)); { ibuMethodLabel = new JLabel(); ibuMethodPanel.add(ibuMethodLabel); ibuMethodLabel.setText("IBU Method:"); ibuMethodLabel.setFont(new java.awt.Font("Dialog", 1, 10)); } } { alcMethodPanel = new JPanel(); statusPanel.add(alcMethodPanel); alcMethodPanel.setBorder(BorderFactory .createBevelBorder(BevelBorder.LOWERED)); { alcMethodLabel = new JLabel(); alcMethodPanel.add(alcMethodLabel); alcMethodLabel.setText("Alc Method:"); alcMethodLabel.setFont(new java.awt.Font("Dialog", 1, 10)); } } } } { jMenuBar1 = new JMenuBar(); setJMenuBar(jMenuBar1); { fileMenu = new JMenu(); jMenuBar1.add(fileMenu); fileMenu.setText("File"); { newFileMenuItem = new JMenuItem(); fileMenu.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(); myRecipe.setVersion(version); currentFile = null; attachRecipeData(); displayRecipe(); } }); } { openFileMenuItem = new JMenuItem(); fileMenu.add(openFileMenuItem); openFileMenuItem.setText("Open"); openFileMenuItem.setAccelerator(KeyStroke.getKeyStroke( KeyEvent.VK_O, ActionEvent.CTRL_MASK)); openFileMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // Show open dialog; this method does // not return until the dialog is closed String[] ext = {"xml", "qbrew", "rec"}; String desc = "StrangBrew and importable formats"; sbFileFilter openFileFilter = new sbFileFilter(ext, desc); // fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); fileChooser.setFileFilter(openFileFilter); int returnVal = fileChooser.showOpenDialog(jMenuBar1); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); Debug.print("Opening: " + file.getName() + ".\n"); OpenImport oi = new OpenImport(); myRecipe = oi.openFile(file); if (oi.getFileType().equals("")){ JOptionPane.showMessageDialog( null, "The file you've tried to open isn't a recognized format. \n" + "You can open: \n" + "StrangeBrew 1.x and Java files (.xml)\n" + "QBrew files (.qbrew)\n" + "BeerXML files (.xml)\n" + "Promash files (.rec)", "Unrecognized Format!", JOptionPane.INFORMATION_MESSAGE); } if (oi.getFileType().equals("beerxml")){ JOptionPane.showMessageDialog( null, "The file you've opened is in BeerXML format. It may contain \n" + "several recipes. Only the first recipe is opened. Use the Find \n" + "dialog to open other recipes in a BeerXML file.", "BeerXML!", JOptionPane.INFORMATION_MESSAGE); } myRecipe.setVersion(version); myRecipe.calcMaltTotals(); myRecipe.calcHopsTotals(); myRecipe.mash.calcMashSchedule(); checkIngredientsInDB(); attachRecipeData(); currentFile = file; displayRecipe(); } else { Debug.print("Open command cancelled by user.\n"); } } }); } { imgURL = getClass().getClassLoader().getResource("ca/strangebrew/icons/find.gif"); icon = new ImageIcon(imgURL); findFileMenuItem = new JMenuItem("Find", icon); findFileMenuItem.setAccelerator(KeyStroke.getKeyStroke( KeyEvent.VK_F, ActionEvent.CTRL_MASK)); fileMenu.add(findFileMenuItem); final JFrame owner = this; findFileMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // open the find dialog FindDialog fd = new FindDialog(owner); fd.setModal(true); fd.setVisible(true); } }); } { imgURL = getClass().getClassLoader().getResource("ca/strangebrew/icons/save.gif"); icon = new ImageIcon(imgURL); saveMenuItem = new JMenuItem("Save", icon); fileMenu.add(saveMenuItem); saveMenuItem.setAccelerator(KeyStroke.getKeyStroke( KeyEvent.VK_S, ActionEvent.CTRL_MASK)); saveMenuItem.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent evt) { saveFile(evt); } }); } { imgURL = getClass().getClassLoader().getResource("ca/strangebrew/icons/saveas.gif"); icon = new ImageIcon(imgURL); saveAsMenuItem = new JMenuItem("Save As ...", icon); fileMenu.add(saveAsMenuItem); saveAsMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { saveAs(); } }); } { exportMenu = new JMenu(); fileMenu.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 String[] ext = {"html", "htm"}; sbFileFilter saveFileFilter = new sbFileFilter(ext, "HTML"); fileChooser.setFileFilter(saveFileFilter); 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, "recipeToHtml.xslt", null); } catch (Exception e) { showError(e); } } else { Debug.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 String[] ext = {"txt"}; sbFileFilter saveFileFilter = new sbFileFilter(ext, "Text"); fileChooser.setFileFilter(saveFileFilter); 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) { showError(e); } } else { Debug.print("Export text command cancelled by user.\n"); } } }); } } { JMenuItem clipboardMenuItem = new JMenuItem("Copy to Clipboard"); fileMenu.add(clipboardMenuItem); clipboardMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // Copy current recipe to clipboard Clipboard clipboard = getToolkit ().getSystemClipboard (); StringSelection s = new StringSelection(myRecipe.toText()); clipboard.setContents(s, s); } }); JMenuItem printMenuItem = new JMenuItem("Print..."); fileMenu.add(printMenuItem); final JFrame owner = this; printMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { PrintDialog pd = new PrintDialog(owner); pd.setModal(true); pd.setVisible(true); } }); } { jSeparator2 = new JSeparator(); fileMenu.add(jSeparator2); } { exitMenuItem = new JMenuItem(); fileMenu.add(exitMenuItem); exitMenuItem.setText("Exit"); exitMenuItem.setAccelerator(KeyStroke.getKeyStroke( KeyEvent.VK_Q, ActionEvent.CTRL_MASK)); final JFrame owner = this; exitMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // exit program processWindowEvent(new WindowEvent(owner,WindowEvent.WINDOW_CLOSING)); 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); } } { mnuTools = new JMenu(); jMenuBar1.add(mnuTools); mnuTools.setText("Tools"); { final JFrame owner = this; JMenuItem scalRecipeMenuItem = new JMenuItem(); mnuTools.add(scalRecipeMenuItem); scalRecipeMenuItem.setText("Resize / Convert Recipe..."); scalRecipeMenuItem.setAccelerator(KeyStroke.getKeyStroke( KeyEvent.VK_R, ActionEvent.CTRL_MASK)); scalRecipeMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { ScaleRecipeDialog scaleRecipe = new ScaleRecipeDialog(owner); scaleRecipe.setModal(true); scaleRecipe.setVisible(true); } }); JMenuItem maltPercentMenuItem = new JMenuItem(); mnuTools.add(maltPercentMenuItem); maltPercentMenuItem.setText("Malt Percent..."); maltPercentMenuItem.setAccelerator(KeyStroke.getKeyStroke( KeyEvent.VK_M, ActionEvent.CTRL_MASK)); maltPercentMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { MaltPercentDialog maltPercent = new MaltPercentDialog(owner); maltPercent.setModal(true); maltPercent.setVisible(true); } }); } } { jMenu5 = new JMenu(); jMenuBar1.add(jMenu5); jMenu5.setText("Help"); { helpMenuItem = new JMenuItem(); jMenu5.add(helpMenuItem); helpMenuItem.setText("Help"); helpMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { String urlString = "file://" + appRoot + slash + "help" + slash + "index.html"; Debug.print(urlString); AbstractLogger logger = new SystemLogger(); BrowserLauncher launcher; try { launcher = new BrowserLauncher(logger); BrowserLauncherRunner runner = new BrowserLauncherRunner( launcher, urlString, null); Thread launcherThread = new Thread(runner); launcherThread.start(); } catch (BrowserLaunchingInitializingException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (UnsupportedOperatingSystemException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }); } { 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, version); aboutDlg.setVisible(true); } }); } } } } catch (Exception e) { e.printStackTrace(); } }
1,116,957
public void processResponse( QueryResponseMsg msg ) { long speed = msg.getRemoteHostSpeed(); GUID rcID = msg.getRemoteClientID(); DestAddress address = msg.getDestAddress(); QueryHitHost qhHost = new QueryHitHost( rcID, address, speed ); qhHost.setQHDFlags( msg.getPushNeededFlag(), msg.getServerBusyFlag(), msg.getHasUploadedFlag(), msg.getUploadSpeedFlag() ); qhHost.setQueryResponseFields( msg ); QueryResponseRecord rec; RemoteFile rfile; int recordCount = msg.getRecordCount(); ArrayList newHitList = new ArrayList( recordCount ); for (int i = 0; i < recordCount; i++) { rec = msg.getMsgRecord(i); synchronized( this ) { long fileSize = rec.getFileSize(); String filename = rec.getFilename(); URN urn = rec.getURN(); int fileIndex = rec.getFileIndex(); String metaData = rec.getMetaData(); String pathInfo = rec.getPathInfo(); rfile = new RemoteFile( qhHost, fileIndex, filename, pathInfo, fileSize, urn, metaData, (short)100 ); searchResultHolder.addQueryHit( rfile ); newHitList.add( rfile ); } } // if something was added... if ( newHitList.size() > 0 ) { if ( queryEngine != null ) { queryEngine.incrementResultCount( msg.getUniqueResultCount() ); } RemoteFile[] newHits = new RemoteFile[ newHitList.size() ]; newHitList.toArray( newHits ); fireSearchHitsAdded( newHits ); } }
public void processResponse( QueryResponseMsg msg ) { long speed = msg.getRemoteHostSpeed(); GUID rcID = msg.getRemoteClientID(); DestAddress address = msg.getDestAddress(); QueryHitHost qhHost = new QueryHitHost( rcID, address, speed ); qhHost.setQHDFlags( msg.getPushNeededFlag(), msg.getServerBusyFlag(), msg.getHasUploadedFlag(), msg.getUploadSpeedFlag() ); qhHost.setQueryResponseFields( msg ); RemoteFile rfile; int recordCount = msg.getRecordCount(); ArrayList newHitList = new ArrayList( recordCount ); for (int i = 0; i < recordCount; i++) { rec = msg.getMsgRecord(i); synchronized( this ) { long fileSize = rec.getFileSize(); String filename = rec.getFilename(); URN urn = rec.getURN(); int fileIndex = rec.getFileIndex(); String metaData = rec.getMetaData(); String pathInfo = rec.getPathInfo(); rfile = new RemoteFile( qhHost, fileIndex, filename, pathInfo, fileSize, urn, metaData, (short)100 ); searchResultHolder.addQueryHit( rfile ); newHitList.add( rfile ); } } // if something was added... if ( newHitList.size() > 0 ) { if ( queryEngine != null ) { queryEngine.incrementResultCount( msg.getUniqueResultCount() ); } RemoteFile[] newHits = new RemoteFile[ newHitList.size() ]; newHitList.toArray( newHits ); fireSearchHitsAdded( newHits ); } }
1,116,958
public void processResponse( QueryResponseMsg msg ) { long speed = msg.getRemoteHostSpeed(); GUID rcID = msg.getRemoteClientID(); DestAddress address = msg.getDestAddress(); QueryHitHost qhHost = new QueryHitHost( rcID, address, speed ); qhHost.setQHDFlags( msg.getPushNeededFlag(), msg.getServerBusyFlag(), msg.getHasUploadedFlag(), msg.getUploadSpeedFlag() ); qhHost.setQueryResponseFields( msg ); QueryResponseRecord rec; RemoteFile rfile; int recordCount = msg.getRecordCount(); ArrayList newHitList = new ArrayList( recordCount ); for (int i = 0; i < recordCount; i++) { rec = msg.getMsgRecord(i); synchronized( this ) { long fileSize = rec.getFileSize(); String filename = rec.getFilename(); URN urn = rec.getURN(); int fileIndex = rec.getFileIndex(); String metaData = rec.getMetaData(); String pathInfo = rec.getPathInfo(); rfile = new RemoteFile( qhHost, fileIndex, filename, pathInfo, fileSize, urn, metaData, (short)100 ); searchResultHolder.addQueryHit( rfile ); newHitList.add( rfile ); } } // if something was added... if ( newHitList.size() > 0 ) { if ( queryEngine != null ) { queryEngine.incrementResultCount( msg.getUniqueResultCount() ); } RemoteFile[] newHits = new RemoteFile[ newHitList.size() ]; newHitList.toArray( newHits ); fireSearchHitsAdded( newHits ); } }
public void processResponse( QueryResponseMsg msg ) { long speed = msg.getRemoteHostSpeed(); GUID rcID = msg.getRemoteClientID(); DestAddress address = msg.getDestAddress(); QueryHitHost qhHost = new QueryHitHost( rcID, address, speed ); qhHost.setQHDFlags( msg.getPushNeededFlag(), msg.getServerBusyFlag(), msg.getHasUploadedFlag(), msg.getUploadSpeedFlag() ); qhHost.setQueryResponseFields( msg ); QueryResponseRecord rec; RemoteFile rfile; int recordCount = msg.getRecordCount(); ArrayList newHitList = new ArrayList( recordCount ); for (int i = 0; i < recordCount; i++) { rec = msg.getMsgRecord(i); synchronized( this ) { long fileSize = rec.getFileSize(); String filename = rec.getFilename(); URN urn = rec.getURN(); int fileIndex = rec.getFileIndex(); String metaData = rec.getMetaData(); String pathInfo = rec.getPathInfo(); rfile = new RemoteFile( qhHost, fileIndex, filename, pathInfo, fileSize, urn, metaData, (short)100 ); searchResultHolder.addQueryHit( rfile ); newHitList.add( rfile ); } } // if something was added... if ( newHitList.size() > 0 ) { if ( queryEngine != null ) { queryEngine.incrementResultCount( msg.getUniqueResultCount() ); } RemoteFile[] newHits = new RemoteFile[ newHitList.size() ]; newHitList.toArray( newHits ); fireSearchHitsAdded( newHits ); } }
1,116,959
public void processResponse( QueryResponseMsg msg ) { long speed = msg.getRemoteHostSpeed(); GUID rcID = msg.getRemoteClientID(); DestAddress address = msg.getDestAddress(); QueryHitHost qhHost = new QueryHitHost( rcID, address, speed ); qhHost.setQHDFlags( msg.getPushNeededFlag(), msg.getServerBusyFlag(), msg.getHasUploadedFlag(), msg.getUploadSpeedFlag() ); qhHost.setQueryResponseFields( msg ); QueryResponseRecord rec; RemoteFile rfile; int recordCount = msg.getRecordCount(); ArrayList newHitList = new ArrayList( recordCount ); for (int i = 0; i < recordCount; i++) { rec = msg.getMsgRecord(i); synchronized( this ) { long fileSize = rec.getFileSize(); String filename = rec.getFilename(); URN urn = rec.getURN(); int fileIndex = rec.getFileIndex(); String metaData = rec.getMetaData(); String pathInfo = rec.getPathInfo(); rfile = new RemoteFile( qhHost, fileIndex, filename, pathInfo, fileSize, urn, metaData, (short)100 ); searchResultHolder.addQueryHit( rfile ); newHitList.add( rfile ); } } // if something was added... if ( newHitList.size() > 0 ) { if ( queryEngine != null ) { queryEngine.incrementResultCount( msg.getUniqueResultCount() ); } RemoteFile[] newHits = new RemoteFile[ newHitList.size() ]; newHitList.toArray( newHits ); fireSearchHitsAdded( newHits ); } }
public void processResponse( QueryResponseMsg msg ) { long speed = msg.getRemoteHostSpeed(); GUID rcID = msg.getRemoteClientID(); DestAddress address = msg.getDestAddress(); QueryHitHost qhHost = new QueryHitHost( rcID, address, speed ); qhHost.setQHDFlags( msg.getPushNeededFlag(), msg.getServerBusyFlag(), msg.getHasUploadedFlag(), msg.getUploadSpeedFlag() ); qhHost.setQueryResponseFields( msg ); QueryResponseRecord rec; RemoteFile rfile; int recordCount = msg.getRecordCount(); ArrayList newHitList = new ArrayList( recordCount ); for (int i = 0; i < recordCount; i++) { synchronized( this ) { long fileSize = rec.getFileSize(); String filename = rec.getFilename(); URN urn = rec.getURN(); int fileIndex = rec.getFileIndex(); String metaData = rec.getMetaData(); String pathInfo = rec.getPathInfo(); rfile = new RemoteFile( qhHost, fileIndex, filename, pathInfo, fileSize, urn, metaData, (short)100 ); searchResultHolder.addQueryHit( rfile ); newHitList.add( rfile ); } } // if something was added... if ( newHitList.size() > 0 ) { if ( queryEngine != null ) { queryEngine.incrementResultCount( msg.getUniqueResultCount() ); } RemoteFile[] newHits = new RemoteFile[ newHitList.size() ]; newHitList.toArray( newHits ); fireSearchHitsAdded( newHits ); } }
1,116,960
public void processResponse( QueryResponseMsg msg ) { long speed = msg.getRemoteHostSpeed(); GUID rcID = msg.getRemoteClientID(); DestAddress address = msg.getDestAddress(); QueryHitHost qhHost = new QueryHitHost( rcID, address, speed ); qhHost.setQHDFlags( msg.getPushNeededFlag(), msg.getServerBusyFlag(), msg.getHasUploadedFlag(), msg.getUploadSpeedFlag() ); qhHost.setQueryResponseFields( msg ); QueryResponseRecord rec; RemoteFile rfile; int recordCount = msg.getRecordCount(); ArrayList newHitList = new ArrayList( recordCount ); for (int i = 0; i < recordCount; i++) { rec = msg.getMsgRecord(i); synchronized( this ) { long fileSize = rec.getFileSize(); String filename = rec.getFilename(); URN urn = rec.getURN(); int fileIndex = rec.getFileIndex(); String metaData = rec.getMetaData(); String pathInfo = rec.getPathInfo(); rfile = new RemoteFile( qhHost, fileIndex, filename, pathInfo, fileSize, urn, metaData, (short)100 ); searchResultHolder.addQueryHit( rfile ); newHitList.add( rfile ); } } // if something was added... if ( newHitList.size() > 0 ) { if ( queryEngine != null ) { queryEngine.incrementResultCount( msg.getUniqueResultCount() ); } RemoteFile[] newHits = new RemoteFile[ newHitList.size() ]; newHitList.toArray( newHits ); fireSearchHitsAdded( newHits ); } }
public void processResponse( QueryResponseMsg msg ) { long speed = msg.getRemoteHostSpeed(); GUID rcID = msg.getRemoteClientID(); DestAddress address = msg.getDestAddress(); QueryHitHost qhHost = new QueryHitHost( rcID, address, speed ); qhHost.setQHDFlags( msg.getPushNeededFlag(), msg.getServerBusyFlag(), msg.getHasUploadedFlag(), msg.getUploadSpeedFlag() ); qhHost.setQueryResponseFields( msg ); QueryResponseRecord rec; RemoteFile rfile; int recordCount = msg.getRecordCount(); ArrayList newHitList = new ArrayList( recordCount ); for (int i = 0; i < recordCount; i++) { rec = msg.getMsgRecord(i); synchronized( this ) { long fileSize = rec.getFileSize(); String filename = rec.getFilename(); URN urn = rec.getURN(); int fileIndex = rec.getFileIndex(); String metaData = rec.getMetaData(); String pathInfo = rec.getPathInfo(); rfile = new RemoteFile( qhHost, fileIndex, filename, pathInfo, fileSize, urn, metaData, (short)100 ); searchResultHolder.addQueryHit( rfile ); newHitList.add( rfile ); } } // if something was added... if ( newHitList.size() > 0 ) { if ( queryEngine != null ) { queryEngine.incrementResultCount( msg.getUniqueResultCount() ); } RemoteFile[] newHits = new RemoteFile[ newHitList.size() ]; newHitList.toArray( newHits ); fireSearchHitsAdded( newHits ); } }
1,116,961
public void actionPerformed( ActionEvent e ) { SWDownloadCandidate[] candidates = getSelectedDownloadCandidates(); for ( int i = 0; i < candidates.length; i++ ) { candidates[i].manualConnectionRetry(); } }
public void actionPerformed( ActionEvent e ) { SWDownloadCandidate[] candidates = getSelectedDownloadCandidates(); for ( int i = 0; i < candidates.length; i++ ) { if ( candidates[i] != null ) { candidates[i].manualConnectionRetry(); } } }
1,116,962
public MatrixValueI calcValue(MatrixValueI res, MatrixValueI lhs,MatrixValueI rhs) throws ParseException { Number num = (Number) rhs.getEle(0); res.setEle(0,lhs.getEle(num.intValue()+1)); return res; }
public MatrixValueI calcValue(MatrixValueI res, MatrixValueI param1,MatrixValueI param2) throws ParseException { Number num = (Number) rhs.getEle(0); res.setEle(0,lhs.getEle(num.intValue()+1)); return res; }
1,116,963
public MatrixValueI calcValue(MatrixValueI res, MatrixValueI lhs,MatrixValueI rhs) throws ParseException { Number num = (Number) rhs.getEle(0); res.setEle(0,lhs.getEle(num.intValue()+1)); return res; }
public MatrixValueI calcValue(MatrixValueI res, MatrixValueI lhs,MatrixValueI rhs) throws ParseException { Number num = (Number) rhs.getEle(0); res.setEle(0,lhs.getEle(num.intValue()+1)); return res; }
1,116,964
public Object getValueAt(int row, int col) { // Fermentable m = (Fermentable) data.get(row); try { switch (col) { case 0: // steep return data.getMaltSteep(row); case 1: // mash return data.getMaltMashed(row); case 2 : // indicate this is a sugar: String s = ""; if (!data.getMaltMashed(row) && data.getMaltSteep(row)) s = "*"; return s + data.getMaltName(row); case 3 : return SBStringUtils.format(data .getMaltAmountAs(row, data.getMaltUnits(row)), 1); case 4 : return data.getMaltUnits(row); case 5 : return SBStringUtils.format(data.getMaltPppg(row), 3); case 6 : return SBStringUtils.format(data.getMaltLov(row), 0); case 7 : return new Double(data.getMaltCostPerU(row)); case 8 : return SBStringUtils.format(data.getMaltPercent(row), 1); } } catch (Exception e) { }; return ""; }
public Object getValueAt(int row, int col) { // Fermentable m = (Fermentable) data.get(row); try { switch (col) { case 0: // steep return new Boolean(data.getMaltSteep(row)); case 1: // mash return data.getMaltMashed(row); case 2 : // indicate this is a sugar: String s = ""; if (!data.getMaltMashed(row) && data.getMaltSteep(row)) s = "*"; return s + data.getMaltName(row); case 3 : return SBStringUtils.format(data .getMaltAmountAs(row, data.getMaltUnits(row)), 1); case 4 : return data.getMaltUnits(row); case 5 : return SBStringUtils.format(data.getMaltPppg(row), 3); case 6 : return SBStringUtils.format(data.getMaltLov(row), 0); case 7 : return new Double(data.getMaltCostPerU(row)); case 8 : return SBStringUtils.format(data.getMaltPercent(row), 1); } } catch (Exception e) { }; return ""; }
1,116,965