bugged
stringlengths
6
599k
fixed
stringlengths
10
599k
__index_level_0__
int64
0
1.13M
private void parseBody() { if ( isParsed ) { return; } // Already read the header. int offset = 0; byte n = body[offset++]; short recordCount = (short)(n < 0 ? 256 + n : n); // parsing of port and ip is done on demand in getHostAddress() and // getHostIP() offset += 2; // skip port offset += 4; // skip ip try { long speed = IOUtil.unsignedInt2Long( IOUtil.deserializeIntLE(body, offset) ); remoteHostSpeed = speed; offset += 4; uniqueResultCount = 0; Set<URN> uniqueURNs = new HashSet<URN>(); records = new QueryResponseRecord[ recordCount ]; for (int i = 0; i < recordCount; i++) { QueryResponseRecord rec = new QueryResponseRecord(); offset = rec.deserialize(body, offset); if ( NLogger.isWarnEnabled( QueryResponseMsg.class ) && rec.getAlternateLocations() != null && rec.getAlternateLocations().length > 15 ) { NLogger.warn( QueryResponseMsg.class, "QueryRespRecord with " + rec.getAlternateLocations().length + " alt locs..." ); } records[ i ] = rec; URN urn = rec.getURN(); if ( urn != null ) { uniqueURNs.add( urn ); } else { uniqueResultCount ++; } } uniqueResultCount += uniqueURNs.size(); // Handle Bearshare meta informations. The format is documented in // the GnutellaProtocol04.pdf document pushNeededFlag = QHD_UNKNOWN_FLAG; serverBusyFlag = QHD_UNKNOWN_FLAG; hasUploadedFlag = QHD_UNKNOWN_FLAG; uploadSpeedFlag = QHD_UNKNOWN_FLAG; // GGEP extensions isBrowseHostSupported = false; if ( offset <= (getHeader().getDataLength() - 16 - 4 - 2) ) { // parse meta data // Use ISO encoding for two bytes characters on some platforms. vendorCode = new String( body, offset, 4, "ISO-8859-1"); if ( !isVendorCodeValid( vendorCode ) ) { String hexVendorCode = HexConverter.toHexString( body, offset, 4 ); NLogger.warn(QueryResponseMsg.class, getHeader().getFromHost() + ": Illegal QHD vendor code found: " + vendorCode + " (" + hexVendorCode + "). Body: " + HexConverter.toHexString( body ) ); vendorCode = hexVendorCode; } offset += 4; int openDataLength = IOUtil.unsignedByte2int( body[ offset ] ); offset += 1; // parse upload speed, have uploaded, busy and push if ( openDataLength > 1) { // if we have a flag byte byte flag1 = body[ offset ]; byte flag2 = body[ offset + 1]; // check if push flag is meaningfull do it reversed from other checks if ( ( flag2 & PUSH_NEEDED_MASK ) != 0 ) { if ( ( flag1 & PUSH_NEEDED_MASK ) != 0 ) { pushNeededFlag = QHD_TRUE_FLAG; } else { pushNeededFlag = QHD_FALSE_FLAG; } } // check if server busy flag meaningfull if ((flag1 & SERVER_BUSY_MASK) != 0) { if ( (flag2 & SERVER_BUSY_MASK) != 0 ) { serverBusyFlag = QHD_TRUE_FLAG; } else { serverBusyFlag = QHD_FALSE_FLAG; } } // check if the uploaded flag is meaningfull if ((flag1 & HAS_UPLOADED_MASK) != 0) { if ( (flag2 & HAS_UPLOADED_MASK) != 0 ) { hasUploadedFlag = QHD_TRUE_FLAG; } else { hasUploadedFlag = QHD_FALSE_FLAG; } } if ((flag1 & UPLOAD_SPEED_MASK) != 0 ) { if ( (flag2 & UPLOAD_SPEED_MASK) != 0 ) { uploadSpeedFlag = QHD_TRUE_FLAG; } else { uploadSpeedFlag = QHD_FALSE_FLAG; } } if ((flag1 & GGEP_MASK) != 0 && (flag2 & GGEP_MASK) !=0 ) {// parse GGEP area should follow after open data area but // we can't be sure... int ggepMagicIndex = offset + 2; // search for real magic index while ( ggepMagicIndex < body.length ) { if ( body[ ggepMagicIndex ] == GGEPBlock.MAGIC_NUMBER ) { // found index! break; } ggepMagicIndex ++; } GGEPBlock[] ggepBlocks = null; try { // if there are GGEPs, see if Browse Host supported... ggepBlocks = GGEPBlock.parseGGEPBlocks( body, ggepMagicIndex ); isBrowseHostSupported = GGEPBlock.isExtensionHeaderInBlocks( ggepBlocks, GGEPBlock.BROWSE_HOST_HEADER_ID ); pushProxyAddresses = GGEPExtension.parsePushProxyExtensionData( ggepBlocks ); } catch ( InvalidGGEPBlockException exp ) {// ignore and continue parsing... NLogger.debug(QueryResponseMsg.class, exp, exp ); } } } // skip unknown open data length offset += openDataLength; //Parse private area of Limewire and Shareaza to read out chat //flag. If chatflag is 0x1 chat is supported, if 0x0 its not. int privateDataLength = body.length - offset - 16; if ( privateDataLength > 0 && ( vendorCode.equals("LIME") || vendorCode.equals("RAZA") || vendorCode.equals("PHEX") ) ) { byte flag = body[ offset ]; isChatSupported = ( flag & CHAT_SUPPORTED_MASK ) != 0; } //System.out.println( (mHeader.getDataLen() -16 - 4 -2) + " " + offset + " " + // /*new String( body, offset, mHeader.getDataLen() - offset) + " " +*/ // openDataLength + " " + pushNeededFlag + " " + serverBusyFlag + " " + // uploadSpeedFlag + " " + hasUploadedFlag + " " + vendorCode ); } parseRemoteClientID(); isParsed = true; } catch ( java.io.UnsupportedEncodingException exp ) { return; } }
private void parseBody() { if ( isParsed ) { return; } // Already read the header. int offset = 0; byte n = body[offset++]; short recordCount = (short)(n < 0 ? 256 + n : n); // parsing of port and ip is done on demand in getHostAddress() and // getHostIP() offset += 2; // skip port offset += 4; // skip ip try { long speed = IOUtil.unsignedInt2Long( IOUtil.deserializeIntLE(body, offset) ); remoteHostSpeed = speed; offset += 4; uniqueResultCount = 0; Set<URN> uniqueURNs = new HashSet<URN>(); records = new QueryResponseRecord[ recordCount ]; for (int i = 0; i < recordCount; i++) { QueryResponseRecord rec = new QueryResponseRecord(); offset = rec.deserialize(body, offset); if ( NLogger.isWarnEnabled( QueryResponseMsg.class ) && rec.getAlternateLocations() != null && rec.getAlternateLocations().length > 15 ) { NLogger.warn( QueryResponseMsg.class, "QueryRespRecord with " + rec.getAlternateLocations().length + " alt locs..." ); } records[ i ] = rec; URN urn = rec.getURN(); if ( urn != null ) { uniqueURNs.add( urn ); } else { uniqueResultCount ++; } } uniqueResultCount += uniqueURNs.size(); // Handle Bearshare meta informations. The format is documented in // the GnutellaProtocol04.pdf document pushNeededFlag = QHD_UNKNOWN_FLAG; serverBusyFlag = QHD_UNKNOWN_FLAG; hasUploadedFlag = QHD_UNKNOWN_FLAG; uploadSpeedFlag = QHD_UNKNOWN_FLAG; // GGEP extensions isBrowseHostSupported = false; if ( offset <= (getHeader().getDataLength() - 16 - 4 - 2) ) { // parse meta data // Use ISO encoding for two bytes characters on some platforms. vendorCode = new String( body, offset, 4, "ISO-8859-1"); if ( !isVendorCodeValid( vendorCode ) ) { String hexVendorCode = HexConverter.toHexString( body, offset, 4 ); NLogger.warn(QueryResponseMsg.class, getHeader().getFromHost() + ": Illegal QHD vendor code found: " + vendorCode + " (" + hexVendorCode + "). Body: " + HexConverter.toHexString( body ) ); vendorCode = hexVendorCode; } offset += 4; int openDataLength = IOUtil.unsignedByte2int( body[ offset ] ); offset += 1; // parse upload speed, have uploaded, busy and push if ( openDataLength > 1) { // if we have a flag byte byte flag1 = body[ offset ]; byte flag2 = body[ offset + 1]; // check if push flag is meaningfull do it reversed from other checks if ( ( flag2 & PUSH_NEEDED_MASK ) != 0 ) { if ( ( flag1 & PUSH_NEEDED_MASK ) != 0 ) { pushNeededFlag = QHD_TRUE_FLAG; } else { pushNeededFlag = QHD_FALSE_FLAG; } } // check if server busy flag meaningfull if ((flag1 & SERVER_BUSY_MASK) != 0) { if ( (flag2 & SERVER_BUSY_MASK) != 0 ) { serverBusyFlag = QHD_TRUE_FLAG; } else { serverBusyFlag = QHD_FALSE_FLAG; } } // check if the uploaded flag is meaningfull if ((flag1 & HAS_UPLOADED_MASK) != 0) { if ( (flag2 & HAS_UPLOADED_MASK) != 0 ) { hasUploadedFlag = QHD_TRUE_FLAG; } else { hasUploadedFlag = QHD_FALSE_FLAG; } } if ((flag1 & UPLOAD_SPEED_MASK) != 0 ) { if ( (flag2 & UPLOAD_SPEED_MASK) != 0 ) { uploadSpeedFlag = QHD_TRUE_FLAG; } else { uploadSpeedFlag = QHD_FALSE_FLAG; } } if ((flag1 & GGEP_MASK) != 0 && (flag2 & GGEP_MASK) !=0 ) {// parse GGEP area should follow after open data area but // we can't be sure... int ggepMagicIndex = offset + 2; // search for real magic index while ( ggepMagicIndex < body.length ) { if ( body[ ggepMagicIndex ] == GGEPBlock.MAGIC_NUMBER ) { // found index! break; } ggepMagicIndex ++; } GGEPBlock[] ggepBlocks = null; try { // if there are GGEPs, see if Browse Host supported... ggepBlocks = GGEPBlock.parseGGEPBlocks( body, ggepMagicIndex ); isBrowseHostSupported = GGEPBlock.isExtensionHeaderInBlocks( ggepBlocks, GGEPBlock.BROWSE_HOST_HEADER_ID ); pushProxyAddresses = GGEPExtension.parsePushProxyExtensionData( ggepBlocks ); } catch ( InvalidGGEPBlockException exp ) {// ignore and continue parsing... NLogger.debug(QueryResponseMsg.class, exp, exp ); } } } // skip unknown open data length offset += openDataLength; //Parse private area of Limewire and Shareaza to read out chat //flag. If chatflag is 0x1 chat is supported, if 0x0 its not. int privateDataLength = body.length - offset - 16; if ( privateDataLength > 0 && ( vendorCode.equals("LIME") || vendorCode.equals("RAZA") || vendorCode.equals("PHEX") ) ) { byte flag = body[ offset ]; isChatSupported = ( flag & CHAT_SUPPORTED_MASK ) != 0; } //System.out.println( (mHeader.getDataLen() -16 - 4 -2) + " " + offset + " " + // /*new String( body, offset, mHeader.getDataLen() - offset) + " " +*/ // openDataLength + " " + pushNeededFlag + " " + serverBusyFlag + " " + // uploadSpeedFlag + " " + hasUploadedFlag + " " + vendorCode ); } parseRemoteClientID(); isParsed = true; } catch ( java.io.UnsupportedEncodingException exp ) { return; } }
1,116,730
public Dimensions calcDim(Dimensions l,Dimensions r) { if(l.equals(r) && l.is1D()) return Dimensions.ONE; else return null; }
public Dimensions calcDim(Dimensions l,Dimensions r) { if(l.equals(r) && l.is1D()) return Dimensions.ONE; return null; }
1,116,731
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); }
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,732
public int compare(Number a,Number b) { return ((Rational) a).compareTo((Rational) b); }
public int compare(Number a,Number b) { return ((Rational) a).compareTo(b); }
1,116,735
public boolean equals(Number a,Number b) { return ((Rational) a).compareTo((Rational) b) == 0; }
public boolean equals(Number a,Number b) { return ((Rational) a).compareTo(b) == 0; }
1,116,736
public void setStepEndTemp(int i, int t){ if (tempUnits.equals("C")) ((MashStep)steps.get(i)).setEndTemp(cToF(t)); else ((MashStep)steps.get(i)).setEndTemp(t); calcMashSchedule(); }
public void setStepEndTemp(int i, double t){ if (tempUnits.equals("C")) ((MashStep)steps.get(i)).setEndTemp(cToF(t)); else ((MashStep)steps.get(i)).setEndTemp(t); calcMashSchedule(); }
1,116,739
public void doAutoConnectCheck() { if ( !networkMgr.isNetworkJoined() || !networkMgr.isConnected() ) { return; } int hostCount; int requiredHostCount; if ( isAbleToBecomeUltrapeer() ) { // as a ultrapeer I'm primary searching for Ultrapeers only... // to make sure I'm well connected... hostCount = networkHostsContainer.getUltrapeerConnectionCount(); requiredHostCount = ServiceManager.sCfg.up2upConnections; } else if ( isShieldedLeafNode() || ServiceManager.sCfg.allowToBecomeLeaf ) { // as a leaf I'm primary searching for Ultrapeers only... hostCount = networkHostsContainer.getUltrapeerConnectionCount(); requiredHostCount = ServiceManager.sCfg.leaf2upConnections; } else { hostCount = networkHostsContainer.getTotalConnectionCount(); requiredHostCount = ServiceManager.sCfg.peerConnections; } // count the number of missing connection tryes this is the required count // minus the available count. The result is multiplied by four to raise the // connection try count. int missingCount = ( requiredHostCount - hostCount ) * 4; // find out the number of hosts where a connection is currently tried... int allHostCount = networkHostsContainer.getNetworkHostCount( ); int errorHostCount = networkHostsContainer.getNetworkHostCount( HostStatus.ERROR); // make sure the value is not negative. int currentTryCount = Math.max( 0, allHostCount - hostCount - errorHostCount ); // we will never try more then a reasonable parallel tries.. int upperLimit = Math.min( MAX_PARALLEL_CONNECTION_TRIES, ServiceManager.sCfg.maxConcurrentConnectAttempts ) - currentTryCount; int outConnectCount = Math.min( missingCount-currentTryCount, upperLimit ); if ( outConnectCount > 0 ) { NLogger.debug( HostManager.class, "Auto-connect to " + outConnectCount + " new hosts."); networkHostsContainer.createOutConnectionToNextHosts( outConnectCount ); } }
public void doAutoConnectCheck() { if ( !networkMgr.isNetworkJoined() || !networkMgr.isConnected() ) { return; } int hostCount; int requiredHostCount; if ( isAbleToBecomeUltrapeer() ) { // as a ultrapeer I'm primary searching for Ultrapeers only... // to make sure I'm well connected... hostCount = networkHostsContainer.getUltrapeerConnectionCount(); requiredHostCount = ServiceManager.sCfg.up2upConnections; } else if ( isShieldedLeafNode() || ServiceManager.sCfg.allowToBecomeLeaf ) { // as a leaf I'm primary searching for Ultrapeers only... hostCount = networkHostsContainer.getUltrapeerConnectionCount(); requiredHostCount = ServiceManager.sCfg.leaf2upConnections; } else { hostCount = networkHostsContainer.getTotalConnectionCount(); requiredHostCount = ServiceManager.sCfg.peerConnections; } // count the number of missing connection tryes this is the required count // minus the available count. The result is multiplied by four to raise the // connection try count. int missingCount = ( requiredHostCount - hostCount ) * 4; // find out the number of hosts where a connection is currently tried... int allHostCount = networkHostsContainer.getNetworkHostCount( ); int errorHostCount = networkHostsContainer.getNetworkHostCount( HostStatus.ERROR); // make sure the value is not negative. int totalCount = networkHostsContainer.getTotalConnectionCount(); int currentTryCount = Math.max( 0, allHostCount - totalCount - errorHostCount); // we will never try more then a reasonable parallel tries.. int upperLimit = Math.min( MAX_PARALLEL_CONNECTION_TRIES, ServiceManager.sCfg.maxConcurrentConnectAttempts ) - currentTryCount; int outConnectCount = Math.min( missingCount-currentTryCount, upperLimit ); if ( outConnectCount > 0 ) { NLogger.debug( HostManager.class, "Auto-connect to " + outConnectCount + " new hosts."); networkHostsContainer.createOutConnectionToNextHosts( outConnectCount ); } }
1,116,741
private void drag(int dragAmount, int dragFrom, SeismogramShapeIterator iterator){ double pointsPerPixel = iterator.getPointsPerPixel(); int[] seisPoints = currentIterator.getSeisPoints(); System.out.println("SeisPoint[0] forehand: " + seisPoints[0] + "dragged points: " + (pointsPerPixel * dragAmount)); seisPoints[0] =(int)-(iterator.getTotalShift() * pointsPerPixel) + iterator.getBaseSeisPoint(); //Math.ceil(pointsPerPixel * dragAmount); System.out.println("SeisPoint[0] afterhand: " + seisPoints[0]); seisPoints[1] = seisPoints[0] + (int)-(iterator.getSize().width * pointsPerPixel); //Math.ceil(pointsPerPixel * dragAmount); 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--; } plotPixels(drawStart, drawEnd, iterator); currentIterator = iterator; }
private void drag(int dragAmount, int dragFrom, SeismogramShapeIterator iterator){ double pointsPerPixel = iterator.getPointsPerPixel(); int[] seisPoints = currentIterator.getSeisPoints(); System.out.println("SeisPoint[0] forehand: " + seisPoints[0] + "dragged points: " + (pointsPerPixel * dragAmount)); seisPoints[0] =(int)-(iterator.getTotalShift() * pointsPerPixel) + iterator.getBaseSeisPoint(); //Math.ceil(pointsPerPixel * dragAmount); System.out.println("SeisPoint[0] afterhand: " + seisPoints[0]); seisPoints[1] = seisPoints[0] + (int)-(iterator.getSize().width * pointsPerPixel); //Math.ceil(pointsPerPixel * dragAmount); 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--; } plotPixels(drawStart, drawEnd, iterator); currentIterator = iterator; }
1,116,742
private void drag(int dragAmount, int dragFrom, SeismogramShapeIterator iterator){ double pointsPerPixel = iterator.getPointsPerPixel(); int[] seisPoints = currentIterator.getSeisPoints(); System.out.println("SeisPoint[0] forehand: " + seisPoints[0] + "dragged points: " + (pointsPerPixel * dragAmount)); seisPoints[0] =(int)-(iterator.getTotalShift() * pointsPerPixel) + iterator.getBaseSeisPoint(); //Math.ceil(pointsPerPixel * dragAmount); System.out.println("SeisPoint[0] afterhand: " + seisPoints[0]); seisPoints[1] = seisPoints[0] + (int)-(iterator.getSize().width * pointsPerPixel); //Math.ceil(pointsPerPixel * dragAmount); 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--; } plotPixels(drawStart, drawEnd, iterator); currentIterator = iterator; }
private void drag(int dragAmount, int dragFrom, SeismogramShapeIterator iterator){ double pointsPerPixel = iterator.getPointsPerPixel(); int[] seisPoints = currentIterator.getSeisPoints(); System.out.println("SeisPoint[0] forehand: " + seisPoints[0] + "dragged points: " + (pointsPerPixel * dragAmount)); seisPoints[0] =(int)-(iterator.getTotalShift() * pointsPerPixel) + iterator.getBaseSeisPoint(); //Math.ceil(pointsPerPixel * dragAmount); seisPoints[1] = seisPoints[0] + (int)-(iterator.getSize().width * pointsPerPixel); //Math.ceil(pointsPerPixel * dragAmount); 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--; } plotPixels(drawStart, drawEnd, iterator); currentIterator = iterator; }
1,116,743
public void dragLeft(int dragAmount, SeismogramShapeIterator iterator){ System.out.println("Draggin left"); drag(dragAmount, -dragAmount, iterator); }
public void dragLeft(int dragAmount, SeismogramShapeIterator iterator){ drag(dragAmount, -dragAmount, iterator); }
1,116,744
public void dragRight(int dragAmount, SeismogramShapeIterator iterator){ System.out.println("Draggin right"); drag(dragAmount, 0, iterator); }
public void dragRight(int dragAmount, SeismogramShapeIterator iterator){ System.out.println("Draggin right"); drag(dragAmount, 0, iterator); }
1,116,745
public void plot(SeismogramShapeIterator iterator){ System.out.println("Plotting all points"); iterator.setSeisPoints(DisplayUtils.getSeisPoints(dss.getSeismogram(), iterator.getTime())); iterator.setBaseSeisPoint(); iterator.setPointsPerPixel(); iterator.setPoints(new int[2][iterator.getSize().width]); plotPixels(iterator); currentIterator = iterator; }
public void plot(SeismogramShapeIterator iterator){ iterator.setSeisPoints(DisplayUtils.getSeisPoints(dss.getSeismogram(), iterator.getTime())); iterator.setBaseSeisPoint(); iterator.setPointsPerPixel(); iterator.setPoints(new int[2][iterator.getSize().width]); plotPixels(iterator); currentIterator = iterator; }
1,116,746
public Object atanh(Object param) throws ParseException { if (param instanceof Number) { Complex temp = new Complex(((Number)param).doubleValue(),0.0); return temp.atanh(); } else if (param instanceof Complex) { return ((Complex)param).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(); } else if (param instanceof Complex) { return ((Complex)param).atanh(); } throw new ParseException("Invalid parameter type"); }
1,116,747
public Object atanh(Object param) throws ParseException { if (param instanceof Number) { Complex temp = new Complex(((Number)param).doubleValue(),0.0); return temp.atanh(); } else if (param instanceof Complex) { return ((Complex)param).atanh(); } throw new ParseException("Invalid parameter type"); }
public Object atanh(Object param) throws ParseException { if (param instanceof Number) { Complex temp = new Complex(((Number)param).doubleValue(),0.0); return temp.atanh(); } else if (param instanceof Complex) { return ((Complex)param).atanh(); } throw new ParseException("Invalid parameter type"); }
1,116,748
private boolean evaluateHTTPRequest() throws IOException { String logMsg = "HTTP Request: " + httpRequest.buildHTTPRequestString(); NLogger.debug( UploadEngine.class, logMsg); uploadState.addToUploadLog( logMsg ); GnutellaRequest gRequest = httpRequest.getGnutellaRequest(); if ( gRequest == null ) { throw new IOException("Not a Gnutella file request."); } HTTPHeader header; if (gRequest.getURN() == null) { header = httpRequest .getHeader(GnutellaHeaderNames.X_GNUTELLA_CONTENT_URN); if (header != null) { if (URN.isValidURN(header.getValue())) { URN urn = new URN(header.getValue()); gRequest.setContentURN(urn); } } } SocketFacade socket = connection.getSocket(); int port = -1; header = httpRequest.getHeader(GnutellaHeaderNames.LISTEN_IP); if (header == null) { header = httpRequest.getHeader(GnutellaHeaderNames.X_MY_ADDRESS); } if (header != null) { // parse port port = AddressUtils.parsePort(header.getValue()); } if (port <= 0) { port = socket.getRemoteAddress().getPort(); } hostAddress = new DefaultDestAddress(socket.getRemoteAddress().getHostName(), port); UploadManager uploadMgr = UploadManager.getInstance(); HTTPResponse httpResponse; if (!isIPCounted) { boolean succ = uploadMgr.validateAndCountIP(hostAddress); if (!succ) { httpResponse = new HTTPResponse((short) 503, "Upload Limit Reached for IP", true); sendHTTPResponse(httpResponse); return false; } isIPCounted = true; } ShareFile requestedShareFile = findShareFile(gRequest); if (requestedShareFile == null) { httpResponse = new HTTPResponse((short) 404, "File not found", true); sendHTTPResponse(httpResponse); return false; } isUploadQueued = false; if (uploadMgr.isHostBusy()) { header = httpRequest.getHeader(GnutellaHeaderNames.X_QUEUE); if (header == null || !ServiceManager.sCfg.allowUploadQueuing || uploadMgr.isQueueLimitReached()) {// queueing is not supported httpResponse = new HTTPResponse((short) 503, "Upload Limit Reached", true); addAltLocResponseHeader(httpResponse, requestedShareFile); sendHTTPResponse(httpResponse); return false; } isUploadQueued = true; } HTTPHeader rangeHeader = null; HTTPRangeSet uploadRange = null; Range uploadRangeEntry = null; if ( !gRequest.isTigerTreeRequest() ) { rangeHeader = httpRequest.getHeader(HTTPHeaderNames.RANGE); if (rangeHeader != null) { uploadRange = HTTPRangeSet.parseHTTPRangeSet( rangeHeader.getValue(), true); if (uploadRange == null) { // this is not 416 Requested Range Not Satisfiable since // we have a parsing error on the requested range. httpResponse = new HTTPResponse((short) 500, "Requested Range Not Parseable", true); addAltLocResponseHeader(httpResponse, requestedShareFile); sendHTTPResponse(httpResponse); return false; } } else { uploadRange = new HTTPRangeSet(0, HTTPRangeSet.NOT_SET); } uploadRangeEntry = uploadRange.getFirstRange(); short rangeStatus = requestedShareFile .getRangeAvailableStatus(uploadRangeEntry); if (rangeStatus != UploadConstants.RANGE_AVAILABLE) { if (rangeStatus == UploadConstants.RANGE_NOT_AVAILABLE) { httpResponse = new HTTPResponse((short) 503, "Requested Range Not Available", true); } else //case: if ( rangeStatus == // UploadConstants.RANGE_NOT_SATISFIABLE ) { httpResponse = new HTTPResponse((short) 416, "Requested Range Not Satisfiable", true); } if (requestedShareFile instanceof PartialShareFile) { // TODO we could check if the partial file is progressing // and // return a 416 when the range will not come available soon. PartialShareFile pShareFile = (PartialShareFile) requestedShareFile; httpResponse.addHeader(new HTTPHeader( GnutellaHeaderNames.X_AVAILABLE_RANGES, pShareFile .buildXAvailableRangesString())); } addAltLocResponseHeader(httpResponse, requestedShareFile); sendHTTPResponse(httpResponse); return false; } } // everything is right... collect upload infos String vendor = null; header = httpRequest.getHeader(HTTPHeaderNames.USER_AGENT); if (header != null) { vendor = header.getValue(); } else { vendor = ""; } // check for persistent connection... // a connection is assumed to be persistent if its a HTTP 1.1 connection // with no 'Connection: close' header. Or a HTTP connection with // Connection: Keep-Alive header. header = httpRequest.getHeader(HTTPHeaderNames.CONNECTION); if (HTTPRequest.HTTP_11.equals(httpRequest.getHTTPVersion())) { if (header != null && header.getValue().equalsIgnoreCase("CLOSE")) { isPersistentConnection = false; } else { isPersistentConnection = true; } } else { if (header != null && header.getValue().equalsIgnoreCase("KEEP-ALIVE")) { isPersistentConnection = true; } else { isPersistentConnection = false; } } if (isUploadQueued) { // queueing is supported int queuePosition; uploadState.update(hostAddress, vendor); queuePosition = uploadMgr.getQueuedPosition(uploadState) + 1; if ( queuePosition < 0 ) {// missing in queue list queuePosition = uploadMgr.addQueuedUpload(uploadState) + 1; } uploadState.setStatus(UploadConstants.STATUS_QUEUED); int queueLength = uploadMgr.getUploadQueueSize(); int uploadLimit = ServiceManager.sCfg.mMaxUpload; int pollMin = ServiceManager.sCfg.minUploadQueuePollTime; int pollMax = ServiceManager.sCfg.maxUploadQueuePollTime; httpResponse = new HTTPResponse((short) 503, "Remotely Queued", true); addAltLocResponseHeader(httpResponse, requestedShareFile); XQueueParameters xQueueParas = new XQueueParameters(queuePosition, queueLength, uploadLimit, pollMin, pollMax); httpResponse.addHeader(new HTTPHeader(GnutellaHeaderNames.X_QUEUE, xQueueParas.buildHTTPString())); sendHTTPResponse(httpResponse); socket.setSoTimeout(pollMax * 1000); minNextPollTime = System.currentTimeMillis() + pollMin * 1000; return true; } // standard upload... HTTPHeader additionalResponseHeader = null; long contentLength = 0; if ( !gRequest.isTigerTreeRequest() ) { if (requestedShareFile instanceof PartialShareFile) { PartialShareFile pShareFile = (PartialShareFile) requestedShareFile; // call adjusts uploadRangeEntry to fit... pShareFile.findFittingPartForRange(uploadRangeEntry); fileStartOffset = pShareFile.getFileStartOffset(); additionalResponseHeader = new HTTPHeader( GnutellaHeaderNames.X_AVAILABLE_RANGES, pShareFile .buildXAvailableRangesString()); } else { fileStartOffset = uploadRangeEntry .getStartOffset(requestedShareFile.getFileSize()); } startOffset = uploadRangeEntry.getStartOffset(requestedShareFile .getFileSize()); endOffset = uploadRangeEntry.getEndOffset(requestedShareFile .getFileSize()); contentLength = endOffset - startOffset + 1; } URN sharedFileURN = requestedShareFile.getURN(); if ( gRequest.isTigerTreeRequest() ) { uploadState.update(hostAddress, vendor, requestedShareFile.getFileName()); } else { uploadState.update(hostAddress, vendor, requestedShareFile .getFileName(), sharedFileURN, requestedShareFile.getSystemFile(), contentLength); } if ( !uploadMgr.containsUploadState(uploadState) ) { uploadMgr.addUploadState(uploadState); } uploadState.setUploadEngine(this); // form ok response... if ( !gRequest.isTigerTreeRequest() ) { if (startOffset == 0 && endOffset == requestedShareFile.getFileSize() - 1) { httpResponse = new HTTPResponse((short) 200, "OK", true); } else { httpResponse = new HTTPResponse((short) 206, "Partial Content", true); } if (additionalResponseHeader != null) { httpResponse.addHeader(additionalResponseHeader); } } else { httpResponse = new HTTPResponse((short) 200, "OK", true); } // TODO for browser request we might like to return explicite content // types: // contentType = MimeTypeMapping.getMimeTypeForExtension( ext ); httpResponse.addHeader(new HTTPHeader(HTTPHeaderNames.CONTENT_TYPE, "application/binary")); if ( !gRequest.isTigerTreeRequest() ) { httpResponse.addHeader(new HTTPHeader( HTTPHeaderNames.CONTENT_LENGTH, String.valueOf(contentLength))); httpResponse.addHeader(new HTTPHeader( HTTPHeaderNames.CONTENT_RANGE, "bytes " + startOffset + "-" + endOffset + "/" + requestedShareFile.getFileSize())); } // in case of tiger tree request we need to close the connection since // we dont know the content length of the dime here already... // TODO: we could pre calculate the dime length in this case! if ( isPersistentConnection && !gRequest.isTigerTreeRequest() ) { httpResponse.addHeader( new HTTPHeader( HTTPHeaderNames.CONNECTION, "Keep-Alive" ) ); } else { httpResponse.addHeader(new HTTPHeader(HTTPHeaderNames.CONNECTION, "close")); isPersistentConnection = false; } if ( sharedFileURN != null ) { httpResponse.addHeader(new HTTPHeader( GnutellaHeaderNames.X_GNUTELLA_CONTENT_URN, sharedFileURN .getAsString())); } if ( !gRequest.isTigerTreeRequest() ) { addAltLocResponseHeader(httpResponse, requestedShareFile); addPushProxyResponseHeader( httpResponse ); } if ( sharedFileURN != null && !gRequest.isTigerTreeRequest() ) { parseAltLocRequestHeader( requestedShareFile, sharedFileURN ); // add thex download url ShareFileThexData thexData = requestedShareFile.getThexData( true ); if ( thexData != null ) { String thexRootHash = thexData.getRootHash(); HTTPHeader thexHeader = new HTTPHeader( GnutellaHeaderNames.X_THEX_URI, URLUtil.buildName2ResThexURL( sharedFileURN, thexRootHash ) ); httpResponse.addHeader( thexHeader ); } } sendHTTPResponse(httpResponse); socket.setSoTimeout(ServiceManager.sCfg.socketConnectTimeout); // check if we need to count again.. // this is the case if we have no PartialShareFile (same // PartialShareFile is never equal again, since its always a new instance) // and the ShareFile is not equal to the requested file. if ( uploadShareFile != null && !(requestedShareFile instanceof PartialShareFile) && uploadShareFile != requestedShareFile) { isUploadCounted = false; } uploadShareFile = requestedShareFile; minNextPollTime = -1; return true; }
private boolean evaluateHTTPRequest() throws IOException { String logMsg = "HTTP Request: " + httpRequest.buildHTTPRequestString(); NLogger.debug( UploadEngine.class, logMsg); uploadState.addToUploadLog( logMsg ); GnutellaRequest gRequest = httpRequest.getGnutellaRequest(); if ( gRequest == null ) { throw new IOException("Not a Gnutella file request."); } HTTPHeader header; if (gRequest.getURN() == null) { header = httpRequest .getHeader(GnutellaHeaderNames.X_GNUTELLA_CONTENT_URN); if (header != null) { if (URN.isValidURN(header.getValue())) { URN urn = new URN(header.getValue()); gRequest.setContentURN(urn); } } } SocketFacade socket = connection.getSocket(); int port = -1; header = httpRequest.getHeader(GnutellaHeaderNames.LISTEN_IP); if (header == null) { header = httpRequest.getHeader(GnutellaHeaderNames.X_MY_ADDRESS); } if (header != null) { // parse port port = AddressUtils.parsePort(header.getValue()); } if (port <= 0) { port = socket.getRemoteAddress().getPort(); } hostAddress = new DefaultDestAddress(socket.getRemoteAddress().getHostName(), port); UploadManager uploadMgr = UploadManager.getInstance(); HTTPResponse httpResponse; if (!isIPCounted) { boolean succ = uploadMgr.validateAndCountIP(hostAddress); if (!succ) { httpResponse = new HTTPResponse((short) 503, "Upload Limit Reached for IP", true); sendHTTPResponse(httpResponse); return false; } isIPCounted = true; } ShareFile requestedShareFile = findShareFile(gRequest); if (requestedShareFile == null) { httpResponse = new HTTPResponse((short) 404, "File not found", true); sendHTTPResponse(httpResponse); return false; } isUploadQueued = false; if (uploadMgr.isHostBusy()) { header = httpRequest.getHeader(GnutellaHeaderNames.X_QUEUE); if (header == null || !ServiceManager.sCfg.allowUploadQueuing || uploadMgr.isQueueLimitReached()) {// queueing is not supported httpResponse = new HTTPResponse((short) 503, "Upload Limit Reached", true); addAltLocResponseHeader(httpResponse, requestedShareFile); sendHTTPResponse(httpResponse); return false; } isUploadQueued = true; } HTTPHeader rangeHeader = null; HTTPRangeSet uploadRange = null; Range uploadRangeEntry = null; if ( !gRequest.isTigerTreeRequest() ) { rangeHeader = httpRequest.getHeader(HTTPHeaderNames.RANGE); if (rangeHeader != null) { uploadRange = HTTPRangeSet.parseHTTPRangeSet( rangeHeader.getValue(), true); if (uploadRange == null) { // this is not 416 Requested Range Not Satisfiable since // we have a parsing error on the requested range. httpResponse = new HTTPResponse((short) 500, "Requested Range Not Parseable", true); addAltLocResponseHeader(httpResponse, requestedShareFile); sendHTTPResponse(httpResponse); return false; } } else { uploadRange = new HTTPRangeSet(0, HTTPRangeSet.NOT_SET); } uploadRangeEntry = uploadRange.getFirstRange(); short rangeStatus = requestedShareFile .getRangeAvailableStatus(uploadRangeEntry); if (rangeStatus != UploadConstants.RANGE_AVAILABLE) { if (rangeStatus == UploadConstants.RANGE_NOT_AVAILABLE) { httpResponse = new HTTPResponse((short) 503, "Requested Range Not Available", true); } else //case: if ( rangeStatus == // UploadConstants.RANGE_NOT_SATISFIABLE ) { httpResponse = new HTTPResponse((short) 416, "Requested Range Not Satisfiable", true); } if (requestedShareFile instanceof PartialShareFile) { // TODO we could check if the partial file is progressing // and // return a 416 when the range will not come available soon. PartialShareFile pShareFile = (PartialShareFile) requestedShareFile; httpResponse.addHeader(new HTTPHeader( GnutellaHeaderNames.X_AVAILABLE_RANGES, pShareFile .buildXAvailableRangesString())); } addAltLocResponseHeader(httpResponse, requestedShareFile); sendHTTPResponse(httpResponse); return false; } } // everything is right... collect upload infos String vendor = null; header = httpRequest.getHeader(HTTPHeaderNames.USER_AGENT); if (header != null) { vendor = header.getValue(); } else { vendor = ""; } // check for persistent connection... // a connection is assumed to be persistent if its a HTTP 1.1 connection // with no 'Connection: close' header. Or a HTTP connection with // Connection: Keep-Alive header. header = httpRequest.getHeader(HTTPHeaderNames.CONNECTION); if (HTTPRequest.HTTP_11.equals(httpRequest.getHTTPVersion())) { if (header != null && header.getValue().equalsIgnoreCase("CLOSE")) { isPersistentConnection = false; } else { isPersistentConnection = true; } } else { if (header != null && header.getValue().equalsIgnoreCase("KEEP-ALIVE")) { isPersistentConnection = true; } else { isPersistentConnection = false; } } if (isUploadQueued) { // queueing is supported int queuePosition; uploadState.update(hostAddress, vendor); queuePosition = uploadMgr.getQueuedPosition(uploadState); if ( queuePosition < 0 ) {// missing in queue list queuePosition = uploadMgr.addQueuedUpload(uploadState) + 1; } uploadState.setStatus(UploadConstants.STATUS_QUEUED); int queueLength = uploadMgr.getUploadQueueSize(); int uploadLimit = ServiceManager.sCfg.mMaxUpload; int pollMin = ServiceManager.sCfg.minUploadQueuePollTime; int pollMax = ServiceManager.sCfg.maxUploadQueuePollTime; httpResponse = new HTTPResponse((short) 503, "Remotely Queued", true); addAltLocResponseHeader(httpResponse, requestedShareFile); XQueueParameters xQueueParas = new XQueueParameters(queuePosition, queueLength, uploadLimit, pollMin, pollMax); httpResponse.addHeader(new HTTPHeader(GnutellaHeaderNames.X_QUEUE, xQueueParas.buildHTTPString())); sendHTTPResponse(httpResponse); socket.setSoTimeout(pollMax * 1000); minNextPollTime = System.currentTimeMillis() + pollMin * 1000; return true; } // standard upload... HTTPHeader additionalResponseHeader = null; long contentLength = 0; if ( !gRequest.isTigerTreeRequest() ) { if (requestedShareFile instanceof PartialShareFile) { PartialShareFile pShareFile = (PartialShareFile) requestedShareFile; // call adjusts uploadRangeEntry to fit... pShareFile.findFittingPartForRange(uploadRangeEntry); fileStartOffset = pShareFile.getFileStartOffset(); additionalResponseHeader = new HTTPHeader( GnutellaHeaderNames.X_AVAILABLE_RANGES, pShareFile .buildXAvailableRangesString()); } else { fileStartOffset = uploadRangeEntry .getStartOffset(requestedShareFile.getFileSize()); } startOffset = uploadRangeEntry.getStartOffset(requestedShareFile .getFileSize()); endOffset = uploadRangeEntry.getEndOffset(requestedShareFile .getFileSize()); contentLength = endOffset - startOffset + 1; } URN sharedFileURN = requestedShareFile.getURN(); if ( gRequest.isTigerTreeRequest() ) { uploadState.update(hostAddress, vendor, requestedShareFile.getFileName()); } else { uploadState.update(hostAddress, vendor, requestedShareFile .getFileName(), sharedFileURN, requestedShareFile.getSystemFile(), contentLength); } if ( !uploadMgr.containsUploadState(uploadState) ) { uploadMgr.addUploadState(uploadState); } uploadState.setUploadEngine(this); // form ok response... if ( !gRequest.isTigerTreeRequest() ) { if (startOffset == 0 && endOffset == requestedShareFile.getFileSize() - 1) { httpResponse = new HTTPResponse((short) 200, "OK", true); } else { httpResponse = new HTTPResponse((short) 206, "Partial Content", true); } if (additionalResponseHeader != null) { httpResponse.addHeader(additionalResponseHeader); } } else { httpResponse = new HTTPResponse((short) 200, "OK", true); } // TODO for browser request we might like to return explicite content // types: // contentType = MimeTypeMapping.getMimeTypeForExtension( ext ); httpResponse.addHeader(new HTTPHeader(HTTPHeaderNames.CONTENT_TYPE, "application/binary")); if ( !gRequest.isTigerTreeRequest() ) { httpResponse.addHeader(new HTTPHeader( HTTPHeaderNames.CONTENT_LENGTH, String.valueOf(contentLength))); httpResponse.addHeader(new HTTPHeader( HTTPHeaderNames.CONTENT_RANGE, "bytes " + startOffset + "-" + endOffset + "/" + requestedShareFile.getFileSize())); } // in case of tiger tree request we need to close the connection since // we dont know the content length of the dime here already... // TODO: we could pre calculate the dime length in this case! if ( isPersistentConnection && !gRequest.isTigerTreeRequest() ) { httpResponse.addHeader( new HTTPHeader( HTTPHeaderNames.CONNECTION, "Keep-Alive" ) ); } else { httpResponse.addHeader(new HTTPHeader(HTTPHeaderNames.CONNECTION, "close")); isPersistentConnection = false; } if ( sharedFileURN != null ) { httpResponse.addHeader(new HTTPHeader( GnutellaHeaderNames.X_GNUTELLA_CONTENT_URN, sharedFileURN .getAsString())); } if ( !gRequest.isTigerTreeRequest() ) { addAltLocResponseHeader(httpResponse, requestedShareFile); addPushProxyResponseHeader( httpResponse ); } if ( sharedFileURN != null && !gRequest.isTigerTreeRequest() ) { parseAltLocRequestHeader( requestedShareFile, sharedFileURN ); // add thex download url ShareFileThexData thexData = requestedShareFile.getThexData( true ); if ( thexData != null ) { String thexRootHash = thexData.getRootHash(); HTTPHeader thexHeader = new HTTPHeader( GnutellaHeaderNames.X_THEX_URI, URLUtil.buildName2ResThexURL( sharedFileURN, thexRootHash ) ); httpResponse.addHeader( thexHeader ); } } sendHTTPResponse(httpResponse); socket.setSoTimeout(ServiceManager.sCfg.socketConnectTimeout); // check if we need to count again.. // this is the case if we have no PartialShareFile (same // PartialShareFile is never equal again, since its always a new instance) // and the ShareFile is not equal to the requested file. if ( uploadShareFile != null && !(requestedShareFile instanceof PartialShareFile) && uploadShareFile != requestedShareFile) { isUploadCounted = false; } uploadShareFile = requestedShareFile; minNextPollTime = -1; return true; }
1,116,749
private boolean evaluateHTTPRequest() throws IOException { String logMsg = "HTTP Request: " + httpRequest.buildHTTPRequestString(); NLogger.debug( UploadEngine.class, logMsg); uploadState.addToUploadLog( logMsg ); GnutellaRequest gRequest = httpRequest.getGnutellaRequest(); if ( gRequest == null ) { throw new IOException("Not a Gnutella file request."); } HTTPHeader header; if (gRequest.getURN() == null) { header = httpRequest .getHeader(GnutellaHeaderNames.X_GNUTELLA_CONTENT_URN); if (header != null) { if (URN.isValidURN(header.getValue())) { URN urn = new URN(header.getValue()); gRequest.setContentURN(urn); } } } SocketFacade socket = connection.getSocket(); int port = -1; header = httpRequest.getHeader(GnutellaHeaderNames.LISTEN_IP); if (header == null) { header = httpRequest.getHeader(GnutellaHeaderNames.X_MY_ADDRESS); } if (header != null) { // parse port port = AddressUtils.parsePort(header.getValue()); } if (port <= 0) { port = socket.getRemoteAddress().getPort(); } hostAddress = new DefaultDestAddress(socket.getRemoteAddress().getHostName(), port); UploadManager uploadMgr = UploadManager.getInstance(); HTTPResponse httpResponse; if (!isIPCounted) { boolean succ = uploadMgr.validateAndCountIP(hostAddress); if (!succ) { httpResponse = new HTTPResponse((short) 503, "Upload Limit Reached for IP", true); sendHTTPResponse(httpResponse); return false; } isIPCounted = true; } ShareFile requestedShareFile = findShareFile(gRequest); if (requestedShareFile == null) { httpResponse = new HTTPResponse((short) 404, "File not found", true); sendHTTPResponse(httpResponse); return false; } isUploadQueued = false; if (uploadMgr.isHostBusy()) { header = httpRequest.getHeader(GnutellaHeaderNames.X_QUEUE); if (header == null || !ServiceManager.sCfg.allowUploadQueuing || uploadMgr.isQueueLimitReached()) {// queueing is not supported httpResponse = new HTTPResponse((short) 503, "Upload Limit Reached", true); addAltLocResponseHeader(httpResponse, requestedShareFile); sendHTTPResponse(httpResponse); return false; } isUploadQueued = true; } HTTPHeader rangeHeader = null; HTTPRangeSet uploadRange = null; Range uploadRangeEntry = null; if ( !gRequest.isTigerTreeRequest() ) { rangeHeader = httpRequest.getHeader(HTTPHeaderNames.RANGE); if (rangeHeader != null) { uploadRange = HTTPRangeSet.parseHTTPRangeSet( rangeHeader.getValue(), true); if (uploadRange == null) { // this is not 416 Requested Range Not Satisfiable since // we have a parsing error on the requested range. httpResponse = new HTTPResponse((short) 500, "Requested Range Not Parseable", true); addAltLocResponseHeader(httpResponse, requestedShareFile); sendHTTPResponse(httpResponse); return false; } } else { uploadRange = new HTTPRangeSet(0, HTTPRangeSet.NOT_SET); } uploadRangeEntry = uploadRange.getFirstRange(); short rangeStatus = requestedShareFile .getRangeAvailableStatus(uploadRangeEntry); if (rangeStatus != UploadConstants.RANGE_AVAILABLE) { if (rangeStatus == UploadConstants.RANGE_NOT_AVAILABLE) { httpResponse = new HTTPResponse((short) 503, "Requested Range Not Available", true); } else //case: if ( rangeStatus == // UploadConstants.RANGE_NOT_SATISFIABLE ) { httpResponse = new HTTPResponse((short) 416, "Requested Range Not Satisfiable", true); } if (requestedShareFile instanceof PartialShareFile) { // TODO we could check if the partial file is progressing // and // return a 416 when the range will not come available soon. PartialShareFile pShareFile = (PartialShareFile) requestedShareFile; httpResponse.addHeader(new HTTPHeader( GnutellaHeaderNames.X_AVAILABLE_RANGES, pShareFile .buildXAvailableRangesString())); } addAltLocResponseHeader(httpResponse, requestedShareFile); sendHTTPResponse(httpResponse); return false; } } // everything is right... collect upload infos String vendor = null; header = httpRequest.getHeader(HTTPHeaderNames.USER_AGENT); if (header != null) { vendor = header.getValue(); } else { vendor = ""; } // check for persistent connection... // a connection is assumed to be persistent if its a HTTP 1.1 connection // with no 'Connection: close' header. Or a HTTP connection with // Connection: Keep-Alive header. header = httpRequest.getHeader(HTTPHeaderNames.CONNECTION); if (HTTPRequest.HTTP_11.equals(httpRequest.getHTTPVersion())) { if (header != null && header.getValue().equalsIgnoreCase("CLOSE")) { isPersistentConnection = false; } else { isPersistentConnection = true; } } else { if (header != null && header.getValue().equalsIgnoreCase("KEEP-ALIVE")) { isPersistentConnection = true; } else { isPersistentConnection = false; } } if (isUploadQueued) { // queueing is supported int queuePosition; uploadState.update(hostAddress, vendor); queuePosition = uploadMgr.getQueuedPosition(uploadState) + 1; if ( queuePosition < 0 ) {// missing in queue list queuePosition = uploadMgr.addQueuedUpload(uploadState) + 1; } uploadState.setStatus(UploadConstants.STATUS_QUEUED); int queueLength = uploadMgr.getUploadQueueSize(); int uploadLimit = ServiceManager.sCfg.mMaxUpload; int pollMin = ServiceManager.sCfg.minUploadQueuePollTime; int pollMax = ServiceManager.sCfg.maxUploadQueuePollTime; httpResponse = new HTTPResponse((short) 503, "Remotely Queued", true); addAltLocResponseHeader(httpResponse, requestedShareFile); XQueueParameters xQueueParas = new XQueueParameters(queuePosition, queueLength, uploadLimit, pollMin, pollMax); httpResponse.addHeader(new HTTPHeader(GnutellaHeaderNames.X_QUEUE, xQueueParas.buildHTTPString())); sendHTTPResponse(httpResponse); socket.setSoTimeout(pollMax * 1000); minNextPollTime = System.currentTimeMillis() + pollMin * 1000; return true; } // standard upload... HTTPHeader additionalResponseHeader = null; long contentLength = 0; if ( !gRequest.isTigerTreeRequest() ) { if (requestedShareFile instanceof PartialShareFile) { PartialShareFile pShareFile = (PartialShareFile) requestedShareFile; // call adjusts uploadRangeEntry to fit... pShareFile.findFittingPartForRange(uploadRangeEntry); fileStartOffset = pShareFile.getFileStartOffset(); additionalResponseHeader = new HTTPHeader( GnutellaHeaderNames.X_AVAILABLE_RANGES, pShareFile .buildXAvailableRangesString()); } else { fileStartOffset = uploadRangeEntry .getStartOffset(requestedShareFile.getFileSize()); } startOffset = uploadRangeEntry.getStartOffset(requestedShareFile .getFileSize()); endOffset = uploadRangeEntry.getEndOffset(requestedShareFile .getFileSize()); contentLength = endOffset - startOffset + 1; } URN sharedFileURN = requestedShareFile.getURN(); if ( gRequest.isTigerTreeRequest() ) { uploadState.update(hostAddress, vendor, requestedShareFile.getFileName()); } else { uploadState.update(hostAddress, vendor, requestedShareFile .getFileName(), sharedFileURN, requestedShareFile.getSystemFile(), contentLength); } if ( !uploadMgr.containsUploadState(uploadState) ) { uploadMgr.addUploadState(uploadState); } uploadState.setUploadEngine(this); // form ok response... if ( !gRequest.isTigerTreeRequest() ) { if (startOffset == 0 && endOffset == requestedShareFile.getFileSize() - 1) { httpResponse = new HTTPResponse((short) 200, "OK", true); } else { httpResponse = new HTTPResponse((short) 206, "Partial Content", true); } if (additionalResponseHeader != null) { httpResponse.addHeader(additionalResponseHeader); } } else { httpResponse = new HTTPResponse((short) 200, "OK", true); } // TODO for browser request we might like to return explicite content // types: // contentType = MimeTypeMapping.getMimeTypeForExtension( ext ); httpResponse.addHeader(new HTTPHeader(HTTPHeaderNames.CONTENT_TYPE, "application/binary")); if ( !gRequest.isTigerTreeRequest() ) { httpResponse.addHeader(new HTTPHeader( HTTPHeaderNames.CONTENT_LENGTH, String.valueOf(contentLength))); httpResponse.addHeader(new HTTPHeader( HTTPHeaderNames.CONTENT_RANGE, "bytes " + startOffset + "-" + endOffset + "/" + requestedShareFile.getFileSize())); } // in case of tiger tree request we need to close the connection since // we dont know the content length of the dime here already... // TODO: we could pre calculate the dime length in this case! if ( isPersistentConnection && !gRequest.isTigerTreeRequest() ) { httpResponse.addHeader( new HTTPHeader( HTTPHeaderNames.CONNECTION, "Keep-Alive" ) ); } else { httpResponse.addHeader(new HTTPHeader(HTTPHeaderNames.CONNECTION, "close")); isPersistentConnection = false; } if ( sharedFileURN != null ) { httpResponse.addHeader(new HTTPHeader( GnutellaHeaderNames.X_GNUTELLA_CONTENT_URN, sharedFileURN .getAsString())); } if ( !gRequest.isTigerTreeRequest() ) { addAltLocResponseHeader(httpResponse, requestedShareFile); addPushProxyResponseHeader( httpResponse ); } if ( sharedFileURN != null && !gRequest.isTigerTreeRequest() ) { parseAltLocRequestHeader( requestedShareFile, sharedFileURN ); // add thex download url ShareFileThexData thexData = requestedShareFile.getThexData( true ); if ( thexData != null ) { String thexRootHash = thexData.getRootHash(); HTTPHeader thexHeader = new HTTPHeader( GnutellaHeaderNames.X_THEX_URI, URLUtil.buildName2ResThexURL( sharedFileURN, thexRootHash ) ); httpResponse.addHeader( thexHeader ); } } sendHTTPResponse(httpResponse); socket.setSoTimeout(ServiceManager.sCfg.socketConnectTimeout); // check if we need to count again.. // this is the case if we have no PartialShareFile (same // PartialShareFile is never equal again, since its always a new instance) // and the ShareFile is not equal to the requested file. if ( uploadShareFile != null && !(requestedShareFile instanceof PartialShareFile) && uploadShareFile != requestedShareFile) { isUploadCounted = false; } uploadShareFile = requestedShareFile; minNextPollTime = -1; return true; }
private boolean evaluateHTTPRequest() throws IOException { String logMsg = "HTTP Request: " + httpRequest.buildHTTPRequestString(); NLogger.debug( UploadEngine.class, logMsg); uploadState.addToUploadLog( logMsg ); GnutellaRequest gRequest = httpRequest.getGnutellaRequest(); if ( gRequest == null ) { throw new IOException("Not a Gnutella file request."); } HTTPHeader header; if (gRequest.getURN() == null) { header = httpRequest .getHeader(GnutellaHeaderNames.X_GNUTELLA_CONTENT_URN); if (header != null) { if (URN.isValidURN(header.getValue())) { URN urn = new URN(header.getValue()); gRequest.setContentURN(urn); } } } SocketFacade socket = connection.getSocket(); int port = -1; header = httpRequest.getHeader(GnutellaHeaderNames.LISTEN_IP); if (header == null) { header = httpRequest.getHeader(GnutellaHeaderNames.X_MY_ADDRESS); } if (header != null) { // parse port port = AddressUtils.parsePort(header.getValue()); } if (port <= 0) { port = socket.getRemoteAddress().getPort(); } hostAddress = new DefaultDestAddress(socket.getRemoteAddress().getHostName(), port); UploadManager uploadMgr = UploadManager.getInstance(); HTTPResponse httpResponse; if (!isIPCounted) { boolean succ = uploadMgr.validateAndCountIP(hostAddress); if (!succ) { httpResponse = new HTTPResponse((short) 503, "Upload Limit Reached for IP", true); sendHTTPResponse(httpResponse); return false; } isIPCounted = true; } ShareFile requestedShareFile = findShareFile(gRequest); if (requestedShareFile == null) { httpResponse = new HTTPResponse((short) 404, "File not found", true); sendHTTPResponse(httpResponse); return false; } isUploadQueued = false; if (uploadMgr.isHostBusy()) { header = httpRequest.getHeader(GnutellaHeaderNames.X_QUEUE); if (header == null || !ServiceManager.sCfg.allowUploadQueuing || uploadMgr.isQueueLimitReached()) {// queueing is not supported httpResponse = new HTTPResponse((short) 503, "Upload Limit Reached", true); addAltLocResponseHeader(httpResponse, requestedShareFile); sendHTTPResponse(httpResponse); return false; } isUploadQueued = true; } HTTPHeader rangeHeader = null; HTTPRangeSet uploadRange = null; Range uploadRangeEntry = null; if ( !gRequest.isTigerTreeRequest() ) { rangeHeader = httpRequest.getHeader(HTTPHeaderNames.RANGE); if (rangeHeader != null) { uploadRange = HTTPRangeSet.parseHTTPRangeSet( rangeHeader.getValue(), true); if (uploadRange == null) { // this is not 416 Requested Range Not Satisfiable since // we have a parsing error on the requested range. httpResponse = new HTTPResponse((short) 500, "Requested Range Not Parseable", true); addAltLocResponseHeader(httpResponse, requestedShareFile); sendHTTPResponse(httpResponse); return false; } } else { uploadRange = new HTTPRangeSet(0, HTTPRangeSet.NOT_SET); } uploadRangeEntry = uploadRange.getFirstRange(); short rangeStatus = requestedShareFile .getRangeAvailableStatus(uploadRangeEntry); if (rangeStatus != UploadConstants.RANGE_AVAILABLE) { if (rangeStatus == UploadConstants.RANGE_NOT_AVAILABLE) { httpResponse = new HTTPResponse((short) 503, "Requested Range Not Available", true); } else //case: if ( rangeStatus == // UploadConstants.RANGE_NOT_SATISFIABLE ) { httpResponse = new HTTPResponse((short) 416, "Requested Range Not Satisfiable", true); } if (requestedShareFile instanceof PartialShareFile) { // TODO we could check if the partial file is progressing // and // return a 416 when the range will not come available soon. PartialShareFile pShareFile = (PartialShareFile) requestedShareFile; httpResponse.addHeader(new HTTPHeader( GnutellaHeaderNames.X_AVAILABLE_RANGES, pShareFile .buildXAvailableRangesString())); } addAltLocResponseHeader(httpResponse, requestedShareFile); sendHTTPResponse(httpResponse); return false; } } // everything is right... collect upload infos String vendor = null; header = httpRequest.getHeader(HTTPHeaderNames.USER_AGENT); if (header != null) { vendor = header.getValue(); } else { vendor = ""; } // check for persistent connection... // a connection is assumed to be persistent if its a HTTP 1.1 connection // with no 'Connection: close' header. Or a HTTP connection with // Connection: Keep-Alive header. header = httpRequest.getHeader(HTTPHeaderNames.CONNECTION); if (HTTPRequest.HTTP_11.equals(httpRequest.getHTTPVersion())) { if (header != null && header.getValue().equalsIgnoreCase("CLOSE")) { isPersistentConnection = false; } else { isPersistentConnection = true; } } else { if (header != null && header.getValue().equalsIgnoreCase("KEEP-ALIVE")) { isPersistentConnection = true; } else { isPersistentConnection = false; } } if (isUploadQueued) { // queueing is supported int queuePosition; uploadState.update(hostAddress, vendor); queuePosition = uploadMgr.getQueuedPosition(uploadState) + 1; if ( queuePosition < 0 ) {// missing in queue list queuePosition = uploadMgr.addQueuedUpload(uploadState); } uploadState.setStatus(UploadConstants.STATUS_QUEUED); int queueLength = uploadMgr.getUploadQueueSize(); int uploadLimit = ServiceManager.sCfg.mMaxUpload; int pollMin = ServiceManager.sCfg.minUploadQueuePollTime; int pollMax = ServiceManager.sCfg.maxUploadQueuePollTime; httpResponse = new HTTPResponse((short) 503, "Remotely Queued", true); addAltLocResponseHeader(httpResponse, requestedShareFile); XQueueParameters xQueueParas = new XQueueParameters(queuePosition, queueLength, uploadLimit, pollMin, pollMax); httpResponse.addHeader(new HTTPHeader(GnutellaHeaderNames.X_QUEUE, xQueueParas.buildHTTPString())); sendHTTPResponse(httpResponse); socket.setSoTimeout(pollMax * 1000); minNextPollTime = System.currentTimeMillis() + pollMin * 1000; return true; } // standard upload... HTTPHeader additionalResponseHeader = null; long contentLength = 0; if ( !gRequest.isTigerTreeRequest() ) { if (requestedShareFile instanceof PartialShareFile) { PartialShareFile pShareFile = (PartialShareFile) requestedShareFile; // call adjusts uploadRangeEntry to fit... pShareFile.findFittingPartForRange(uploadRangeEntry); fileStartOffset = pShareFile.getFileStartOffset(); additionalResponseHeader = new HTTPHeader( GnutellaHeaderNames.X_AVAILABLE_RANGES, pShareFile .buildXAvailableRangesString()); } else { fileStartOffset = uploadRangeEntry .getStartOffset(requestedShareFile.getFileSize()); } startOffset = uploadRangeEntry.getStartOffset(requestedShareFile .getFileSize()); endOffset = uploadRangeEntry.getEndOffset(requestedShareFile .getFileSize()); contentLength = endOffset - startOffset + 1; } URN sharedFileURN = requestedShareFile.getURN(); if ( gRequest.isTigerTreeRequest() ) { uploadState.update(hostAddress, vendor, requestedShareFile.getFileName()); } else { uploadState.update(hostAddress, vendor, requestedShareFile .getFileName(), sharedFileURN, requestedShareFile.getSystemFile(), contentLength); } if ( !uploadMgr.containsUploadState(uploadState) ) { uploadMgr.addUploadState(uploadState); } uploadState.setUploadEngine(this); // form ok response... if ( !gRequest.isTigerTreeRequest() ) { if (startOffset == 0 && endOffset == requestedShareFile.getFileSize() - 1) { httpResponse = new HTTPResponse((short) 200, "OK", true); } else { httpResponse = new HTTPResponse((short) 206, "Partial Content", true); } if (additionalResponseHeader != null) { httpResponse.addHeader(additionalResponseHeader); } } else { httpResponse = new HTTPResponse((short) 200, "OK", true); } // TODO for browser request we might like to return explicite content // types: // contentType = MimeTypeMapping.getMimeTypeForExtension( ext ); httpResponse.addHeader(new HTTPHeader(HTTPHeaderNames.CONTENT_TYPE, "application/binary")); if ( !gRequest.isTigerTreeRequest() ) { httpResponse.addHeader(new HTTPHeader( HTTPHeaderNames.CONTENT_LENGTH, String.valueOf(contentLength))); httpResponse.addHeader(new HTTPHeader( HTTPHeaderNames.CONTENT_RANGE, "bytes " + startOffset + "-" + endOffset + "/" + requestedShareFile.getFileSize())); } // in case of tiger tree request we need to close the connection since // we dont know the content length of the dime here already... // TODO: we could pre calculate the dime length in this case! if ( isPersistentConnection && !gRequest.isTigerTreeRequest() ) { httpResponse.addHeader( new HTTPHeader( HTTPHeaderNames.CONNECTION, "Keep-Alive" ) ); } else { httpResponse.addHeader(new HTTPHeader(HTTPHeaderNames.CONNECTION, "close")); isPersistentConnection = false; } if ( sharedFileURN != null ) { httpResponse.addHeader(new HTTPHeader( GnutellaHeaderNames.X_GNUTELLA_CONTENT_URN, sharedFileURN .getAsString())); } if ( !gRequest.isTigerTreeRequest() ) { addAltLocResponseHeader(httpResponse, requestedShareFile); addPushProxyResponseHeader( httpResponse ); } if ( sharedFileURN != null && !gRequest.isTigerTreeRequest() ) { parseAltLocRequestHeader( requestedShareFile, sharedFileURN ); // add thex download url ShareFileThexData thexData = requestedShareFile.getThexData( true ); if ( thexData != null ) { String thexRootHash = thexData.getRootHash(); HTTPHeader thexHeader = new HTTPHeader( GnutellaHeaderNames.X_THEX_URI, URLUtil.buildName2ResThexURL( sharedFileURN, thexRootHash ) ); httpResponse.addHeader( thexHeader ); } } sendHTTPResponse(httpResponse); socket.setSoTimeout(ServiceManager.sCfg.socketConnectTimeout); // check if we need to count again.. // this is the case if we have no PartialShareFile (same // PartialShareFile is never equal again, since its always a new instance) // and the ShareFile is not equal to the requested file. if ( uploadShareFile != null && !(requestedShareFile instanceof PartialShareFile) && uploadShareFile != requestedShareFile) { isUploadCounted = false; } uploadShareFile = requestedShareFile; minNextPollTime = -1; return true; }
1,116,750
private void sendBinaryData() throws IOException { NLogger.debug(UploadEngine.class, "About to send binary range: " + startOffset + " to " + endOffset); uploadState.addToUploadLog( "About to send binary range: " + startOffset + " to " + endOffset ); // the upload is actually starting now.. // if not yet done we are counting this upload. if (!isUploadCounted) { // count upload even if upload is just starting and not finished // yet. // swarming uploads fail often anyway. uploadShareFile.incUploadCount(); // Increment the completed uploads count StatisticsManager statMgr = StatisticsManager.getInstance(); SimpleStatisticProvider provider = (SimpleStatisticProvider) statMgr .getStatisticProvider(StatisticProviderConstants.SESSION_UPLOAD_COUNT_PROVIDER); provider.increment(1); isUploadCounted = true; } uploadState.setStatus(UploadConstants.STATUS_UPLOADING); // open file File sourceFile = uploadState.getUploadFile(); raFile = new RandomAccessFile(sourceFile, "r"); raFile.seek(fileStartOffset); BandwidthController throttleController = BandwidthManager.getInstance() .getUploadBandwidthController(); long lengthToUpload = endOffset - startOffset + 1; long lengthUploaded = 0; int lengthRead = -1; int likeToSend; OutputStream outStream = connection.getOutputStream(); byte[] buffer = new byte[BUFFER_LENGTH]; while (lengthToUpload > 0) { // make sure we dont send more then requested likeToSend = (int) Math.min(lengthToUpload, (long) BUFFER_LENGTH); // we may be throttled to less than this amount int available = throttleController.getAvailableByteCount( true ); int ableToSend = Math.min( likeToSend, available ); if ( NLogger.isDebugEnabled( UploadEngine.class ) ) { NLogger.debug( UploadEngine.class, "Reading in " + ableToSend + " bytes at " + raFile.getFilePointer() + " from " + sourceFile.getName()); } lengthRead = raFile.read(buffer, 0, ableToSend); // lengthRead should equal ableToSend. I can't see a reason // why it wouldn't.... if (lengthRead == -1) { break; } outStream.write(buffer, 0, lengthRead); lengthToUpload -= lengthRead; lengthUploaded += lengthRead; uploadState.setTransferredDataSize(lengthUploaded); } uploadState.setStatus(UploadConstants.STATUS_COMPLETED); }
private void sendBinaryData() throws IOException { NLogger.debug(UploadEngine.class, "About to send binary range: " + startOffset + " to " + endOffset); uploadState.addToUploadLog( "About to send binary range: " + startOffset + " to " + endOffset ); // the upload is actually starting now.. // if not yet done we are counting this upload. if (!isUploadCounted) { // count upload even if upload is just starting and not finished // yet. // swarming uploads fail often anyway. uploadShareFile.incUploadCount(); // Increment the completed uploads count StatisticsManager statMgr = StatisticsManager.getInstance(); SimpleStatisticProvider provider = (SimpleStatisticProvider) statMgr .getStatisticProvider(StatisticProviderConstants.SESSION_UPLOAD_COUNT_PROVIDER); provider.increment(1); isUploadCounted = true; } uploadState.setStatus(UploadConstants.STATUS_UPLOADING); // open file File sourceFile = uploadState.getUploadFile(); raFile = new RandomAccessFile(sourceFile, "r"); raFile.seek(fileStartOffset); BandwidthController throttleController = BandwidthManager.getInstance() .getUploadBandwidthController(); long lengthToUpload = endOffset - startOffset + 1; long lengthUploaded = 0; int lengthRead = -1; int likeToSend; OutputStream outStream = connection.getOutputStream(); byte[] buffer = new byte[BUFFER_LENGTH]; while (lengthToUpload > 0) { // make sure we dont send more then requested likeToSend = (int) Math.min(lengthToUpload, (long) BUFFER_LENGTH); // we may be throttled to less than this amount int available = throttleController.getAvailableByteCount( true ); int ableToSend = Math.min( likeToSend, available ); if ( NLogger.isDebugEnabled( UploadEngine.class ) ) { NLogger.debug( UploadEngine.class, "Reading in " + ableToSend + " bytes at " + raFile.getFilePointer() + " from " + sourceFile.getName()); } lengthRead = raFile.read(buffer, 0, ableToSend); // lengthRead should equal ableToSend. I can't see a reason // why it wouldn't.... if (lengthRead == -1) { break; } outStream.write(buffer, 0, lengthRead); lengthToUpload -= lengthRead; lengthUploaded += lengthRead; uploadState.setTransferredDataSize(lengthUploaded); } uploadState.setStatus(UploadConstants.STATUS_COMPLETED); }
1,116,752
public synchronized int getAvailableByteCount( boolean blockTillAvailable ) { updateWindow( blockTillAvailable ); int bytesAllowed = bytesRemaining; // If there is another controller we are chained to, call it. if( nextContollerInChain != null ) { bytesAllowed = Math.min( bytesAllowed, nextContollerInChain.getAvailableByteCount( blockTillAvailable ) ); } short logLevel = NLogger.LOG_LEVEL_DEBUG; if ( bytesRemaining < 0 ) { logLevel = NLogger.LOG_LEVEL_ERROR; } if ( NLogger.isEnabled( logLevel, NLoggerNames.BANDWIDTH ) ) { NLogger.log( logLevel, NLoggerNames.BANDWIDTH, "["+controllerName + "] Available byte count " + bytesAllowed + "bps - Remaining: " + bytesRemaining + "."); } return bytesAllowed; }
public synchronized int getAvailableByteCount( int maxToRequest, boolean blockTillAvailable, boolean markBytesUsed ) throws IOException { updateWindow( blockTillAvailable ); int bytesAllowed = bytesRemaining; // If there is another controller we are chained to, call it. if( nextContollerInChain != null ) { bytesAllowed = Math.min( bytesAllowed, nextContollerInChain.getAvailableByteCount( blockTillAvailable ) ); } short logLevel = NLogger.LOG_LEVEL_DEBUG; if ( bytesRemaining < 0 ) { logLevel = NLogger.LOG_LEVEL_ERROR; } if ( NLogger.isEnabled( logLevel, NLoggerNames.BANDWIDTH ) ) { NLogger.log( logLevel, NLoggerNames.BANDWIDTH, "["+controllerName + "] Available byte count " + bytesAllowed + "bps - Remaining: " + bytesRemaining + "."); } return bytesAllowed; }
1,116,753
public synchronized int getAvailableByteCount( boolean blockTillAvailable ) { updateWindow( blockTillAvailable ); int bytesAllowed = bytesRemaining; // If there is another controller we are chained to, call it. if( nextContollerInChain != null ) { bytesAllowed = Math.min( bytesAllowed, nextContollerInChain.getAvailableByteCount( blockTillAvailable ) ); } short logLevel = NLogger.LOG_LEVEL_DEBUG; if ( bytesRemaining < 0 ) { logLevel = NLogger.LOG_LEVEL_ERROR; } if ( NLogger.isEnabled( logLevel, NLoggerNames.BANDWIDTH ) ) { NLogger.log( logLevel, NLoggerNames.BANDWIDTH, "["+controllerName + "] Available byte count " + bytesAllowed + "bps - Remaining: " + bytesRemaining + "."); } return bytesAllowed; }
public synchronized int getAvailableByteCount( boolean blockTillAvailable ) { updateWindow( blockTillAvailable ); int bytesAllowed = Math.max( 0, Math.min( maxToRequest, bytesRemaining ) ); // If there is another controller we are chained to, call it. if( nextContollerInChain != null ) { bytesAllowed = Math.min( bytesAllowed, nextContollerInChain.getAvailableByteCount( blockTillAvailable ) ); } short logLevel = NLogger.LOG_LEVEL_DEBUG; if ( bytesRemaining < 0 ) { logLevel = NLogger.LOG_LEVEL_ERROR; } if ( NLogger.isEnabled( logLevel, NLoggerNames.BANDWIDTH ) ) { NLogger.log( logLevel, NLoggerNames.BANDWIDTH, "["+controllerName + "] Available byte count " + bytesAllowed + "bps - Remaining: " + bytesRemaining + "."); } return bytesAllowed; }
1,116,754
public synchronized int getAvailableByteCount( boolean blockTillAvailable ) { updateWindow( blockTillAvailable ); int bytesAllowed = bytesRemaining; // If there is another controller we are chained to, call it. if( nextContollerInChain != null ) { bytesAllowed = Math.min( bytesAllowed, nextContollerInChain.getAvailableByteCount( blockTillAvailable ) ); } short logLevel = NLogger.LOG_LEVEL_DEBUG; if ( bytesRemaining < 0 ) { logLevel = NLogger.LOG_LEVEL_ERROR; } if ( NLogger.isEnabled( logLevel, NLoggerNames.BANDWIDTH ) ) { NLogger.log( logLevel, NLoggerNames.BANDWIDTH, "["+controllerName + "] Available byte count " + bytesAllowed + "bps - Remaining: " + bytesRemaining + "."); } return bytesAllowed; }
public synchronized int getAvailableByteCount( boolean blockTillAvailable ) { updateWindow( blockTillAvailable ); int bytesAllowed = bytesRemaining; // If there is another controller we are chained to, call it. if( nextContollerInChain != null ) { bytesAllowed = Math.min( bytesAllowed, nextContollerInChain.getAvailableByteCount( blockTillAvailable ) ); } short logLevel = NLogger.LOG_LEVEL_DEBUG; if ( bytesRemaining < 0 ) { logLevel = NLogger.LOG_LEVEL_ERROR; } if ( NLogger.isEnabled( logLevel, NLoggerNames.BANDWIDTH ) ) { NLogger.log( logLevel, NLoggerNames.BANDWIDTH, "["+controllerName + "] Available byte count " + bytesAllowed + "bps - Remaining: " + bytesRemaining + "."); } return bytesAllowed; }
1,116,755
public void actionPerformed(ActionEvent ev) { Object o = ev.getSource(); String font = fontComboModel.getSelectedItem().toString(); String fontSize = sizeSpin.getValue().toString(); String printOptions = " <PRINT FONTSIZE=\"" + fontSize + "pt\" FONTFACE=\"" + font + "\"/>\n"; if (o == prevButton) { File file = new File("print.html"); try { app.saveAsHTML(file, "ca/strangebrew/data/recipeToHtml.xslt", printOptions); } catch (Exception e1) { // TODO Auto-generated catch block e1.printStackTrace(); } String urlString; try { urlString = "file://" + file.getCanonicalPath(); Debug.print(urlString); AbstractLogger logger = new SystemLogger(); BrowserLauncher launcher; launcher = new BrowserLauncher(logger); BrowserLauncherRunner runner = new BrowserLauncherRunner(launcher, urlString, null); Thread launcherThread = new Thread(runner); launcherThread.start(); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (BrowserLaunchingInitializingException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (UnsupportedOperatingSystemException e) { // TODO Auto-generated catch block e.printStackTrace(); } } setVisible(false); dispose(); }
public void actionPerformed(ActionEvent ev) { Object o = ev.getSource(); String font = fontComboModel.getSelectedItem().toString(); String fontSize = sizeSpin.getValue().toString(); String printOptions = " <PRINT FONTSIZE=\"" + fontSize + "pt\" FONTFACE=\"" + font + "\"/>\n"; if (o == prevButton) { File file = new File("print.html"); try { app.saveAsHTML(file, "recipeToHtml.xslt", printOptions); } catch (Exception e1) { // TODO Auto-generated catch block e1.printStackTrace(); } String urlString; try { urlString = "file://" + file.getCanonicalPath(); Debug.print(urlString); AbstractLogger logger = new SystemLogger(); BrowserLauncher launcher; launcher = new BrowserLauncher(logger); BrowserLauncherRunner runner = new BrowserLauncherRunner(launcher, urlString, null); Thread launcherThread = new Thread(runner); launcherThread.start(); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (BrowserLaunchingInitializingException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (UnsupportedOperatingSystemException e) { // TODO Auto-generated catch block e.printStackTrace(); } } setVisible(false); dispose(); }
1,116,757
public Complex getComplexValue() { return calculateComplexValue((Complex) group.getRootVal()); }
public Complex getComplexValue() { return calculateComplexValue(group.getRootVal()); }
1,116,758
public synchronized void pushData(SeisDataChangeEvent sdce) { AmpConfigData dssData = (AmpConfigData)ampData.get(sdce.getSource()); dssData.addSeismograms(sdce.getSeismos()); this.seismos = null; calculateAmp(); recalculateAmp(); fireAmpEvent(); }
public synchronized void pushData(SeisDataChangeEvent sdce) { AmpConfigData dssData = (AmpConfigData)ampData.get(sdce.getSource()); dssData.addSeismograms(sdce.getSeismos()); this.seismos = null; calculateAmp(); recalculateAmp(); fireAmpEvent(); }
1,116,759
public MatrixValueI calcValue(MatrixValueI res, MatrixValueI lhs) throws ParseException { if(!(res instanceof Scaler)) throw new ParseException("trace: result must be a scaler"); if(!(lhs instanceof Matrix)) throw new ParseException("trace: argument must be a matrix"); Matrix mat = (Matrix) lhs; if( mat.getNumRows()!= mat.getNumCols()) throw new ParseException("trace: argument must be a square matrix "+mat); if(mat.getNumRows() == 2) { res.setEle(0,add.add(mat.getEle(0,0),mat.getEle(1,1))); } else if(mat.getNumRows() == 3) { res.setEle(0,add.add(mat.getEle(0,0),add.add(mat.getEle(1,1),mat.getEle(2,2)))); } else { Object val = Scaler.getInstance(mat.getEle(0,0)); for(int i=1;i<mat.getNumRows();++i) val = add.add(val,mat.getEle(i,i)); res.setEle(0,val); } return res; }
public MatrixValueI calcValue(MatrixValueI res, MatrixValueI lhs) throws ParseException { if(!(res instanceof Scaler)) throw new ParseException("trace: result must be a scaler"); if(!(lhs instanceof Matrix)) throw new ParseException("trace: argument must be a matrix"); Matrix mat = (Matrix) lhs; if( mat.getNumRows()!= mat.getNumCols()) throw new ParseException("trace: argument must be a square matrix "+mat); if(mat.getNumRows() == 2) { res.setEle(0,add.add(mat.getEle(0,0),mat.getEle(1,1))); } else if(mat.getNumRows() == 3) { res.setEle(0,add.add(mat.getEle(0,0),add.add(mat.getEle(1,1),mat.getEle(2,2)))); } else { Object val = mat.getEle(0,0); for(int i=1;i<mat.getNumRows();++i) val = add.add(val,mat.getEle(i,i)); res.setEle(0,val); } return res; }
1,116,760
public void testFindUserRole() { // write list List<UserRole> userRoleList = writeUserRole(); // read UserRole userRole = userRoleList.get((int) Math.random()*userRoleList.size()); assertEquals(userRole, authorizationDao.findUserRoleByNaturalId(userRole.getUser(), userRole.getService(), userRole.getServiceExtension())); }
public void testFindUserRole() { // write list List<UserRole> userRoleList = writeUserRole(); // read UserRole userRole = userRoleList.get((int) Math.random()*userRoleList.size()); assertEquals(userRole, authorizationDao.findUserRoleByNaturalId(userRole.getUserGroup(), userRole.getService(), userRole.getServiceExtension())); }
1,116,761
public void testPersistUserRole() { //write UserRole userRole = createAndPersistUserRole(authorizationDao); hibernateTemplate.flush(); //read assertEquals(userRole, authorizationDao.findUserRoleByNaturalId(userRole.getUser(), userRole.getService(), userRole.getServiceExtension())); }
public void testPersistUserRole() { //write UserRole userRole = createAndPersistUserRole(authorizationDao); hibernateTemplate.flush(); //read assertEquals(userRole, authorizationDao.findUserRoleByNaturalId(userRole.getUserGroup(), userRole.getService(), userRole.getServiceExtension())); }
1,116,762
public MatrixJep() { super(); nf = new MatrixNodeFactory(); symTab = new DSymbolTable(mvf); opSet = new MatrixOperatorSet(); this.parser.setInitialTokenManagerState(Parser.NO_DOT_IN_IDENTIFIERS); Operator tens = ((MatrixOperatorSet) opSet).getMList(); pv.addSpecialRule(tens,(PrintVisitor.PrintRulesI) tens.getPFMC()); addDiffRule(new PassThroughDiffRule(tens.getName(),tens.getPFMC())); Operator cross = ((MatrixOperatorSet) opSet).getCross(); addDiffRule(new MultiplyDiffRule(cross.getName(),cross)); Operator dot = ((MatrixOperatorSet) opSet).getDot(); addDiffRule(new MultiplyDiffRule(dot.getName(),dot)); }
public MatrixJep() { super(); nf = new MatrixNodeFactory(); symTab = new DSymbolTable(mvf); opSet = new MatrixOperatorSet(); this.parser.setInitialTokenManagerState(ParserConstants.NO_DOT_IN_IDENTIFIERS); Operator tens = ((MatrixOperatorSet) opSet).getMList(); pv.addSpecialRule(tens,(PrintVisitor.PrintRulesI) tens.getPFMC()); addDiffRule(new PassThroughDiffRule(tens.getName(),tens.getPFMC())); Operator cross = ((MatrixOperatorSet) opSet).getCross(); addDiffRule(new MultiplyDiffRule(cross.getName(),cross)); Operator dot = ((MatrixOperatorSet) opSet).getDot(); addDiffRule(new MultiplyDiffRule(dot.getName(),dot)); }
1,116,763
public Object evaluate(Node node) throws ParseException { Object res = mev.evaluate((MatrixNodeI) node,this); if(res instanceof Scaler) return ((Scaler) res).getEle(0); else return res; }
public Object evaluate(Node node) throws ParseException { Object res = mev.evaluate((MatrixNodeI) node,this); if(res instanceof Scaler) return ((Scaler) res).getEle(0); else return res; }
1,116,764
public Object getValueAsObject() { try { Object res = mev.evaluate((MatrixNodeI) getTopNode(),this); if(res instanceof Scaler) return ((Scaler) res).getEle(0); else return res; } catch(Exception e) { this.errorList.addElement("Error during evaluation:"); this.errorList.addElement(e.getMessage()); return null; } }
public Object getValueAsObject() { try { Object res = mev.evaluate((MatrixNodeI) getTopNode(),this); if(res instanceof Scaler) return ((Scaler) res).getEle(0); else return res; } catch(Exception e) { this.errorList.addElement("Error during evaluation:"); this.errorList.addElement(e.getMessage()); return null; } }
1,116,765
public synchronized void doWs( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException { File dir = getWorkspace().getLocal(); if(!dir.exists()) { // if there's no workspace, report a nice error message rsp.forward(this,"noWorkspace",req); } else { serveFile(req, rsp, dir, "folder.gif", true); } }
public void doWs( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException { File dir = getWorkspace().getLocal(); if(!dir.exists()) { // if there's no workspace, report a nice error message rsp.forward(this,"noWorkspace",req); } else { serveFile(req, rsp, dir, "folder.gif", true); } }
1,116,766
public void saveAsHTML(File f, String xslt, String options) throws Exception { // save file as xml, then transform it to html File tmp = new File("tmp.xml"); FileWriter out = new FileWriter(tmp); out.write(myRecipe.toXML(options)); out.close(); // find the xslt stylesheet in the classpath // URL xsltUrl = getClass().getClassLoader().getResource(xslt); String path = SBStringUtils.getAppPath("data"); File xsltFile = new File(path + xslt); FileOutputStream output = new FileOutputStream(f); XmlTransformer.writeStream(tmp, xsltFile, output); // tmp.delete(); }
public void saveAsHTML(File f, String xslt, String options) throws Exception { // save file as xml, then transform it to html File tmp = new File("tmp.xml"); FileWriter out = new FileWriter(tmp); out.write(myRecipe.toXML(options)); out.close(); // find the xslt stylesheet in the classpath // URL xsltUrl = getClass().getClassLoader().getResource(xslt); String path = SBStringUtils.getAppPath("data"); File xsltFile = new File(path, xslt); FileOutputStream output = new FileOutputStream(f); XmlTransformer.writeStream(tmp, xsltFile, output); // tmp.delete(); }
1,116,767
public void printIntroText() { println("DJep: differention in JEP. eg. diff(x^2,x)"); printStdHelp(); }
public void printIntroText() { println("DJep: differentation in JEP. eg. diff(x^2,x)"); printStdHelp(); }
1,116,768
public void processEquation(Node node) throws ParseException { DJep j = (DJep) this.j; if(verbose) { print("Parsed:\t\t"); println(j.toString(node)); } Node processed = j.preprocess(node); if(verbose) { print("Processed:\t"); println(j.toString(processed)); } Node simp = j.simplify(processed); if(verbose) print("Simplified:\t"); println(j.toString(simp)); if(verbose) { print("Full Brackets, no variable expansion:\n\t\t"); j.getPrintVisitor().setMode(PrintVisitor.FULL_BRACKET,true); j.getPrintVisitor().setMode(DPrintVisitor.PRINT_PARTIAL_EQNS,false); println(j.toString(simp)); j.getPrintVisitor().setMode(DPrintVisitor.PRINT_PARTIAL_EQNS,true); j.getPrintVisitor().setMode(PrintVisitor.FULL_BRACKET,false); } Object val = j.evaluate(simp); String s = j.getPrintVisitor().formatValue(val); println("Value:\t\t"+s); }
public void processEquation(Node node) throws ParseException { DJep dj = (DJep) this.j; if(verbose) { print("Parsed:\t\t"); println(j.toString(node)); } Node processed = j.preprocess(node); if(verbose) { print("Processed:\t"); println(j.toString(processed)); } Node simp = j.simplify(processed); if(verbose) print("Simplified:\t"); println(j.toString(simp)); if(verbose) { print("Full Brackets, no variable expansion:\n\t\t"); j.getPrintVisitor().setMode(PrintVisitor.FULL_BRACKET,true); j.getPrintVisitor().setMode(DPrintVisitor.PRINT_PARTIAL_EQNS,false); println(j.toString(simp)); j.getPrintVisitor().setMode(DPrintVisitor.PRINT_PARTIAL_EQNS,true); j.getPrintVisitor().setMode(PrintVisitor.FULL_BRACKET,false); } Object val = j.evaluate(simp); String s = j.getPrintVisitor().formatValue(val); println("Value:\t\t"+s); }
1,116,769
public void processEquation(Node node) throws ParseException { DJep j = (DJep) this.j; if(verbose) { print("Parsed:\t\t"); println(j.toString(node)); } Node processed = j.preprocess(node); if(verbose) { print("Processed:\t"); println(j.toString(processed)); } Node simp = j.simplify(processed); if(verbose) print("Simplified:\t"); println(j.toString(simp)); if(verbose) { print("Full Brackets, no variable expansion:\n\t\t"); j.getPrintVisitor().setMode(PrintVisitor.FULL_BRACKET,true); j.getPrintVisitor().setMode(DPrintVisitor.PRINT_PARTIAL_EQNS,false); println(j.toString(simp)); j.getPrintVisitor().setMode(DPrintVisitor.PRINT_PARTIAL_EQNS,true); j.getPrintVisitor().setMode(PrintVisitor.FULL_BRACKET,false); } Object val = j.evaluate(simp); String s = j.getPrintVisitor().formatValue(val); println("Value:\t\t"+s); }
public void processEquation(Node node) throws ParseException { DJep j = (DJep) this.j; if(verbose) { print("Parsed:\t\t"); println(dj.toString(node)); } Node processed = j.preprocess(node); if(verbose) { print("Processed:\t"); println(j.toString(processed)); } Node simp = j.simplify(processed); if(verbose) print("Simplified:\t"); println(j.toString(simp)); if(verbose) { print("Full Brackets, no variable expansion:\n\t\t"); j.getPrintVisitor().setMode(PrintVisitor.FULL_BRACKET,true); j.getPrintVisitor().setMode(DPrintVisitor.PRINT_PARTIAL_EQNS,false); println(j.toString(simp)); j.getPrintVisitor().setMode(DPrintVisitor.PRINT_PARTIAL_EQNS,true); j.getPrintVisitor().setMode(PrintVisitor.FULL_BRACKET,false); } Object val = j.evaluate(simp); String s = j.getPrintVisitor().formatValue(val); println("Value:\t\t"+s); }
1,116,770
public void processEquation(Node node) throws ParseException { DJep j = (DJep) this.j; if(verbose) { print("Parsed:\t\t"); println(j.toString(node)); } Node processed = j.preprocess(node); if(verbose) { print("Processed:\t"); println(j.toString(processed)); } Node simp = j.simplify(processed); if(verbose) print("Simplified:\t"); println(j.toString(simp)); if(verbose) { print("Full Brackets, no variable expansion:\n\t\t"); j.getPrintVisitor().setMode(PrintVisitor.FULL_BRACKET,true); j.getPrintVisitor().setMode(DPrintVisitor.PRINT_PARTIAL_EQNS,false); println(j.toString(simp)); j.getPrintVisitor().setMode(DPrintVisitor.PRINT_PARTIAL_EQNS,true); j.getPrintVisitor().setMode(PrintVisitor.FULL_BRACKET,false); } Object val = j.evaluate(simp); String s = j.getPrintVisitor().formatValue(val); println("Value:\t\t"+s); }
public void processEquation(Node node) throws ParseException { DJep j = (DJep) this.j; if(verbose) { print("Parsed:\t\t"); println(j.toString(node)); } Node processed = dj.preprocess(node); if(verbose) { print("Processed:\t"); println(j.toString(processed)); } Node simp = j.simplify(processed); if(verbose) print("Simplified:\t"); println(j.toString(simp)); if(verbose) { print("Full Brackets, no variable expansion:\n\t\t"); j.getPrintVisitor().setMode(PrintVisitor.FULL_BRACKET,true); j.getPrintVisitor().setMode(DPrintVisitor.PRINT_PARTIAL_EQNS,false); println(j.toString(simp)); j.getPrintVisitor().setMode(DPrintVisitor.PRINT_PARTIAL_EQNS,true); j.getPrintVisitor().setMode(PrintVisitor.FULL_BRACKET,false); } Object val = j.evaluate(simp); String s = j.getPrintVisitor().formatValue(val); println("Value:\t\t"+s); }
1,116,771
public void processEquation(Node node) throws ParseException { DJep j = (DJep) this.j; if(verbose) { print("Parsed:\t\t"); println(j.toString(node)); } Node processed = j.preprocess(node); if(verbose) { print("Processed:\t"); println(j.toString(processed)); } Node simp = j.simplify(processed); if(verbose) print("Simplified:\t"); println(j.toString(simp)); if(verbose) { print("Full Brackets, no variable expansion:\n\t\t"); j.getPrintVisitor().setMode(PrintVisitor.FULL_BRACKET,true); j.getPrintVisitor().setMode(DPrintVisitor.PRINT_PARTIAL_EQNS,false); println(j.toString(simp)); j.getPrintVisitor().setMode(DPrintVisitor.PRINT_PARTIAL_EQNS,true); j.getPrintVisitor().setMode(PrintVisitor.FULL_BRACKET,false); } Object val = j.evaluate(simp); String s = j.getPrintVisitor().formatValue(val); println("Value:\t\t"+s); }
public void processEquation(Node node) throws ParseException { DJep j = (DJep) this.j; if(verbose) { print("Parsed:\t\t"); println(j.toString(node)); } Node processed = j.preprocess(node); if(verbose) { print("Processed:\t"); println(dj.toString(processed)); } Node simp = j.simplify(processed); if(verbose) print("Simplified:\t"); println(j.toString(simp)); if(verbose) { print("Full Brackets, no variable expansion:\n\t\t"); j.getPrintVisitor().setMode(PrintVisitor.FULL_BRACKET,true); j.getPrintVisitor().setMode(DPrintVisitor.PRINT_PARTIAL_EQNS,false); println(j.toString(simp)); j.getPrintVisitor().setMode(DPrintVisitor.PRINT_PARTIAL_EQNS,true); j.getPrintVisitor().setMode(PrintVisitor.FULL_BRACKET,false); } Object val = j.evaluate(simp); String s = j.getPrintVisitor().formatValue(val); println("Value:\t\t"+s); }
1,116,772
public void processEquation(Node node) throws ParseException { DJep j = (DJep) this.j; if(verbose) { print("Parsed:\t\t"); println(j.toString(node)); } Node processed = j.preprocess(node); if(verbose) { print("Processed:\t"); println(j.toString(processed)); } Node simp = j.simplify(processed); if(verbose) print("Simplified:\t"); println(j.toString(simp)); if(verbose) { print("Full Brackets, no variable expansion:\n\t\t"); j.getPrintVisitor().setMode(PrintVisitor.FULL_BRACKET,true); j.getPrintVisitor().setMode(DPrintVisitor.PRINT_PARTIAL_EQNS,false); println(j.toString(simp)); j.getPrintVisitor().setMode(DPrintVisitor.PRINT_PARTIAL_EQNS,true); j.getPrintVisitor().setMode(PrintVisitor.FULL_BRACKET,false); } Object val = j.evaluate(simp); String s = j.getPrintVisitor().formatValue(val); println("Value:\t\t"+s); }
public void processEquation(Node node) throws ParseException { DJep j = (DJep) this.j; if(verbose) { print("Parsed:\t\t"); println(j.toString(node)); } Node processed = j.preprocess(node); if(verbose) { print("Processed:\t"); println(j.toString(processed)); } Node simp = dj.simplify(processed); if(verbose) print("Simplified:\t"); println(j.toString(simp)); if(verbose) { print("Full Brackets, no variable expansion:\n\t\t"); j.getPrintVisitor().setMode(PrintVisitor.FULL_BRACKET,true); j.getPrintVisitor().setMode(DPrintVisitor.PRINT_PARTIAL_EQNS,false); println(j.toString(simp)); j.getPrintVisitor().setMode(DPrintVisitor.PRINT_PARTIAL_EQNS,true); j.getPrintVisitor().setMode(PrintVisitor.FULL_BRACKET,false); } Object val = j.evaluate(simp); String s = j.getPrintVisitor().formatValue(val); println("Value:\t\t"+s); }
1,116,773
public void processEquation(Node node) throws ParseException { DJep j = (DJep) this.j; if(verbose) { print("Parsed:\t\t"); println(j.toString(node)); } Node processed = j.preprocess(node); if(verbose) { print("Processed:\t"); println(j.toString(processed)); } Node simp = j.simplify(processed); if(verbose) print("Simplified:\t"); println(j.toString(simp)); if(verbose) { print("Full Brackets, no variable expansion:\n\t\t"); j.getPrintVisitor().setMode(PrintVisitor.FULL_BRACKET,true); j.getPrintVisitor().setMode(DPrintVisitor.PRINT_PARTIAL_EQNS,false); println(j.toString(simp)); j.getPrintVisitor().setMode(DPrintVisitor.PRINT_PARTIAL_EQNS,true); j.getPrintVisitor().setMode(PrintVisitor.FULL_BRACKET,false); } Object val = j.evaluate(simp); String s = j.getPrintVisitor().formatValue(val); println("Value:\t\t"+s); }
public void processEquation(Node node) throws ParseException { DJep j = (DJep) this.j; if(verbose) { print("Parsed:\t\t"); println(j.toString(node)); } Node processed = j.preprocess(node); if(verbose) { print("Processed:\t"); println(j.toString(processed)); } Node simp = j.simplify(processed); if(verbose) print("Simplified:\t"); println(dj.toString(simp)); if(verbose) { print("Full Brackets, no variable expansion:\n\t\t"); j.getPrintVisitor().setMode(PrintVisitor.FULL_BRACKET,true); j.getPrintVisitor().setMode(DPrintVisitor.PRINT_PARTIAL_EQNS,false); println(dj.toString(simp)); j.getPrintVisitor().setMode(DPrintVisitor.PRINT_PARTIAL_EQNS,true); j.getPrintVisitor().setMode(PrintVisitor.FULL_BRACKET,false); } Object val = j.evaluate(simp); String s = j.getPrintVisitor().formatValue(val); println("Value:\t\t"+s); }
1,116,774
public void processEquation(Node node) throws ParseException { DJep j = (DJep) this.j; if(verbose) { print("Parsed:\t\t"); println(j.toString(node)); } Node processed = j.preprocess(node); if(verbose) { print("Processed:\t"); println(j.toString(processed)); } Node simp = j.simplify(processed); if(verbose) print("Simplified:\t"); println(j.toString(simp)); if(verbose) { print("Full Brackets, no variable expansion:\n\t\t"); j.getPrintVisitor().setMode(PrintVisitor.FULL_BRACKET,true); j.getPrintVisitor().setMode(DPrintVisitor.PRINT_PARTIAL_EQNS,false); println(j.toString(simp)); j.getPrintVisitor().setMode(DPrintVisitor.PRINT_PARTIAL_EQNS,true); j.getPrintVisitor().setMode(PrintVisitor.FULL_BRACKET,false); } Object val = j.evaluate(simp); String s = j.getPrintVisitor().formatValue(val); println("Value:\t\t"+s); }
public void processEquation(Node node) throws ParseException { DJep j = (DJep) this.j; if(verbose) { print("Parsed:\t\t"); println(j.toString(node)); } Node processed = j.preprocess(node); if(verbose) { print("Processed:\t"); println(j.toString(processed)); } Node simp = j.simplify(processed); if(verbose) print("Simplified:\t"); println(j.toString(simp)); if(verbose) { print("Full Brackets, no variable expansion:\n\t\t"); j.getPrintVisitor().setMode(PrintVisitor.FULL_BRACKET,true); j.getPrintVisitor().setMode(DPrintVisitor.PRINT_PARTIAL_EQNS,false); println(j.toString(simp)); j.getPrintVisitor().setMode(DPrintVisitor.PRINT_PARTIAL_EQNS,true); j.getPrintVisitor().setMode(PrintVisitor.FULL_BRACKET,false); } Object val = j.evaluate(simp); String s = j.getPrintVisitor().formatValue(val); println("Value:\t\t"+s); }
1,116,775
public void processEquation(Node node) throws ParseException { DJep j = (DJep) this.j; if(verbose) { print("Parsed:\t\t"); println(j.toString(node)); } Node processed = j.preprocess(node); if(verbose) { print("Processed:\t"); println(j.toString(processed)); } Node simp = j.simplify(processed); if(verbose) print("Simplified:\t"); println(j.toString(simp)); if(verbose) { print("Full Brackets, no variable expansion:\n\t\t"); j.getPrintVisitor().setMode(PrintVisitor.FULL_BRACKET,true); j.getPrintVisitor().setMode(DPrintVisitor.PRINT_PARTIAL_EQNS,false); println(j.toString(simp)); j.getPrintVisitor().setMode(DPrintVisitor.PRINT_PARTIAL_EQNS,true); j.getPrintVisitor().setMode(PrintVisitor.FULL_BRACKET,false); } Object val = j.evaluate(simp); String s = j.getPrintVisitor().formatValue(val); println("Value:\t\t"+s); }
public void processEquation(Node node) throws ParseException { DJep j = (DJep) this.j; if(verbose) { print("Parsed:\t\t"); println(j.toString(node)); } Node processed = j.preprocess(node); if(verbose) { print("Processed:\t"); println(j.toString(processed)); } Node simp = j.simplify(processed); if(verbose) print("Simplified:\t"); println(j.toString(simp)); if(verbose) { print("Full Brackets, no variable expansion:\n\t\t"); j.getPrintVisitor().setMode(PrintVisitor.FULL_BRACKET,true); j.getPrintVisitor().setMode(DPrintVisitor.PRINT_PARTIAL_EQNS,false); println(j.toString(simp)); j.getPrintVisitor().setMode(DPrintVisitor.PRINT_PARTIAL_EQNS,true); j.getPrintVisitor().setMode(PrintVisitor.FULL_BRACKET,false); } Object val = j.evaluate(simp); String s = j.getPrintVisitor().formatValue(val); println("Value:\t\t"+s); }
1,116,776
private void layoutUi() { JPanel buttons = new JPanel(); okButton = new JButton("OK"); okButton.addActionListener(this); cancelButton = new JButton("Cancel"); cancelButton.addActionListener(this); buttons.setLayout(new FlowLayout(FlowLayout.RIGHT)); buttons.add(cancelButton); buttons.add(okButton); getContentPane().setLayout(new BorderLayout()); this.setFocusTraversalKeysEnabled(false); { jTabbedPane1 = new JTabbedPane(); getContentPane().add(jTabbedPane1, BorderLayout.CENTER); { pnlCalculations = new JPanel(); jTabbedPane1.addTab("Calculations", null, pnlCalculations, null); { try { { GridBagLayout thisLayout = new GridBagLayout(); thisLayout.rowWeights = new double[]{0.1, 0.1, 0.1, 0.1}; thisLayout.rowHeights = new int[]{7, 7, 7, 7}; thisLayout.columnWeights = new double[]{0.1, 0.2}; thisLayout.columnWidths = new int[]{7, 7}; pnlCalculations.setLayout(thisLayout); pnlCalculations.setPreferredSize(new java.awt.Dimension(524, 372)); { { bgHopsCalc = new ButtonGroup(); { pnlHops = new JPanel(); GridLayout pnlHopsLayout = new GridLayout(2, 2); pnlHopsLayout.setColumns(2); pnlHopsLayout.setHgap(5); pnlHopsLayout.setVgap(5); pnlHopsLayout.setRows(2); pnlHops.setLayout(pnlHopsLayout); pnlCalculations.add(pnlHops, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); pnlHops .setBorder(BorderFactory .createTitledBorder("Hops:")); { jLabelc1 = new JLabel(); pnlHops.add(jLabelc1); jLabelc1.setText("Pellet Hops +%"); } { txtPellet = new JTextField(); pnlHops.add(txtPellet); txtPellet.setPreferredSize(new java.awt.Dimension(20, 20)); } { jLabelc2 = new JLabel(); pnlHops.add(jLabelc2); jLabelc2.setText("Tinseth Utilization Factor"); } { txtTinsethUtil = new JTextField(); pnlHops.add(txtTinsethUtil); txtTinsethUtil.setText("4.15"); } } { pnlAlc = new JPanel(); BoxLayout pnlAlcLayout = new BoxLayout(pnlAlc, javax.swing.BoxLayout.Y_AXIS); pnlAlc.setLayout(pnlAlcLayout); pnlCalculations.add(pnlAlc, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); pnlAlc.setBorder(BorderFactory .createTitledBorder("Alcohol By:")); { rbABV = new JRadioButton(); pnlAlc.add(rbABV); bgAlc.add(rbABV); rbABV.setText("Volume"); } { rbABW = new JRadioButton(); pnlAlc.add(rbABW); bgAlc.add(rbABW); rbABW.setText("Weight"); } } { pnlHopTimes = new JPanel(); GridLayout pnlHopTimesLayout = new GridLayout(3, 2); pnlHopTimesLayout.setColumns(2); pnlHopTimesLayout.setHgap(5); pnlHopTimesLayout.setVgap(5); pnlHopTimesLayout.setRows(3); pnlHopTimes.setLayout(pnlHopTimesLayout); pnlCalculations.add(pnlHopTimes, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); pnlHopTimes.setBorder(BorderFactory .createTitledBorder("Hop Times:")); { jLabelc3 = new JLabel(); pnlHopTimes.add(jLabelc3); jLabelc3.setText("Dry (min):"); } { txtDryHopTime = new JTextField(); pnlHopTimes.add(txtDryHopTime); txtDryHopTime.setText("0.0"); } { jLabelc4 = new JLabel(); pnlHopTimes.add(jLabelc4); jLabelc4.setText("FWH, boil minus (min):"); } { txtFWHTime = new JTextField(); pnlHopTimes.add(txtFWHTime); txtFWHTime.setText("20.0"); } { jLabelc5 = new JLabel(); pnlHopTimes.add(jLabelc5); jLabelc5.setText("Mash Hop (min):"); } { txtMashHopTime = new JTextField(); pnlHopTimes.add(txtMashHopTime); txtMashHopTime.setText("2.0"); } } } pnlHopsCalc = new JPanel(); BoxLayout pnlHopsCalcLayout = new BoxLayout(pnlHopsCalc, javax.swing.BoxLayout.Y_AXIS); pnlHopsCalc.setLayout(pnlHopsCalcLayout); pnlCalculations.add(pnlHopsCalc, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); pnlCalculations.add(getPnlWaterUsage(), new GridBagConstraints(1, 2, 1, 2, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); pnlCalculations.add(getPnlColourOptions(), new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); pnlCalculations.add(getPnlEvaporation(), new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); pnlHopsCalc.setPreferredSize(new java.awt.Dimension(117, 107)); pnlHopsCalc.setBorder(BorderFactory .createTitledBorder("IBU Calc Method:")); { rbTinseth = new JRadioButton(); pnlHopsCalc.add(rbTinseth); rbTinseth.setText("Tinseth"); bgHopsCalc.add(rbTinseth); } { rbRager = new JRadioButton(); pnlHopsCalc.add(rbRager); rbRager.setText("Rager"); bgHopsCalc.add(rbRager); } { rbGaretz = new JRadioButton(); pnlHopsCalc.add(rbGaretz); rbGaretz.setText("Garetz"); bgHopsCalc.add(rbGaretz); } } } } catch (Exception e) { e.printStackTrace(); } } } { costCarbPanel = new JPanel(); BorderLayout costCarbPanelLayout = new BorderLayout(); costCarbPanel.setLayout(costCarbPanelLayout); jTabbedPane1.addTab("Cost & Carb", null, costCarbPanel, null); { carbPanel = new JPanel(); costCarbPanel.add(carbPanel, BorderLayout.CENTER); carbPanel.setBorder(BorderFactory.createTitledBorder(null, "Carbonation", TitledBorder.LEADING, TitledBorder.TOP)); { jLabel3 = new JLabel(); carbPanel.add(jLabel3); jLabel3.setText("Not implemented"); } } { jPanel2 = new JPanel(); costCarbPanel.add(jPanel2, BorderLayout.NORTH); GridBagLayout jPanel2Layout = new GridBagLayout(); jPanel2Layout.rowWeights = new double[]{0.1, 0.1, 0.4}; jPanel2Layout.rowHeights = new int[]{7, 7, 7}; jPanel2Layout.columnWeights = new double[]{0.1, 0.1, 0.1}; jPanel2Layout.columnWidths = new int[]{7, 7, 7}; jPanel2.setPreferredSize(new java.awt.Dimension(232, 176)); jPanel2.setBorder(BorderFactory.createTitledBorder("Cost")); jPanel2.setLayout(jPanel2Layout); { jLabel1 = new JLabel(); jPanel2.add(jLabel1, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel1.setText("Other Cost:"); } { txtOtherCost = new JTextField(); jPanel2.add(txtOtherCost, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); txtOtherCost.setText("$0.00"); txtOtherCost.setPreferredSize(new java.awt.Dimension(62, 20)); } { jLabel2 = new JLabel(); jPanel2.add(jLabel2, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel2.setText("Bottle Size:"); } { cmbBottleSize = new JComboBox(); cmbBottleSizeModel = new ComboModel(); cmbBottleSizeModel.setList(new Quantity().getListofUnits("vol")); cmbBottleSize.setModel(cmbBottleSizeModel); jPanel2.add(cmbBottleSize, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); cmbBottleSize.setPreferredSize(new java.awt.Dimension(89, 20)); jPanel2.add(getTxtBottleSize(), new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); } } { } } { pnlBrewer = new JPanel(); GridBagLayout pnlBrewerLayout = new GridBagLayout(); pnlBrewerLayout.rowWeights = new double[]{0.1, 0.1, 0.3, 0.3}; pnlBrewerLayout.rowHeights = new int[]{2, 2, 7, 7}; pnlBrewerLayout.columnWeights = new double[]{0.1, 0.1, 0.1, 0.1}; pnlBrewerLayout.columnWidths = new int[]{7, 7, 7, 7}; pnlBrewer.setLayout(pnlBrewerLayout); jTabbedPane1.addTab("Brewer", null, pnlBrewer, null); { jLabel4 = new JLabel(); pnlBrewer.add(jLabel4, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel4.setText("Name:"); } { txtBrewerName = new JTextField(); pnlBrewer.add(txtBrewerName, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); txtBrewerName.setText("Your Name"); } { jLabel5 = new JLabel(); pnlBrewer.add(jLabel5, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel5.setText("Phone:"); } { txtPhone = new JTextField(); pnlBrewer.add(txtPhone, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); txtPhone.setText("Your Phone"); } { jLabel6 = new JLabel(); pnlBrewer.add(jLabel6, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel6.setText("Club Name:"); } { txtClubName = new JTextField(); pnlBrewer.add(txtClubName, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); txtClubName.setText("Club Name"); } { jLabel7 = new JLabel(); pnlBrewer.add(jLabel7, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel7.setText("Email:"); } { txtEmail = new JTextField(); pnlBrewer.add(txtEmail, new GridBagConstraints(3, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); txtEmail.setText("Email"); } } { pnlDatabase = new JPanel(); BorderLayout pnlDatabaseLayout = new BorderLayout(); pnlDatabase.setLayout(pnlDatabaseLayout); pnlDatabase.add(getPnlDefaultDB(), BorderLayout.NORTH); pnlDatabase.add(getPnlSortOrder(), BorderLayout.WEST); jTabbedPane1.addTab("Database", null, pnlDatabase, null); pnlDatabase.setVisible(false); } newRecipePanel = new JPanel(); GridBagLayout newRecipePanelLayout = new GridBagLayout(); newRecipePanelLayout.rowWeights = new double[]{0.1, 0.1, 0.1, 0.1}; newRecipePanelLayout.rowHeights = new int[]{7, 7, 7, 7}; newRecipePanelLayout.columnWeights = new double[]{0.1, 0.1, 0.1, 0.1}; newRecipePanelLayout.columnWidths = new int[]{7, 7, 7, 7}; newRecipePanel.setLayout(newRecipePanelLayout); jTabbedPane1.addTab("New Recipe Defaults", null, newRecipePanel, null); appearancePanel = new JPanel(); BorderLayout appearancePanelLayout = new BorderLayout(); appearancePanel.setLayout(appearancePanelLayout); jTabbedPane1.addTab("Appearance", null, appearancePanel, null);/* landfPanel = new JPanel(); appearancePanel.add(landfPanel, BorderLayout.NORTH); jLabel19 = new JLabel(); landfPanel.add(jLabel19); jLabel19.setText("Look and Feel:"); landfCombo = new JComboBox(looks.toArray()); landfPanel.add(landfCombo);*/ colourPanel = new JPanel(); appearancePanel.add(colourPanel, BorderLayout.CENTER); GridBagLayout colourPanelLayout = new GridBagLayout(); colourPanelLayout.rowWeights = new double[] {0.1, 0.1, 0.1, 0.1, 0.1, 0.1}; colourPanelLayout.rowHeights = new int[] {7, 7, 7, 7, 7, 7}; colourPanelLayout.columnWeights = new double[] {0.1, 0.1, 0.1, 0.1, 0.1, 0.1}; colourPanelLayout.columnWidths = new int[] {7, 7, 7, 7, 7, 7}; colourPanel.setLayout(colourPanelLayout); colourPanel.setPreferredSize(new java.awt.Dimension(340, 223)); colourPanel.setBorder(BorderFactory.createTitledBorder("Colour Swatch")); colMethod1rb = new JRadioButton(); colMethod1rb.addActionListener(this); colourGroup.add(colMethod1rb); colourPanel.add(colMethod1rb, new GridBagConstraints(0, 0, 3, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); colMethod1rb.setText("Colour Method 1"); colMethod2rb = new JRadioButton(); colMethod2rb.addActionListener(this); colourGroup.add(colMethod2rb); colourPanel.add(colMethod2rb, new GridBagConstraints(3, 0, 3, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); colMethod2rb.setText("Colour Method 2"); jLabel13 = new JLabel(); colourPanel.add(jLabel13, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); jLabel13.setText("Straw \n(2)"); jLabel14 = new JLabel(); colourPanel.add(jLabel14, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); jLabel14.setText("Pale\n(4)"); jLabel15 = new JLabel(); colourPanel.add(jLabel15, new GridBagConstraints(2, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); jLabel15.setText("Amber\n(8)"); jLabel16 = new JLabel(); colourPanel.add(jLabel16, new GridBagConstraints(3, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); jLabel16.setText("Copper (15)"); jLabel17 = new JLabel(); colourPanel.add(jLabel17, new GridBagConstraints(4, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); jLabel17.setText("Brown (20)"); jLabel18 = new JLabel(); colourPanel.add(jLabel18, new GridBagConstraints(5, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); jLabel18.setText("Black (30)"); stawPanel = new JPanel(); colourPanel.add(stawPanel, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); stawPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); palePanel = new JPanel(); colourPanel.add(palePanel, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); palePanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); amberPanel = new JPanel(); colourPanel.add(amberPanel, new GridBagConstraints(2, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); amberPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); copperPanel = new JPanel(); colourPanel.add(copperPanel, new GridBagConstraints(3, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); copperPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); brownPanel = new JPanel(); colourPanel.add(brownPanel, new GridBagConstraints(4, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); brownPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); blackPanel = new JPanel(); colourPanel.add(blackPanel, new GridBagConstraints(5, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); blackPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); SpinnerNumberModel redSpnModel = new SpinnerNumberModel(8,0,255,1); redSpn = new JSpinner(); colourPanel.add(redSpn, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); redSpn.setModel(redSpnModel); redSpn.addChangeListener(this); SpinnerNumberModel greenSpnModel = new SpinnerNumberModel(30,0,255,1); greenSpn = new JSpinner(); colourPanel.add(greenSpn, new GridBagConstraints(3, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); greenSpn.setModel(greenSpnModel); greenSpn.addChangeListener(this); SpinnerNumberModel blueSpnModel = new SpinnerNumberModel(20,0,255,1); blueSpn = new JSpinner(); colourPanel.add(blueSpn, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); blueSpn.setModel(blueSpnModel); blueSpn.addChangeListener(this); SpinnerNumberModel alphaSpnModel = new SpinnerNumberModel(255,0,255,1); alphaSpn = new JSpinner(); colourPanel.add(alphaSpn, new GridBagConstraints(3, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); alphaSpn.setModel(alphaSpnModel); alphaSpn.addChangeListener(this); jLabel20 = new JLabel(); colourPanel.add(jLabel20, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel20.setText("Red:"); jLabel21 = new JLabel(); colourPanel.add(jLabel21, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel21.setText("Blue:"); jLabel22 = new JLabel(); colourPanel.add(jLabel22, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel22.setText("Green:"); jLabel23 = new JLabel(); colourPanel.add(jLabel23, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel23.setText("Alpha:"); mashPanel = new JPanel(); newRecipePanel.add(mashPanel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); mashPanel.setBorder(BorderFactory.createTitledBorder("Mash")); jPanel1 = new JPanel(); GridBagLayout jPanel1Layout = new GridBagLayout(); jPanel1Layout.rowWeights = new double[] {0.1, 0.1, 0.1, 0.1}; jPanel1Layout.rowHeights = new int[] {7, 7, 7, 7}; jPanel1Layout.columnWeights = new double[] {0.1, 0.1}; jPanel1Layout.columnWidths = new int[] {7, 7}; jPanel1.setLayout(jPanel1Layout); newRecipePanel.add(jPanel1, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); jPanel1.setBorder(BorderFactory.createTitledBorder("Units")); jLabel19 = new JLabel(); jPanel1.add(jLabel19, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel19.setText("Malt Units:"); maltUnitsCombo = new JComboBox(); jPanel1.add(maltUnitsCombo, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); maltUnitsComboModel = new ComboModel(); maltUnitsComboModel.setList(new Quantity().getListofUnits("weight")); maltUnitsCombo.setModel(maltUnitsComboModel); jLabel24 = new JLabel(); jPanel1.add(jLabel24, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel24.setText("Hops Units:"); hopsUnitsCombo = new JComboBox(); jPanel1.add(hopsUnitsCombo, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); hopsUnitsComboModel = new ComboModel(); hopsUnitsComboModel.setList(new Quantity().getListofUnits("weight")); hopsUnitsCombo.setModel(hopsUnitsComboModel); jLabel25 = new JLabel(); jPanel1.add(jLabel25, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel25.setText("Vol Units:"); volUnitsCombo = new JComboBox(); volUnitsCombo.addActionListener(new ActionListener() { public void actionPerformed (ActionEvent e){ setEvapLable(); } }); jPanel1.add(volUnitsCombo, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); volUnitsComboModel = new ComboModel(); volUnitsComboModel.setList(new Quantity().getListofUnits("vol")); volUnitsCombo.setModel(volUnitsComboModel); jLabel26 = new JLabel(); jPanel1.add(jLabel26, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel26.setText("Batch Size:"); batchSizeTxt = new JTextField(); jPanel1.add(batchSizeTxt, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); batchSizeTxt.setText("jTextField1"); jLabel12 = new JLabel(); mashPanel.add(jLabel12); jLabel12.setText("Boil Temp (F):"); boilTempTxt = new JTextField(); mashPanel.add(boilTempTxt); boilTempTxt.setText("212"); boilTempTxt.setPreferredSize(new java.awt.Dimension(43, 20)); } getContentPane().add(BorderLayout.CENTER, jTabbedPane1); getContentPane().add(BorderLayout.SOUTH, buttons); setSize(500, 500); }
private void layoutUi() { JPanel buttons = new JPanel(); okButton = new JButton("OK"); okButton.addActionListener(this); cancelButton = new JButton("Cancel"); cancelButton.addActionListener(this); buttons.setLayout(new FlowLayout(FlowLayout.RIGHT)); buttons.add(cancelButton); buttons.add(okButton); getContentPane().setLayout(new BorderLayout()); this.setFocusTraversalKeysEnabled(false); { jTabbedPane1 = new JTabbedPane(); getContentPane().add(jTabbedPane1, BorderLayout.CENTER); { pnlCalculations = new JPanel(); jTabbedPane1.addTab("Calculations", null, pnlCalculations, null); { try { { GridBagLayout thisLayout = new GridBagLayout(); thisLayout.rowWeights = new double[]{0.1, 0.1, 0.1, 0.1}; thisLayout.rowHeights = new int[]{7, 7, 7, 7}; thisLayout.columnWeights = new double[]{0.1, 0.2}; thisLayout.columnWidths = new int[]{7, 7}; pnlCalculations.setLayout(thisLayout); pnlCalculations.setPreferredSize(new java.awt.Dimension(524, 372)); { { bgHopsCalc = new ButtonGroup(); { pnlHops = new JPanel(); GridLayout pnlHopsLayout = new GridLayout(2, 2); pnlHopsLayout.setColumns(2); pnlHopsLayout.setHgap(5); pnlHopsLayout.setVgap(5); pnlHopsLayout.setRows(2); pnlHops.setLayout(pnlHopsLayout); pnlCalculations.add(pnlHops, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); pnlHops .setBorder(BorderFactory .createTitledBorder("Hops:")); { jLabelc1 = new JLabel(); pnlHops.add(jLabelc1); jLabelc1.setText("Pellet Hops +%"); } { txtPellet = new JTextField(); pnlHops.add(txtPellet); txtPellet.setPreferredSize(new java.awt.Dimension(20, 20)); } { jLabelc2 = new JLabel(); pnlHops.add(jLabelc2); jLabelc2.setText("Tinseth Utilization Factor"); } { txtTinsethUtil = new JTextField(); pnlHops.add(txtTinsethUtil); txtTinsethUtil.setText("4.15"); } } { pnlAlc = new JPanel(); BoxLayout pnlAlcLayout = new BoxLayout(pnlAlc, javax.swing.BoxLayout.Y_AXIS); pnlAlc.setLayout(pnlAlcLayout); pnlCalculations.add(pnlAlc, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); pnlAlc.setBorder(BorderFactory .createTitledBorder("Alcohol By:")); { rbABV = new JRadioButton(); pnlAlc.add(rbABV); bgAlc.add(rbABV); rbABV.setText("Volume"); } { rbABW = new JRadioButton(); pnlAlc.add(rbABW); bgAlc.add(rbABW); rbABW.setText("Weight"); } } { pnlHopTimes = new JPanel(); GridLayout pnlHopTimesLayout = new GridLayout(3, 2); pnlHopTimesLayout.setColumns(2); pnlHopTimesLayout.setHgap(5); pnlHopTimesLayout.setVgap(5); pnlHopTimesLayout.setRows(3); pnlHopTimes.setLayout(pnlHopTimesLayout); pnlCalculations.add(pnlHopTimes, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); pnlHopTimes.setBorder(BorderFactory .createTitledBorder("Hop Times:")); { jLabelc3 = new JLabel(); pnlHopTimes.add(jLabelc3); jLabelc3.setText("Dry (min):"); } { txtDryHopTime = new JTextField(); pnlHopTimes.add(txtDryHopTime); txtDryHopTime.setText("0.0"); } { jLabelc4 = new JLabel(); pnlHopTimes.add(jLabelc4); jLabelc4.setText("FWH, boil minus (min):"); } { txtFWHTime = new JTextField(); pnlHopTimes.add(txtFWHTime); txtFWHTime.setText("20.0"); } { jLabelc5 = new JLabel(); pnlHopTimes.add(jLabelc5); jLabelc5.setText("Mash Hop (min):"); } { txtMashHopTime = new JTextField(); pnlHopTimes.add(txtMashHopTime); txtMashHopTime.setText("2.0"); } } } pnlHopsCalc = new JPanel(); BoxLayout pnlHopsCalcLayout = new BoxLayout(pnlHopsCalc, javax.swing.BoxLayout.Y_AXIS); pnlHopsCalc.setLayout(pnlHopsCalcLayout); pnlCalculations.add(pnlHopsCalc, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); pnlCalculations.add(getPnlWaterUsage(), new GridBagConstraints(1, 2, 1, 2, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); pnlCalculations.add(getPnlColourOptions(), new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); pnlCalculations.add(getPnlEvaporation(), new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); pnlHopsCalc.setPreferredSize(new java.awt.Dimension(117, 107)); pnlHopsCalc.setBorder(BorderFactory .createTitledBorder("IBU Calc Method:")); { rbTinseth = new JRadioButton(); pnlHopsCalc.add(rbTinseth); rbTinseth.setText("Tinseth"); bgHopsCalc.add(rbTinseth); } { rbRager = new JRadioButton(); pnlHopsCalc.add(rbRager); rbRager.setText("Rager"); bgHopsCalc.add(rbRager); } { rbGaretz = new JRadioButton(); pnlHopsCalc.add(rbGaretz); rbGaretz.setText("Garetz"); bgHopsCalc.add(rbGaretz); } } } } catch (Exception e) { e.printStackTrace(); } } } { costCarbPanel = new JPanel(); BorderLayout costCarbPanelLayout = new BorderLayout(); costCarbPanel.setLayout(costCarbPanelLayout); jTabbedPane1.addTab("Cost & Carb", null, costCarbPanel, null); { carbPanel = new JPanel(); costCarbPanel.add(carbPanel, BorderLayout.CENTER); carbPanel.setBorder(BorderFactory.createTitledBorder(null, "Carbonation", TitledBorder.LEADING, TitledBorder.TOP)); { jLabel3 = new JLabel(); carbPanel.add(jLabel3); jLabel3.setText("Not implemented"); } } { jPanel2 = new JPanel(); costCarbPanel.add(jPanel2, BorderLayout.NORTH); GridBagLayout jPanel2Layout = new GridBagLayout(); jPanel2Layout.rowWeights = new double[]{0.1, 0.1, 0.4}; jPanel2Layout.rowHeights = new int[]{7, 7, 7}; jPanel2Layout.columnWeights = new double[]{0.1, 0.1, 0.1}; jPanel2Layout.columnWidths = new int[]{7, 7, 7}; jPanel2.setPreferredSize(new java.awt.Dimension(232, 176)); jPanel2.setBorder(BorderFactory.createTitledBorder("Cost")); jPanel2.setLayout(jPanel2Layout); { jLabel1 = new JLabel(); jPanel2.add(jLabel1, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel1.setText("Other Cost:"); } { txtOtherCost = new JTextField(); jPanel2.add(txtOtherCost, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); txtOtherCost.setText("$0.00"); txtOtherCost.setPreferredSize(new java.awt.Dimension(62, 20)); } { jLabel2 = new JLabel(); jPanel2.add(jLabel2, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel2.setText("Bottle Size:"); } { cmbBottleSize = new JComboBox(); cmbBottleSizeModel = new ComboModel(); cmbBottleSizeModel.setList(new Quantity().getListofUnits("vol")); cmbBottleSize.setModel(cmbBottleSizeModel); jPanel2.add(cmbBottleSize, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); cmbBottleSize.setPreferredSize(new java.awt.Dimension(89, 20)); jPanel2.add(getTxtBottleSize(), new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); } } { } } { pnlBrewer = new JPanel(); GridBagLayout pnlBrewerLayout = new GridBagLayout(); pnlBrewerLayout.rowWeights = new double[]{0.1, 0.1, 0.3, 0.3}; pnlBrewerLayout.rowHeights = new int[]{2, 2, 7, 7}; pnlBrewerLayout.columnWeights = new double[]{0.1, 0.1, 0.1, 0.1}; pnlBrewerLayout.columnWidths = new int[]{7, 7, 7, 7}; pnlBrewer.setLayout(pnlBrewerLayout); jTabbedPane1.addTab("Brewer", null, pnlBrewer, null); { jLabel4 = new JLabel(); pnlBrewer.add(jLabel4, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel4.setText("Name:"); } { txtBrewerName = new JTextField(); pnlBrewer.add(txtBrewerName, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); txtBrewerName.setText("Your Name"); } { jLabel5 = new JLabel(); pnlBrewer.add(jLabel5, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel5.setText("Phone:"); } { txtPhone = new JTextField(); pnlBrewer.add(txtPhone, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); txtPhone.setText("Your Phone"); } { jLabel6 = new JLabel(); pnlBrewer.add(jLabel6, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel6.setText("Club Name:"); } { txtClubName = new JTextField(); pnlBrewer.add(txtClubName, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); txtClubName.setText("Club Name"); } { jLabel7 = new JLabel(); pnlBrewer.add(jLabel7, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel7.setText("Email:"); } { txtEmail = new JTextField(); pnlBrewer.add(txtEmail, new GridBagConstraints(3, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); txtEmail.setText("Email"); } } { pnlDatabase = new JPanel(); BorderLayout pnlDatabaseLayout = new BorderLayout(); pnlDatabase.setLayout(pnlDatabaseLayout); pnlDatabase.add(getPnlDefaultDB(), BorderLayout.NORTH); pnlDatabase.add(getPnlSortOrder(), BorderLayout.WEST); jTabbedPane1.addTab("Database", null, pnlDatabase, null); pnlDatabase.setVisible(false); } newRecipePanel = new JPanel(); GridBagLayout newRecipePanelLayout = new GridBagLayout(); newRecipePanelLayout.rowWeights = new double[]{0.1, 0.1, 0.1, 0.1}; newRecipePanelLayout.rowHeights = new int[]{7, 7, 7, 7}; newRecipePanelLayout.columnWeights = new double[]{0.1, 0.1, 0.1, 0.1}; newRecipePanelLayout.columnWidths = new int[]{7, 7, 7, 7}; newRecipePanel.setLayout(newRecipePanelLayout); jTabbedPane1.addTab("New Recipe Defaults", null, newRecipePanel, null); appearancePanel = new JPanel(); BorderLayout appearancePanelLayout = new BorderLayout(); appearancePanel.setLayout(appearancePanelLayout); jTabbedPane1.addTab("Appearance", null, appearancePanel, null);/* landfPanel = new JPanel(); appearancePanel.add(landfPanel, BorderLayout.NORTH); jLabel19 = new JLabel(); landfPanel.add(jLabel19); jLabel19.setText("Look and Feel:"); landfCombo = new JComboBox(looks.toArray()); landfPanel.add(landfCombo);*/ colourPanel = new JPanel(); appearancePanel.add(colourPanel, BorderLayout.CENTER); GridBagLayout colourPanelLayout = new GridBagLayout(); colourPanelLayout.rowWeights = new double[] {0.1, 0.1, 0.1, 0.1, 0.1, 0.1}; colourPanelLayout.rowHeights = new int[] {7, 7, 7, 7, 7, 7}; colourPanelLayout.columnWeights = new double[] {0.1, 0.1, 0.1, 0.1, 0.1, 0.1}; colourPanelLayout.columnWidths = new int[] {7, 7, 7, 7, 7, 7}; colourPanel.setLayout(colourPanelLayout); colourPanel.setPreferredSize(new java.awt.Dimension(340, 223)); colourPanel.setBorder(BorderFactory.createTitledBorder("Colour Swatch")); colMethod1rb = new JRadioButton(); colMethod1rb.addActionListener(this); colourGroup.add(colMethod1rb); colourPanel.add(colMethod1rb, new GridBagConstraints(0, 0, 3, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); colMethod1rb.setText("Colour Method 1"); colMethod2rb = new JRadioButton(); colMethod2rb.addActionListener(this); colourGroup.add(colMethod2rb); colourPanel.add(colMethod2rb, new GridBagConstraints(3, 0, 3, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); colMethod2rb.setText("Colour Method 2"); jLabel13 = new JLabel(); colourPanel.add(jLabel13, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); jLabel13.setText("Straw \n(2)"); jLabel14 = new JLabel(); colourPanel.add(jLabel14, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); jLabel14.setText("Pale\n(4)"); jLabel15 = new JLabel(); colourPanel.add(jLabel15, new GridBagConstraints(2, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); jLabel15.setText("Amber\n(8)"); jLabel16 = new JLabel(); colourPanel.add(jLabel16, new GridBagConstraints(3, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); jLabel16.setText("Copper (15)"); jLabel17 = new JLabel(); colourPanel.add(jLabel17, new GridBagConstraints(4, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); jLabel17.setText("Brown (20)"); jLabel18 = new JLabel(); colourPanel.add(jLabel18, new GridBagConstraints(5, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); jLabel18.setText("Black (30)"); stawPanel = new JPanel(); colourPanel.add(stawPanel, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); stawPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); palePanel = new JPanel(); colourPanel.add(palePanel, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); palePanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); amberPanel = new JPanel(); colourPanel.add(amberPanel, new GridBagConstraints(2, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); amberPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); copperPanel = new JPanel(); colourPanel.add(copperPanel, new GridBagConstraints(3, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); copperPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); brownPanel = new JPanel(); colourPanel.add(brownPanel, new GridBagConstraints(4, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); brownPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); blackPanel = new JPanel(); colourPanel.add(blackPanel, new GridBagConstraints(5, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); blackPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); SpinnerNumberModel redSpnModel = new SpinnerNumberModel(8,0,255,1); redSpn = new JSpinner(); colourPanel.add(redSpn, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); redSpn.setModel(redSpnModel); redSpn.addChangeListener(this); SpinnerNumberModel greenSpnModel = new SpinnerNumberModel(30,0,255,1); greenSpn = new JSpinner(); colourPanel.add(greenSpn, new GridBagConstraints(3, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); greenSpn.setModel(greenSpnModel); greenSpn.addChangeListener(this); SpinnerNumberModel blueSpnModel = new SpinnerNumberModel(20,0,255,1); blueSpn = new JSpinner(); colourPanel.add(blueSpn, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); blueSpn.setModel(blueSpnModel); blueSpn.addChangeListener(this); SpinnerNumberModel alphaSpnModel = new SpinnerNumberModel(255,0,255,1); alphaSpn = new JSpinner(); colourPanel.add(alphaSpn, new GridBagConstraints(3, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); alphaSpn.setModel(alphaSpnModel); alphaSpn.addChangeListener(this); jLabel20 = new JLabel(); colourPanel.add(jLabel20, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel20.setText("Red:"); jLabel21 = new JLabel(); colourPanel.add(jLabel21, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel21.setText("Blue:"); jLabel22 = new JLabel(); colourPanel.add(jLabel22, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel22.setText("Green:"); jLabel23 = new JLabel(); colourPanel.add(jLabel23, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel23.setText("Alpha:"); mashPanel = new JPanel(); newRecipePanel.add(mashPanel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); mashPanel.setBorder(BorderFactory.createTitledBorder("Mash")); jPanel1 = new JPanel(); GridBagLayout jPanel1Layout = new GridBagLayout(); jPanel1Layout.rowWeights = new double[] {0.1, 0.1, 0.1, 0.1}; jPanel1Layout.rowHeights = new int[] {7, 7, 7, 7}; jPanel1Layout.columnWeights = new double[] {0.1, 0.1}; jPanel1Layout.columnWidths = new int[] {7, 7}; jPanel1.setLayout(jPanel1Layout); newRecipePanel.add(jPanel1, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); jPanel1.setBorder(BorderFactory.createTitledBorder("Units")); jLabel19 = new JLabel(); jPanel1.add(jLabel19, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel19.setText("Malt Units:"); maltUnitsCombo = new JComboBox(); jPanel1.add(maltUnitsCombo, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); maltUnitsComboModel = new ComboModel(); maltUnitsComboModel.setList(new Quantity().getListofUnits("weight")); maltUnitsCombo.setModel(maltUnitsComboModel); jLabel24 = new JLabel(); jPanel1.add(jLabel24, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel24.setText("Hops Units:"); hopsUnitsCombo = new JComboBox(); jPanel1.add(hopsUnitsCombo, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); hopsUnitsComboModel = new ComboModel(); hopsUnitsComboModel.setList(new Quantity().getListofUnits("weight")); hopsUnitsCombo.setModel(hopsUnitsComboModel); jLabel25 = new JLabel(); jPanel1.add(jLabel25, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel25.setText("Vol Units:"); volUnitsCombo = new JComboBox(); volUnitsCombo.addActionListener(new ActionListener() { public void actionPerformed (ActionEvent e){ setEvapLable(); } }); jPanel1.add(volUnitsCombo, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); volUnitsComboModel = new ComboModel(); volUnitsComboModel.setList(new Quantity().getListofUnits("vol")); volUnitsCombo.setModel(volUnitsComboModel); jLabel26 = new JLabel(); jPanel1.add(jLabel26, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel26.setText("Batch Size:"); batchSizeTxt = new JTextField(); jPanel1.add(batchSizeTxt, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); batchSizeTxt.setText("jTextField1"); jLabel12 = new JLabel(); mashPanel.add(jLabel12); jLabel12.setText("Boil Temp (F):"); boilTempTxt = new JTextField(); mashPanel.add(boilTempTxt); boilTempTxt.setText("212"); boilTempTxt.setPreferredSize(new java.awt.Dimension(43, 20)); } getContentPane().add(BorderLayout.CENTER, jTabbedPane1); getContentPane().add(BorderLayout.SOUTH, buttons); setSize(500, 500); }
1,116,778
private void layoutUi() { JPanel buttons = new JPanel(); okButton = new JButton("OK"); okButton.addActionListener(this); cancelButton = new JButton("Cancel"); cancelButton.addActionListener(this); buttons.setLayout(new FlowLayout(FlowLayout.RIGHT)); buttons.add(cancelButton); buttons.add(okButton); getContentPane().setLayout(new BorderLayout()); this.setFocusTraversalKeysEnabled(false); { jTabbedPane1 = new JTabbedPane(); getContentPane().add(jTabbedPane1, BorderLayout.CENTER); { pnlCalculations = new JPanel(); jTabbedPane1.addTab("Calculations", null, pnlCalculations, null); { try { { GridBagLayout thisLayout = new GridBagLayout(); thisLayout.rowWeights = new double[]{0.1, 0.1, 0.1, 0.1}; thisLayout.rowHeights = new int[]{7, 7, 7, 7}; thisLayout.columnWeights = new double[]{0.1, 0.2}; thisLayout.columnWidths = new int[]{7, 7}; pnlCalculations.setLayout(thisLayout); pnlCalculations.setPreferredSize(new java.awt.Dimension(524, 372)); { { bgHopsCalc = new ButtonGroup(); { pnlHops = new JPanel(); GridLayout pnlHopsLayout = new GridLayout(2, 2); pnlHopsLayout.setColumns(2); pnlHopsLayout.setHgap(5); pnlHopsLayout.setVgap(5); pnlHopsLayout.setRows(2); pnlHops.setLayout(pnlHopsLayout); pnlCalculations.add(pnlHops, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); pnlHops .setBorder(BorderFactory .createTitledBorder("Hops:")); { jLabelc1 = new JLabel(); pnlHops.add(jLabelc1); jLabelc1.setText("Pellet Hops +%"); } { txtPellet = new JTextField(); pnlHops.add(txtPellet); txtPellet.setPreferredSize(new java.awt.Dimension(20, 20)); } { jLabelc2 = new JLabel(); pnlHops.add(jLabelc2); jLabelc2.setText("Tinseth Utilization Factor"); } { txtTinsethUtil = new JTextField(); pnlHops.add(txtTinsethUtil); txtTinsethUtil.setText("4.15"); } } { pnlAlc = new JPanel(); BoxLayout pnlAlcLayout = new BoxLayout(pnlAlc, javax.swing.BoxLayout.Y_AXIS); pnlAlc.setLayout(pnlAlcLayout); pnlCalculations.add(pnlAlc, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); pnlAlc.setBorder(BorderFactory .createTitledBorder("Alcohol By:")); { rbABV = new JRadioButton(); pnlAlc.add(rbABV); bgAlc.add(rbABV); rbABV.setText("Volume"); } { rbABW = new JRadioButton(); pnlAlc.add(rbABW); bgAlc.add(rbABW); rbABW.setText("Weight"); } } { pnlHopTimes = new JPanel(); GridLayout pnlHopTimesLayout = new GridLayout(3, 2); pnlHopTimesLayout.setColumns(2); pnlHopTimesLayout.setHgap(5); pnlHopTimesLayout.setVgap(5); pnlHopTimesLayout.setRows(3); pnlHopTimes.setLayout(pnlHopTimesLayout); pnlCalculations.add(pnlHopTimes, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); pnlHopTimes.setBorder(BorderFactory .createTitledBorder("Hop Times:")); { jLabelc3 = new JLabel(); pnlHopTimes.add(jLabelc3); jLabelc3.setText("Dry (min):"); } { txtDryHopTime = new JTextField(); pnlHopTimes.add(txtDryHopTime); txtDryHopTime.setText("0.0"); } { jLabelc4 = new JLabel(); pnlHopTimes.add(jLabelc4); jLabelc4.setText("FWH, boil minus (min):"); } { txtFWHTime = new JTextField(); pnlHopTimes.add(txtFWHTime); txtFWHTime.setText("20.0"); } { jLabelc5 = new JLabel(); pnlHopTimes.add(jLabelc5); jLabelc5.setText("Mash Hop (min):"); } { txtMashHopTime = new JTextField(); pnlHopTimes.add(txtMashHopTime); txtMashHopTime.setText("2.0"); } } } pnlHopsCalc = new JPanel(); BoxLayout pnlHopsCalcLayout = new BoxLayout(pnlHopsCalc, javax.swing.BoxLayout.Y_AXIS); pnlHopsCalc.setLayout(pnlHopsCalcLayout); pnlCalculations.add(pnlHopsCalc, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); pnlCalculations.add(getPnlWaterUsage(), new GridBagConstraints(1, 2, 1, 2, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); pnlCalculations.add(getPnlColourOptions(), new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); pnlCalculations.add(getPnlEvaporation(), new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); pnlHopsCalc.setPreferredSize(new java.awt.Dimension(117, 107)); pnlHopsCalc.setBorder(BorderFactory .createTitledBorder("IBU Calc Method:")); { rbTinseth = new JRadioButton(); pnlHopsCalc.add(rbTinseth); rbTinseth.setText("Tinseth"); bgHopsCalc.add(rbTinseth); } { rbRager = new JRadioButton(); pnlHopsCalc.add(rbRager); rbRager.setText("Rager"); bgHopsCalc.add(rbRager); } { rbGaretz = new JRadioButton(); pnlHopsCalc.add(rbGaretz); rbGaretz.setText("Garetz"); bgHopsCalc.add(rbGaretz); } } } } catch (Exception e) { e.printStackTrace(); } } } { costCarbPanel = new JPanel(); BorderLayout costCarbPanelLayout = new BorderLayout(); costCarbPanel.setLayout(costCarbPanelLayout); jTabbedPane1.addTab("Cost & Carb", null, costCarbPanel, null); { carbPanel = new JPanel(); costCarbPanel.add(carbPanel, BorderLayout.CENTER); carbPanel.setBorder(BorderFactory.createTitledBorder(null, "Carbonation", TitledBorder.LEADING, TitledBorder.TOP)); { jLabel3 = new JLabel(); carbPanel.add(jLabel3); jLabel3.setText("Not implemented"); } } { jPanel2 = new JPanel(); costCarbPanel.add(jPanel2, BorderLayout.NORTH); GridBagLayout jPanel2Layout = new GridBagLayout(); jPanel2Layout.rowWeights = new double[]{0.1, 0.1, 0.4}; jPanel2Layout.rowHeights = new int[]{7, 7, 7}; jPanel2Layout.columnWeights = new double[]{0.1, 0.1, 0.1}; jPanel2Layout.columnWidths = new int[]{7, 7, 7}; jPanel2.setPreferredSize(new java.awt.Dimension(232, 176)); jPanel2.setBorder(BorderFactory.createTitledBorder("Cost")); jPanel2.setLayout(jPanel2Layout); { jLabel1 = new JLabel(); jPanel2.add(jLabel1, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel1.setText("Other Cost:"); } { txtOtherCost = new JTextField(); jPanel2.add(txtOtherCost, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); txtOtherCost.setText("$0.00"); txtOtherCost.setPreferredSize(new java.awt.Dimension(62, 20)); } { jLabel2 = new JLabel(); jPanel2.add(jLabel2, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel2.setText("Bottle Size:"); } { cmbBottleSize = new JComboBox(); cmbBottleSizeModel = new ComboModel(); cmbBottleSizeModel.setList(new Quantity().getListofUnits("vol")); cmbBottleSize.setModel(cmbBottleSizeModel); jPanel2.add(cmbBottleSize, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); cmbBottleSize.setPreferredSize(new java.awt.Dimension(89, 20)); jPanel2.add(getTxtBottleSize(), new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); } } { } } { pnlBrewer = new JPanel(); GridBagLayout pnlBrewerLayout = new GridBagLayout(); pnlBrewerLayout.rowWeights = new double[]{0.1, 0.1, 0.3, 0.3}; pnlBrewerLayout.rowHeights = new int[]{2, 2, 7, 7}; pnlBrewerLayout.columnWeights = new double[]{0.1, 0.1, 0.1, 0.1}; pnlBrewerLayout.columnWidths = new int[]{7, 7, 7, 7}; pnlBrewer.setLayout(pnlBrewerLayout); jTabbedPane1.addTab("Brewer", null, pnlBrewer, null); { jLabel4 = new JLabel(); pnlBrewer.add(jLabel4, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel4.setText("Name:"); } { txtBrewerName = new JTextField(); pnlBrewer.add(txtBrewerName, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); txtBrewerName.setText("Your Name"); } { jLabel5 = new JLabel(); pnlBrewer.add(jLabel5, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel5.setText("Phone:"); } { txtPhone = new JTextField(); pnlBrewer.add(txtPhone, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); txtPhone.setText("Your Phone"); } { jLabel6 = new JLabel(); pnlBrewer.add(jLabel6, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel6.setText("Club Name:"); } { txtClubName = new JTextField(); pnlBrewer.add(txtClubName, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); txtClubName.setText("Club Name"); } { jLabel7 = new JLabel(); pnlBrewer.add(jLabel7, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel7.setText("Email:"); } { txtEmail = new JTextField(); pnlBrewer.add(txtEmail, new GridBagConstraints(3, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); txtEmail.setText("Email"); } } { pnlDatabase = new JPanel(); BorderLayout pnlDatabaseLayout = new BorderLayout(); pnlDatabase.setLayout(pnlDatabaseLayout); pnlDatabase.add(getPnlDefaultDB(), BorderLayout.NORTH); pnlDatabase.add(getPnlSortOrder(), BorderLayout.WEST); jTabbedPane1.addTab("Database", null, pnlDatabase, null); pnlDatabase.setVisible(false); } newRecipePanel = new JPanel(); GridBagLayout newRecipePanelLayout = new GridBagLayout(); newRecipePanelLayout.rowWeights = new double[]{0.1, 0.1, 0.1, 0.1}; newRecipePanelLayout.rowHeights = new int[]{7, 7, 7, 7}; newRecipePanelLayout.columnWeights = new double[]{0.1, 0.1, 0.1, 0.1}; newRecipePanelLayout.columnWidths = new int[]{7, 7, 7, 7}; newRecipePanel.setLayout(newRecipePanelLayout); jTabbedPane1.addTab("New Recipe Defaults", null, newRecipePanel, null); appearancePanel = new JPanel(); BorderLayout appearancePanelLayout = new BorderLayout(); appearancePanel.setLayout(appearancePanelLayout); jTabbedPane1.addTab("Appearance", null, appearancePanel, null);/* landfPanel = new JPanel(); appearancePanel.add(landfPanel, BorderLayout.NORTH); jLabel19 = new JLabel(); landfPanel.add(jLabel19); jLabel19.setText("Look and Feel:"); landfCombo = new JComboBox(looks.toArray()); landfPanel.add(landfCombo);*/ colourPanel = new JPanel(); appearancePanel.add(colourPanel, BorderLayout.CENTER); GridBagLayout colourPanelLayout = new GridBagLayout(); colourPanelLayout.rowWeights = new double[] {0.1, 0.1, 0.1, 0.1, 0.1, 0.1}; colourPanelLayout.rowHeights = new int[] {7, 7, 7, 7, 7, 7}; colourPanelLayout.columnWeights = new double[] {0.1, 0.1, 0.1, 0.1, 0.1, 0.1}; colourPanelLayout.columnWidths = new int[] {7, 7, 7, 7, 7, 7}; colourPanel.setLayout(colourPanelLayout); colourPanel.setPreferredSize(new java.awt.Dimension(340, 223)); colourPanel.setBorder(BorderFactory.createTitledBorder("Colour Swatch")); colMethod1rb = new JRadioButton(); colMethod1rb.addActionListener(this); colourGroup.add(colMethod1rb); colourPanel.add(colMethod1rb, new GridBagConstraints(0, 0, 3, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); colMethod1rb.setText("Colour Method 1"); colMethod2rb = new JRadioButton(); colMethod2rb.addActionListener(this); colourGroup.add(colMethod2rb); colourPanel.add(colMethod2rb, new GridBagConstraints(3, 0, 3, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); colMethod2rb.setText("Colour Method 2"); jLabel13 = new JLabel(); colourPanel.add(jLabel13, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); jLabel13.setText("Straw \n(2)"); jLabel14 = new JLabel(); colourPanel.add(jLabel14, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); jLabel14.setText("Pale\n(4)"); jLabel15 = new JLabel(); colourPanel.add(jLabel15, new GridBagConstraints(2, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); jLabel15.setText("Amber\n(8)"); jLabel16 = new JLabel(); colourPanel.add(jLabel16, new GridBagConstraints(3, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); jLabel16.setText("Copper (15)"); jLabel17 = new JLabel(); colourPanel.add(jLabel17, new GridBagConstraints(4, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); jLabel17.setText("Brown (20)"); jLabel18 = new JLabel(); colourPanel.add(jLabel18, new GridBagConstraints(5, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); jLabel18.setText("Black (30)"); stawPanel = new JPanel(); colourPanel.add(stawPanel, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); stawPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); palePanel = new JPanel(); colourPanel.add(palePanel, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); palePanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); amberPanel = new JPanel(); colourPanel.add(amberPanel, new GridBagConstraints(2, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); amberPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); copperPanel = new JPanel(); colourPanel.add(copperPanel, new GridBagConstraints(3, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); copperPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); brownPanel = new JPanel(); colourPanel.add(brownPanel, new GridBagConstraints(4, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); brownPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); blackPanel = new JPanel(); colourPanel.add(blackPanel, new GridBagConstraints(5, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); blackPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); SpinnerNumberModel redSpnModel = new SpinnerNumberModel(8,0,255,1); redSpn = new JSpinner(); colourPanel.add(redSpn, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); redSpn.setModel(redSpnModel); redSpn.addChangeListener(this); SpinnerNumberModel greenSpnModel = new SpinnerNumberModel(30,0,255,1); greenSpn = new JSpinner(); colourPanel.add(greenSpn, new GridBagConstraints(3, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); greenSpn.setModel(greenSpnModel); greenSpn.addChangeListener(this); SpinnerNumberModel blueSpnModel = new SpinnerNumberModel(20,0,255,1); blueSpn = new JSpinner(); colourPanel.add(blueSpn, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); blueSpn.setModel(blueSpnModel); blueSpn.addChangeListener(this); SpinnerNumberModel alphaSpnModel = new SpinnerNumberModel(255,0,255,1); alphaSpn = new JSpinner(); colourPanel.add(alphaSpn, new GridBagConstraints(3, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); alphaSpn.setModel(alphaSpnModel); alphaSpn.addChangeListener(this); jLabel20 = new JLabel(); colourPanel.add(jLabel20, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel20.setText("Red:"); jLabel21 = new JLabel(); colourPanel.add(jLabel21, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel21.setText("Blue:"); jLabel22 = new JLabel(); colourPanel.add(jLabel22, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel22.setText("Green:"); jLabel23 = new JLabel(); colourPanel.add(jLabel23, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel23.setText("Alpha:"); mashPanel = new JPanel(); newRecipePanel.add(mashPanel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); mashPanel.setBorder(BorderFactory.createTitledBorder("Mash")); jPanel1 = new JPanel(); GridBagLayout jPanel1Layout = new GridBagLayout(); jPanel1Layout.rowWeights = new double[] {0.1, 0.1, 0.1, 0.1}; jPanel1Layout.rowHeights = new int[] {7, 7, 7, 7}; jPanel1Layout.columnWeights = new double[] {0.1, 0.1}; jPanel1Layout.columnWidths = new int[] {7, 7}; jPanel1.setLayout(jPanel1Layout); newRecipePanel.add(jPanel1, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); jPanel1.setBorder(BorderFactory.createTitledBorder("Units")); jLabel19 = new JLabel(); jPanel1.add(jLabel19, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel19.setText("Malt Units:"); maltUnitsCombo = new JComboBox(); jPanel1.add(maltUnitsCombo, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); maltUnitsComboModel = new ComboModel(); maltUnitsComboModel.setList(new Quantity().getListofUnits("weight")); maltUnitsCombo.setModel(maltUnitsComboModel); jLabel24 = new JLabel(); jPanel1.add(jLabel24, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel24.setText("Hops Units:"); hopsUnitsCombo = new JComboBox(); jPanel1.add(hopsUnitsCombo, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); hopsUnitsComboModel = new ComboModel(); hopsUnitsComboModel.setList(new Quantity().getListofUnits("weight")); hopsUnitsCombo.setModel(hopsUnitsComboModel); jLabel25 = new JLabel(); jPanel1.add(jLabel25, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel25.setText("Vol Units:"); volUnitsCombo = new JComboBox(); volUnitsCombo.addActionListener(new ActionListener() { public void actionPerformed (ActionEvent e){ setEvapLable(); } }); jPanel1.add(volUnitsCombo, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); volUnitsComboModel = new ComboModel(); volUnitsComboModel.setList(new Quantity().getListofUnits("vol")); volUnitsCombo.setModel(volUnitsComboModel); jLabel26 = new JLabel(); jPanel1.add(jLabel26, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel26.setText("Batch Size:"); batchSizeTxt = new JTextField(); jPanel1.add(batchSizeTxt, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); batchSizeTxt.setText("jTextField1"); jLabel12 = new JLabel(); mashPanel.add(jLabel12); jLabel12.setText("Boil Temp (F):"); boilTempTxt = new JTextField(); mashPanel.add(boilTempTxt); boilTempTxt.setText("212"); boilTempTxt.setPreferredSize(new java.awt.Dimension(43, 20)); } getContentPane().add(BorderLayout.CENTER, jTabbedPane1); getContentPane().add(BorderLayout.SOUTH, buttons); setSize(500, 500); }
private void layoutUi() { JPanel buttons = new JPanel(); okButton = new JButton("OK"); okButton.addActionListener(this); cancelButton = new JButton("Cancel"); cancelButton.addActionListener(this); buttons.setLayout(new FlowLayout(FlowLayout.RIGHT)); buttons.add(cancelButton); buttons.add(okButton); getContentPane().setLayout(new BorderLayout()); this.setFocusTraversalKeysEnabled(false); { jTabbedPane1 = new JTabbedPane(); getContentPane().add(jTabbedPane1, BorderLayout.CENTER); { pnlCalculations = new JPanel(); jTabbedPane1.addTab("Calculations", null, pnlCalculations, null); { try { { GridBagLayout thisLayout = new GridBagLayout(); thisLayout.rowWeights = new double[]{0.1, 0.1, 0.1, 0.1}; thisLayout.rowHeights = new int[]{7, 7, 7, 7}; thisLayout.columnWeights = new double[]{0.1, 0.2}; thisLayout.columnWidths = new int[]{7, 7}; pnlCalculations.setLayout(thisLayout); pnlCalculations.setPreferredSize(new java.awt.Dimension(524, 372)); { { bgHopsCalc = new ButtonGroup(); { pnlHops = new JPanel(); GridLayout pnlHopsLayout = new GridLayout(2, 2); pnlHopsLayout.setColumns(2); pnlHopsLayout.setHgap(5); pnlHopsLayout.setVgap(5); pnlHopsLayout.setRows(2); pnlHops.setLayout(pnlHopsLayout); pnlCalculations.add(pnlHops, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); pnlHops .setBorder(BorderFactory .createTitledBorder("Hops:")); { jLabelc1 = new JLabel(); pnlHops.add(jLabelc1); jLabelc1.setText("Pellet Hops +%"); } { txtPellet = new JTextField(); pnlHops.add(txtPellet); txtPellet.setPreferredSize(new java.awt.Dimension(20, 20)); } { jLabelc2 = new JLabel(); pnlHops.add(jLabelc2); jLabelc2.setText("Tinseth Utilization Factor"); } { txtTinsethUtil = new JTextField(); pnlHops.add(txtTinsethUtil); txtTinsethUtil.setText("4.15"); } } { pnlAlc = new JPanel(); BoxLayout pnlAlcLayout = new BoxLayout(pnlAlc, javax.swing.BoxLayout.Y_AXIS); pnlAlc.setLayout(pnlAlcLayout); pnlCalculations.add(pnlAlc, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); pnlAlc.setBorder(BorderFactory .createTitledBorder("Alcohol By:")); { rbABV = new JRadioButton(); pnlAlc.add(rbABV); bgAlc.add(rbABV); rbABV.setText("Volume"); } { rbABW = new JRadioButton(); pnlAlc.add(rbABW); bgAlc.add(rbABW); rbABW.setText("Weight"); } } { pnlHopTimes = new JPanel(); GridLayout pnlHopTimesLayout = new GridLayout(3, 2); pnlHopTimesLayout.setColumns(2); pnlHopTimesLayout.setHgap(5); pnlHopTimesLayout.setVgap(5); pnlHopTimesLayout.setRows(3); pnlHopTimes.setLayout(pnlHopTimesLayout); pnlCalculations.add(pnlHopTimes, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); pnlHopTimes.setBorder(BorderFactory .createTitledBorder("Hop Times:")); { jLabelc3 = new JLabel(); pnlHopTimes.add(jLabelc3); jLabelc3.setText("Dry (min):"); } { txtDryHopTime = new JTextField(); pnlHopTimes.add(txtDryHopTime); txtDryHopTime.setText("0.0"); } { jLabelc4 = new JLabel(); pnlHopTimes.add(jLabelc4); jLabelc4.setText("FWH, boil minus (min):"); } { txtFWHTime = new JTextField(); pnlHopTimes.add(txtFWHTime); txtFWHTime.setText("20.0"); } { jLabelc5 = new JLabel(); pnlHopTimes.add(jLabelc5); jLabelc5.setText("Mash Hop (min):"); } { txtMashHopTime = new JTextField(); pnlHopTimes.add(txtMashHopTime); txtMashHopTime.setText("2.0"); } } } pnlHopsCalc = new JPanel(); BoxLayout pnlHopsCalcLayout = new BoxLayout(pnlHopsCalc, javax.swing.BoxLayout.Y_AXIS); pnlHopsCalc.setLayout(pnlHopsCalcLayout); pnlCalculations.add(pnlHopsCalc, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); pnlCalculations.add(getPnlWaterUsage(), new GridBagConstraints(1, 2, 1, 2, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); pnlCalculations.add(getPnlColourOptions(), new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); pnlCalculations.add(getPnlEvaporation(), new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); pnlHopsCalc.setPreferredSize(new java.awt.Dimension(117, 107)); pnlHopsCalc.setBorder(BorderFactory .createTitledBorder("IBU Calc Method:")); { rbTinseth = new JRadioButton(); pnlHopsCalc.add(rbTinseth); rbTinseth.setText("Tinseth"); bgHopsCalc.add(rbTinseth); } { rbRager = new JRadioButton(); pnlHopsCalc.add(rbRager); rbRager.setText("Rager"); bgHopsCalc.add(rbRager); } { rbGaretz = new JRadioButton(); pnlHopsCalc.add(rbGaretz); rbGaretz.setText("Garetz"); bgHopsCalc.add(rbGaretz); } } } } catch (Exception e) { e.printStackTrace(); } } } { costCarbPanel = new JPanel(); BorderLayout costCarbPanelLayout = new BorderLayout(); costCarbPanel.setLayout(costCarbPanelLayout); jTabbedPane1.addTab("Cost & Carb", null, costCarbPanel, null); { carbPanel = new JPanel(); costCarbPanel.add(carbPanel, BorderLayout.CENTER); carbPanel.setBorder(BorderFactory.createTitledBorder(null, "Carbonation", TitledBorder.LEADING, TitledBorder.TOP)); { jLabel3 = new JLabel(); carbPanel.add(jLabel3); jLabel3.setText("Not implemented"); } } { jPanel2 = new JPanel(); costCarbPanel.add(jPanel2, BorderLayout.NORTH); GridBagLayout jPanel2Layout = new GridBagLayout(); jPanel2Layout.rowWeights = new double[]{0.1, 0.1, 0.4}; jPanel2Layout.rowHeights = new int[]{7, 7, 7}; jPanel2Layout.columnWeights = new double[]{0.1, 0.1, 0.1}; jPanel2Layout.columnWidths = new int[]{7, 7, 7}; jPanel2.setPreferredSize(new java.awt.Dimension(232, 176)); jPanel2.setBorder(BorderFactory.createTitledBorder("Cost")); jPanel2.setLayout(jPanel2Layout); { jLabel1 = new JLabel(); jPanel2.add(jLabel1, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel1.setText("Other Cost:"); } { txtOtherCost = new JTextField(); jPanel2.add(txtOtherCost, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); txtOtherCost.setText("$0.00"); txtOtherCost.setPreferredSize(new java.awt.Dimension(62, 20)); } { jLabel2 = new JLabel(); jPanel2.add(jLabel2, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel2.setText("Bottle Size:"); } { cmbBottleSize = new JComboBox(); cmbBottleSizeModel = new ComboModel(); cmbBottleSizeModel.setList(new Quantity().getListofUnits("vol")); cmbBottleSize.setModel(cmbBottleSizeModel); jPanel2.add(cmbBottleSize, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); cmbBottleSize.setPreferredSize(new java.awt.Dimension(89, 20)); jPanel2.add(getTxtBottleSize(), new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); } } { } } { pnlBrewer = new JPanel(); GridBagLayout pnlBrewerLayout = new GridBagLayout(); pnlBrewerLayout.rowWeights = new double[]{0.1, 0.1, 0.3, 0.3}; pnlBrewerLayout.rowHeights = new int[]{2, 2, 7, 7}; pnlBrewerLayout.columnWeights = new double[]{0.1, 0.1, 0.1, 0.1}; pnlBrewerLayout.columnWidths = new int[]{7, 7, 7, 7}; pnlBrewer.setLayout(pnlBrewerLayout); jTabbedPane1.addTab("Brewer", null, pnlBrewer, null); { jLabel4 = new JLabel(); pnlBrewer.add(jLabel4, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel4.setText("Name:"); } { txtBrewerName = new JTextField(); pnlBrewer.add(txtBrewerName, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); txtBrewerName.setText("Your Name"); } { jLabel5 = new JLabel(); pnlBrewer.add(jLabel5, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel5.setText("Phone:"); } { txtPhone = new JTextField(); pnlBrewer.add(txtPhone, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); txtPhone.setText("Your Phone"); } { jLabel6 = new JLabel(); pnlBrewer.add(jLabel6, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel6.setText("Club Name:"); } { txtClubName = new JTextField(); pnlBrewer.add(txtClubName, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); txtClubName.setText("Club Name"); } { jLabel7 = new JLabel(); pnlBrewer.add(jLabel7, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel7.setText("Email:"); } { txtEmail = new JTextField(); pnlBrewer.add(txtEmail, new GridBagConstraints(3, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); txtEmail.setText("Email"); } } { pnlDatabase = new JPanel(); BorderLayout pnlDatabaseLayout = new BorderLayout(); pnlDatabase.setLayout(pnlDatabaseLayout); pnlDatabase.add(getPnlDefaultDB(), BorderLayout.NORTH); pnlDatabase.add(getPnlSortOrder(), BorderLayout.WEST); jTabbedPane1.addTab("Database", null, pnlDatabase, null); pnlDatabase.setVisible(false); } newRecipePanel = new JPanel(); GridBagLayout newRecipePanelLayout = new GridBagLayout(); newRecipePanelLayout.rowWeights = new double[]{0.1, 0.1, 0.1, 0.1}; newRecipePanelLayout.rowHeights = new int[]{7, 7, 7, 7}; newRecipePanelLayout.columnWeights = new double[]{0.1, 0.1, 0.1, 0.1}; newRecipePanelLayout.columnWidths = new int[]{7, 7, 7, 7}; newRecipePanel.setLayout(newRecipePanelLayout); jTabbedPane1.addTab("New Recipe Defaults", null, newRecipePanel, null); appearancePanel = new JPanel(); BorderLayout appearancePanelLayout = new BorderLayout(); appearancePanel.setLayout(appearancePanelLayout); jTabbedPane1.addTab("Appearance", null, appearancePanel, null);/* landfPanel = new JPanel(); appearancePanel.add(landfPanel, BorderLayout.NORTH); jLabel19 = new JLabel(); landfPanel.add(jLabel19); jLabel19.setText("Look and Feel:"); landfCombo = new JComboBox(looks.toArray()); landfPanel.add(landfCombo);*/ colourPanel = new JPanel(); appearancePanel.add(colourPanel, BorderLayout.CENTER); GridBagLayout colourPanelLayout = new GridBagLayout(); colourPanelLayout.rowWeights = new double[] {0.1, 0.1, 0.1, 0.1, 0.1, 0.1}; colourPanelLayout.rowHeights = new int[] {7, 7, 7, 7, 7, 7}; colourPanelLayout.columnWeights = new double[] {0.1, 0.1, 0.1, 0.1, 0.1, 0.1}; colourPanelLayout.columnWidths = new int[] {7, 7, 7, 7, 7, 7}; colourPanel.setLayout(colourPanelLayout); colourPanel.setPreferredSize(new java.awt.Dimension(340, 223)); colourPanel.setBorder(BorderFactory.createTitledBorder("Colour Swatch")); colMethod1rb = new JRadioButton(); colMethod1rb.addActionListener(this); colourGroup.add(colMethod1rb); colourPanel.add(colMethod1rb, new GridBagConstraints(0, 0, 3, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); colMethod1rb.setText("Colour Method 1"); colMethod2rb = new JRadioButton(); colMethod2rb.addActionListener(this); colourGroup.add(colMethod2rb); colourPanel.add(colMethod2rb, new GridBagConstraints(3, 0, 3, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); colMethod2rb.setText("Colour Method 2"); jLabel13 = new JLabel(); colourPanel.add(jLabel13, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); jLabel13.setText("Straw \n(2)"); jLabel14 = new JLabel(); colourPanel.add(jLabel14, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); jLabel14.setText("Pale\n(4)"); jLabel15 = new JLabel(); colourPanel.add(jLabel15, new GridBagConstraints(2, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); jLabel15.setText("Amber\n(8)"); jLabel16 = new JLabel(); colourPanel.add(jLabel16, new GridBagConstraints(3, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); jLabel16.setText("Copper (15)"); jLabel17 = new JLabel(); colourPanel.add(jLabel17, new GridBagConstraints(4, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); jLabel17.setText("Brown (20)"); jLabel18 = new JLabel(); colourPanel.add(jLabel18, new GridBagConstraints(5, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); jLabel18.setText("Black (30)"); stawPanel = new JPanel(); colourPanel.add(stawPanel, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); stawPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); palePanel = new JPanel(); colourPanel.add(palePanel, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); palePanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); amberPanel = new JPanel(); colourPanel.add(amberPanel, new GridBagConstraints(2, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); amberPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); copperPanel = new JPanel(); colourPanel.add(copperPanel, new GridBagConstraints(3, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); copperPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); brownPanel = new JPanel(); colourPanel.add(brownPanel, new GridBagConstraints(4, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); brownPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); blackPanel = new JPanel(); colourPanel.add(blackPanel, new GridBagConstraints(5, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); blackPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); SpinnerNumberModel redSpnModel = new SpinnerNumberModel(8,0,255,1); redSpn = new JSpinner(); colourPanel.add(redSpn, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); redSpn.setModel(redSpnModel); redSpn.addChangeListener(this); SpinnerNumberModel greenSpnModel = new SpinnerNumberModel(30,0,255,1); greenSpn = new JSpinner(); colourPanel.add(greenSpn, new GridBagConstraints(3, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); greenSpn.setModel(greenSpnModel); greenSpn.addChangeListener(this); SpinnerNumberModel blueSpnModel = new SpinnerNumberModel(20,0,255,1); blueSpn = new JSpinner(); colourPanel.add(blueSpn, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); blueSpn.setModel(blueSpnModel); blueSpn.addChangeListener(this); SpinnerNumberModel alphaSpnModel = new SpinnerNumberModel(255,0,255,1); alphaSpn = new JSpinner(); colourPanel.add(alphaSpn, new GridBagConstraints(3, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); alphaSpn.setModel(alphaSpnModel); alphaSpn.addChangeListener(this); jLabel20 = new JLabel(); colourPanel.add(jLabel20, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel20.setText("Red:"); jLabel21 = new JLabel(); colourPanel.add(jLabel21, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel21.setText("Blue:"); jLabel22 = new JLabel(); colourPanel.add(jLabel22, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel22.setText("Green:"); jLabel23 = new JLabel(); colourPanel.add(jLabel23, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel23.setText("Alpha:"); mashPanel = new JPanel(); newRecipePanel.add(mashPanel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); mashPanel.setBorder(BorderFactory.createTitledBorder("Mash")); jPanel1 = new JPanel(); GridBagLayout jPanel1Layout = new GridBagLayout(); jPanel1Layout.rowWeights = new double[] {0.1, 0.1, 0.1, 0.1}; jPanel1Layout.rowHeights = new int[] {7, 7, 7, 7}; jPanel1Layout.columnWeights = new double[] {0.1, 0.1}; jPanel1Layout.columnWidths = new int[] {7, 7}; jPanel1.setLayout(jPanel1Layout); newRecipePanel.add(jPanel1, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); jPanel1.setBorder(BorderFactory.createTitledBorder("Units")); jLabel19 = new JLabel(); jPanel1.add(jLabel19, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel19.setText("Malt Units:"); maltUnitsCombo = new JComboBox(); jPanel1.add(maltUnitsCombo, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); maltUnitsComboModel = new ComboModel(); maltUnitsComboModel.setList(new Quantity().getListofUnits("weight")); maltUnitsCombo.setModel(maltUnitsComboModel); jLabel24 = new JLabel(); jPanel1.add(jLabel24, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel24.setText("Hops Units:"); hopsUnitsCombo = new JComboBox(); jPanel1.add(hopsUnitsCombo, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); hopsUnitsComboModel = new ComboModel(); hopsUnitsComboModel.setList(new Quantity().getListofUnits("weight")); hopsUnitsCombo.setModel(hopsUnitsComboModel); jLabel25 = new JLabel(); jPanel1.add(jLabel25, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel25.setText("Vol Units:"); volUnitsCombo = new JComboBox(); volUnitsCombo.addActionListener(new ActionListener() { public void actionPerformed (ActionEvent e){ setEvapLable(); } }); jPanel1.add(volUnitsCombo, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); volUnitsComboModel = new ComboModel(); volUnitsComboModel.setList(new Quantity().getListofUnits("vol")); volUnitsCombo.setModel(volUnitsComboModel); jLabel26 = new JLabel(); jPanel1.add(jLabel26, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel26.setText("Batch Size:"); batchSizeTxt = new JTextField(); jPanel1.add(batchSizeTxt, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); batchSizeTxt.setText("jTextField1"); jLabel12 = new JLabel(); mashPanel.add(jLabel12); jLabel12.setText("Boil Temp (F):"); boilTempTxt = new JTextField(); mashPanel.add(boilTempTxt, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); boilTempTxt.setText("212"); boilTempTxt.setPreferredSize(new java.awt.Dimension(43, 20)); } getContentPane().add(BorderLayout.CENTER, jTabbedPane1); getContentPane().add(BorderLayout.SOUTH, buttons); setSize(500, 500); }
1,116,779
private void layoutUi() { JPanel buttons = new JPanel(); okButton = new JButton("OK"); okButton.addActionListener(this); cancelButton = new JButton("Cancel"); cancelButton.addActionListener(this); buttons.setLayout(new FlowLayout(FlowLayout.RIGHT)); buttons.add(cancelButton); buttons.add(okButton); getContentPane().setLayout(new BorderLayout()); this.setFocusTraversalKeysEnabled(false); { jTabbedPane1 = new JTabbedPane(); getContentPane().add(jTabbedPane1, BorderLayout.CENTER); { pnlCalculations = new JPanel(); jTabbedPane1.addTab("Calculations", null, pnlCalculations, null); { try { { GridBagLayout thisLayout = new GridBagLayout(); thisLayout.rowWeights = new double[]{0.1, 0.1, 0.1, 0.1}; thisLayout.rowHeights = new int[]{7, 7, 7, 7}; thisLayout.columnWeights = new double[]{0.1, 0.2}; thisLayout.columnWidths = new int[]{7, 7}; pnlCalculations.setLayout(thisLayout); pnlCalculations.setPreferredSize(new java.awt.Dimension(524, 372)); { { bgHopsCalc = new ButtonGroup(); { pnlHops = new JPanel(); GridLayout pnlHopsLayout = new GridLayout(2, 2); pnlHopsLayout.setColumns(2); pnlHopsLayout.setHgap(5); pnlHopsLayout.setVgap(5); pnlHopsLayout.setRows(2); pnlHops.setLayout(pnlHopsLayout); pnlCalculations.add(pnlHops, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); pnlHops .setBorder(BorderFactory .createTitledBorder("Hops:")); { jLabelc1 = new JLabel(); pnlHops.add(jLabelc1); jLabelc1.setText("Pellet Hops +%"); } { txtPellet = new JTextField(); pnlHops.add(txtPellet); txtPellet.setPreferredSize(new java.awt.Dimension(20, 20)); } { jLabelc2 = new JLabel(); pnlHops.add(jLabelc2); jLabelc2.setText("Tinseth Utilization Factor"); } { txtTinsethUtil = new JTextField(); pnlHops.add(txtTinsethUtil); txtTinsethUtil.setText("4.15"); } } { pnlAlc = new JPanel(); BoxLayout pnlAlcLayout = new BoxLayout(pnlAlc, javax.swing.BoxLayout.Y_AXIS); pnlAlc.setLayout(pnlAlcLayout); pnlCalculations.add(pnlAlc, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); pnlAlc.setBorder(BorderFactory .createTitledBorder("Alcohol By:")); { rbABV = new JRadioButton(); pnlAlc.add(rbABV); bgAlc.add(rbABV); rbABV.setText("Volume"); } { rbABW = new JRadioButton(); pnlAlc.add(rbABW); bgAlc.add(rbABW); rbABW.setText("Weight"); } } { pnlHopTimes = new JPanel(); GridLayout pnlHopTimesLayout = new GridLayout(3, 2); pnlHopTimesLayout.setColumns(2); pnlHopTimesLayout.setHgap(5); pnlHopTimesLayout.setVgap(5); pnlHopTimesLayout.setRows(3); pnlHopTimes.setLayout(pnlHopTimesLayout); pnlCalculations.add(pnlHopTimes, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); pnlHopTimes.setBorder(BorderFactory .createTitledBorder("Hop Times:")); { jLabelc3 = new JLabel(); pnlHopTimes.add(jLabelc3); jLabelc3.setText("Dry (min):"); } { txtDryHopTime = new JTextField(); pnlHopTimes.add(txtDryHopTime); txtDryHopTime.setText("0.0"); } { jLabelc4 = new JLabel(); pnlHopTimes.add(jLabelc4); jLabelc4.setText("FWH, boil minus (min):"); } { txtFWHTime = new JTextField(); pnlHopTimes.add(txtFWHTime); txtFWHTime.setText("20.0"); } { jLabelc5 = new JLabel(); pnlHopTimes.add(jLabelc5); jLabelc5.setText("Mash Hop (min):"); } { txtMashHopTime = new JTextField(); pnlHopTimes.add(txtMashHopTime); txtMashHopTime.setText("2.0"); } } } pnlHopsCalc = new JPanel(); BoxLayout pnlHopsCalcLayout = new BoxLayout(pnlHopsCalc, javax.swing.BoxLayout.Y_AXIS); pnlHopsCalc.setLayout(pnlHopsCalcLayout); pnlCalculations.add(pnlHopsCalc, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); pnlCalculations.add(getPnlWaterUsage(), new GridBagConstraints(1, 2, 1, 2, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); pnlCalculations.add(getPnlColourOptions(), new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); pnlCalculations.add(getPnlEvaporation(), new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); pnlHopsCalc.setPreferredSize(new java.awt.Dimension(117, 107)); pnlHopsCalc.setBorder(BorderFactory .createTitledBorder("IBU Calc Method:")); { rbTinseth = new JRadioButton(); pnlHopsCalc.add(rbTinseth); rbTinseth.setText("Tinseth"); bgHopsCalc.add(rbTinseth); } { rbRager = new JRadioButton(); pnlHopsCalc.add(rbRager); rbRager.setText("Rager"); bgHopsCalc.add(rbRager); } { rbGaretz = new JRadioButton(); pnlHopsCalc.add(rbGaretz); rbGaretz.setText("Garetz"); bgHopsCalc.add(rbGaretz); } } } } catch (Exception e) { e.printStackTrace(); } } } { costCarbPanel = new JPanel(); BorderLayout costCarbPanelLayout = new BorderLayout(); costCarbPanel.setLayout(costCarbPanelLayout); jTabbedPane1.addTab("Cost & Carb", null, costCarbPanel, null); { carbPanel = new JPanel(); costCarbPanel.add(carbPanel, BorderLayout.CENTER); carbPanel.setBorder(BorderFactory.createTitledBorder(null, "Carbonation", TitledBorder.LEADING, TitledBorder.TOP)); { jLabel3 = new JLabel(); carbPanel.add(jLabel3); jLabel3.setText("Not implemented"); } } { jPanel2 = new JPanel(); costCarbPanel.add(jPanel2, BorderLayout.NORTH); GridBagLayout jPanel2Layout = new GridBagLayout(); jPanel2Layout.rowWeights = new double[]{0.1, 0.1, 0.4}; jPanel2Layout.rowHeights = new int[]{7, 7, 7}; jPanel2Layout.columnWeights = new double[]{0.1, 0.1, 0.1}; jPanel2Layout.columnWidths = new int[]{7, 7, 7}; jPanel2.setPreferredSize(new java.awt.Dimension(232, 176)); jPanel2.setBorder(BorderFactory.createTitledBorder("Cost")); jPanel2.setLayout(jPanel2Layout); { jLabel1 = new JLabel(); jPanel2.add(jLabel1, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel1.setText("Other Cost:"); } { txtOtherCost = new JTextField(); jPanel2.add(txtOtherCost, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); txtOtherCost.setText("$0.00"); txtOtherCost.setPreferredSize(new java.awt.Dimension(62, 20)); } { jLabel2 = new JLabel(); jPanel2.add(jLabel2, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel2.setText("Bottle Size:"); } { cmbBottleSize = new JComboBox(); cmbBottleSizeModel = new ComboModel(); cmbBottleSizeModel.setList(new Quantity().getListofUnits("vol")); cmbBottleSize.setModel(cmbBottleSizeModel); jPanel2.add(cmbBottleSize, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); cmbBottleSize.setPreferredSize(new java.awt.Dimension(89, 20)); jPanel2.add(getTxtBottleSize(), new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); } } { } } { pnlBrewer = new JPanel(); GridBagLayout pnlBrewerLayout = new GridBagLayout(); pnlBrewerLayout.rowWeights = new double[]{0.1, 0.1, 0.3, 0.3}; pnlBrewerLayout.rowHeights = new int[]{2, 2, 7, 7}; pnlBrewerLayout.columnWeights = new double[]{0.1, 0.1, 0.1, 0.1}; pnlBrewerLayout.columnWidths = new int[]{7, 7, 7, 7}; pnlBrewer.setLayout(pnlBrewerLayout); jTabbedPane1.addTab("Brewer", null, pnlBrewer, null); { jLabel4 = new JLabel(); pnlBrewer.add(jLabel4, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel4.setText("Name:"); } { txtBrewerName = new JTextField(); pnlBrewer.add(txtBrewerName, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); txtBrewerName.setText("Your Name"); } { jLabel5 = new JLabel(); pnlBrewer.add(jLabel5, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel5.setText("Phone:"); } { txtPhone = new JTextField(); pnlBrewer.add(txtPhone, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); txtPhone.setText("Your Phone"); } { jLabel6 = new JLabel(); pnlBrewer.add(jLabel6, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel6.setText("Club Name:"); } { txtClubName = new JTextField(); pnlBrewer.add(txtClubName, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); txtClubName.setText("Club Name"); } { jLabel7 = new JLabel(); pnlBrewer.add(jLabel7, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel7.setText("Email:"); } { txtEmail = new JTextField(); pnlBrewer.add(txtEmail, new GridBagConstraints(3, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); txtEmail.setText("Email"); } } { pnlDatabase = new JPanel(); BorderLayout pnlDatabaseLayout = new BorderLayout(); pnlDatabase.setLayout(pnlDatabaseLayout); pnlDatabase.add(getPnlDefaultDB(), BorderLayout.NORTH); pnlDatabase.add(getPnlSortOrder(), BorderLayout.WEST); jTabbedPane1.addTab("Database", null, pnlDatabase, null); pnlDatabase.setVisible(false); } newRecipePanel = new JPanel(); GridBagLayout newRecipePanelLayout = new GridBagLayout(); newRecipePanelLayout.rowWeights = new double[]{0.1, 0.1, 0.1, 0.1}; newRecipePanelLayout.rowHeights = new int[]{7, 7, 7, 7}; newRecipePanelLayout.columnWeights = new double[]{0.1, 0.1, 0.1, 0.1}; newRecipePanelLayout.columnWidths = new int[]{7, 7, 7, 7}; newRecipePanel.setLayout(newRecipePanelLayout); jTabbedPane1.addTab("New Recipe Defaults", null, newRecipePanel, null); appearancePanel = new JPanel(); BorderLayout appearancePanelLayout = new BorderLayout(); appearancePanel.setLayout(appearancePanelLayout); jTabbedPane1.addTab("Appearance", null, appearancePanel, null);/* landfPanel = new JPanel(); appearancePanel.add(landfPanel, BorderLayout.NORTH); jLabel19 = new JLabel(); landfPanel.add(jLabel19); jLabel19.setText("Look and Feel:"); landfCombo = new JComboBox(looks.toArray()); landfPanel.add(landfCombo);*/ colourPanel = new JPanel(); appearancePanel.add(colourPanel, BorderLayout.CENTER); GridBagLayout colourPanelLayout = new GridBagLayout(); colourPanelLayout.rowWeights = new double[] {0.1, 0.1, 0.1, 0.1, 0.1, 0.1}; colourPanelLayout.rowHeights = new int[] {7, 7, 7, 7, 7, 7}; colourPanelLayout.columnWeights = new double[] {0.1, 0.1, 0.1, 0.1, 0.1, 0.1}; colourPanelLayout.columnWidths = new int[] {7, 7, 7, 7, 7, 7}; colourPanel.setLayout(colourPanelLayout); colourPanel.setPreferredSize(new java.awt.Dimension(340, 223)); colourPanel.setBorder(BorderFactory.createTitledBorder("Colour Swatch")); colMethod1rb = new JRadioButton(); colMethod1rb.addActionListener(this); colourGroup.add(colMethod1rb); colourPanel.add(colMethod1rb, new GridBagConstraints(0, 0, 3, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); colMethod1rb.setText("Colour Method 1"); colMethod2rb = new JRadioButton(); colMethod2rb.addActionListener(this); colourGroup.add(colMethod2rb); colourPanel.add(colMethod2rb, new GridBagConstraints(3, 0, 3, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); colMethod2rb.setText("Colour Method 2"); jLabel13 = new JLabel(); colourPanel.add(jLabel13, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); jLabel13.setText("Straw \n(2)"); jLabel14 = new JLabel(); colourPanel.add(jLabel14, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); jLabel14.setText("Pale\n(4)"); jLabel15 = new JLabel(); colourPanel.add(jLabel15, new GridBagConstraints(2, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); jLabel15.setText("Amber\n(8)"); jLabel16 = new JLabel(); colourPanel.add(jLabel16, new GridBagConstraints(3, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); jLabel16.setText("Copper (15)"); jLabel17 = new JLabel(); colourPanel.add(jLabel17, new GridBagConstraints(4, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); jLabel17.setText("Brown (20)"); jLabel18 = new JLabel(); colourPanel.add(jLabel18, new GridBagConstraints(5, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); jLabel18.setText("Black (30)"); stawPanel = new JPanel(); colourPanel.add(stawPanel, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); stawPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); palePanel = new JPanel(); colourPanel.add(palePanel, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); palePanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); amberPanel = new JPanel(); colourPanel.add(amberPanel, new GridBagConstraints(2, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); amberPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); copperPanel = new JPanel(); colourPanel.add(copperPanel, new GridBagConstraints(3, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); copperPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); brownPanel = new JPanel(); colourPanel.add(brownPanel, new GridBagConstraints(4, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); brownPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); blackPanel = new JPanel(); colourPanel.add(blackPanel, new GridBagConstraints(5, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); blackPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); SpinnerNumberModel redSpnModel = new SpinnerNumberModel(8,0,255,1); redSpn = new JSpinner(); colourPanel.add(redSpn, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); redSpn.setModel(redSpnModel); redSpn.addChangeListener(this); SpinnerNumberModel greenSpnModel = new SpinnerNumberModel(30,0,255,1); greenSpn = new JSpinner(); colourPanel.add(greenSpn, new GridBagConstraints(3, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); greenSpn.setModel(greenSpnModel); greenSpn.addChangeListener(this); SpinnerNumberModel blueSpnModel = new SpinnerNumberModel(20,0,255,1); blueSpn = new JSpinner(); colourPanel.add(blueSpn, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); blueSpn.setModel(blueSpnModel); blueSpn.addChangeListener(this); SpinnerNumberModel alphaSpnModel = new SpinnerNumberModel(255,0,255,1); alphaSpn = new JSpinner(); colourPanel.add(alphaSpn, new GridBagConstraints(3, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); alphaSpn.setModel(alphaSpnModel); alphaSpn.addChangeListener(this); jLabel20 = new JLabel(); colourPanel.add(jLabel20, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel20.setText("Red:"); jLabel21 = new JLabel(); colourPanel.add(jLabel21, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel21.setText("Blue:"); jLabel22 = new JLabel(); colourPanel.add(jLabel22, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel22.setText("Green:"); jLabel23 = new JLabel(); colourPanel.add(jLabel23, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel23.setText("Alpha:"); mashPanel = new JPanel(); newRecipePanel.add(mashPanel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); mashPanel.setBorder(BorderFactory.createTitledBorder("Mash")); jPanel1 = new JPanel(); GridBagLayout jPanel1Layout = new GridBagLayout(); jPanel1Layout.rowWeights = new double[] {0.1, 0.1, 0.1, 0.1}; jPanel1Layout.rowHeights = new int[] {7, 7, 7, 7}; jPanel1Layout.columnWeights = new double[] {0.1, 0.1}; jPanel1Layout.columnWidths = new int[] {7, 7}; jPanel1.setLayout(jPanel1Layout); newRecipePanel.add(jPanel1, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); jPanel1.setBorder(BorderFactory.createTitledBorder("Units")); jLabel19 = new JLabel(); jPanel1.add(jLabel19, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel19.setText("Malt Units:"); maltUnitsCombo = new JComboBox(); jPanel1.add(maltUnitsCombo, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); maltUnitsComboModel = new ComboModel(); maltUnitsComboModel.setList(new Quantity().getListofUnits("weight")); maltUnitsCombo.setModel(maltUnitsComboModel); jLabel24 = new JLabel(); jPanel1.add(jLabel24, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel24.setText("Hops Units:"); hopsUnitsCombo = new JComboBox(); jPanel1.add(hopsUnitsCombo, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); hopsUnitsComboModel = new ComboModel(); hopsUnitsComboModel.setList(new Quantity().getListofUnits("weight")); hopsUnitsCombo.setModel(hopsUnitsComboModel); jLabel25 = new JLabel(); jPanel1.add(jLabel25, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel25.setText("Vol Units:"); volUnitsCombo = new JComboBox(); volUnitsCombo.addActionListener(new ActionListener() { public void actionPerformed (ActionEvent e){ setEvapLable(); } }); jPanel1.add(volUnitsCombo, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); volUnitsComboModel = new ComboModel(); volUnitsComboModel.setList(new Quantity().getListofUnits("vol")); volUnitsCombo.setModel(volUnitsComboModel); jLabel26 = new JLabel(); jPanel1.add(jLabel26, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel26.setText("Batch Size:"); batchSizeTxt = new JTextField(); jPanel1.add(batchSizeTxt, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); batchSizeTxt.setText("jTextField1"); jLabel12 = new JLabel(); mashPanel.add(jLabel12); jLabel12.setText("Boil Temp (F):"); boilTempTxt = new JTextField(); mashPanel.add(boilTempTxt); boilTempTxt.setText("212"); boilTempTxt.setPreferredSize(new java.awt.Dimension(43, 20)); } getContentPane().add(BorderLayout.CENTER, jTabbedPane1); getContentPane().add(BorderLayout.SOUTH, buttons); setSize(500, 500); }
private void layoutUi() { JPanel buttons = new JPanel(); okButton = new JButton("OK"); okButton.addActionListener(this); cancelButton = new JButton("Cancel"); cancelButton.addActionListener(this); buttons.setLayout(new FlowLayout(FlowLayout.RIGHT)); buttons.add(cancelButton); buttons.add(okButton); getContentPane().setLayout(new BorderLayout()); this.setFocusTraversalKeysEnabled(false); { jTabbedPane1 = new JTabbedPane(); getContentPane().add(jTabbedPane1, BorderLayout.CENTER); { pnlCalculations = new JPanel(); jTabbedPane1.addTab("Calculations", null, pnlCalculations, null); { try { { GridBagLayout thisLayout = new GridBagLayout(); thisLayout.rowWeights = new double[]{0.1, 0.1, 0.1, 0.1}; thisLayout.rowHeights = new int[]{7, 7, 7, 7}; thisLayout.columnWeights = new double[]{0.1, 0.2}; thisLayout.columnWidths = new int[]{7, 7}; pnlCalculations.setLayout(thisLayout); pnlCalculations.setPreferredSize(new java.awt.Dimension(524, 372)); { { bgHopsCalc = new ButtonGroup(); { pnlHops = new JPanel(); GridLayout pnlHopsLayout = new GridLayout(2, 2); pnlHopsLayout.setColumns(2); pnlHopsLayout.setHgap(5); pnlHopsLayout.setVgap(5); pnlHopsLayout.setRows(2); pnlHops.setLayout(pnlHopsLayout); pnlCalculations.add(pnlHops, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); pnlHops .setBorder(BorderFactory .createTitledBorder("Hops:")); { jLabelc1 = new JLabel(); pnlHops.add(jLabelc1); jLabelc1.setText("Pellet Hops +%"); } { txtPellet = new JTextField(); pnlHops.add(txtPellet); txtPellet.setPreferredSize(new java.awt.Dimension(20, 20)); } { jLabelc2 = new JLabel(); pnlHops.add(jLabelc2); jLabelc2.setText("Tinseth Utilization Factor"); } { txtTinsethUtil = new JTextField(); pnlHops.add(txtTinsethUtil); txtTinsethUtil.setText("4.15"); } } { pnlAlc = new JPanel(); BoxLayout pnlAlcLayout = new BoxLayout(pnlAlc, javax.swing.BoxLayout.Y_AXIS); pnlAlc.setLayout(pnlAlcLayout); pnlCalculations.add(pnlAlc, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); pnlAlc.setBorder(BorderFactory .createTitledBorder("Alcohol By:")); { rbABV = new JRadioButton(); pnlAlc.add(rbABV); bgAlc.add(rbABV); rbABV.setText("Volume"); } { rbABW = new JRadioButton(); pnlAlc.add(rbABW); bgAlc.add(rbABW); rbABW.setText("Weight"); } } { pnlHopTimes = new JPanel(); GridLayout pnlHopTimesLayout = new GridLayout(3, 2); pnlHopTimesLayout.setColumns(2); pnlHopTimesLayout.setHgap(5); pnlHopTimesLayout.setVgap(5); pnlHopTimesLayout.setRows(3); pnlHopTimes.setLayout(pnlHopTimesLayout); pnlCalculations.add(pnlHopTimes, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); pnlHopTimes.setBorder(BorderFactory .createTitledBorder("Hop Times:")); { jLabelc3 = new JLabel(); pnlHopTimes.add(jLabelc3); jLabelc3.setText("Dry (min):"); } { txtDryHopTime = new JTextField(); pnlHopTimes.add(txtDryHopTime); txtDryHopTime.setText("0.0"); } { jLabelc4 = new JLabel(); pnlHopTimes.add(jLabelc4); jLabelc4.setText("FWH, boil minus (min):"); } { txtFWHTime = new JTextField(); pnlHopTimes.add(txtFWHTime); txtFWHTime.setText("20.0"); } { jLabelc5 = new JLabel(); pnlHopTimes.add(jLabelc5); jLabelc5.setText("Mash Hop (min):"); } { txtMashHopTime = new JTextField(); pnlHopTimes.add(txtMashHopTime); txtMashHopTime.setText("2.0"); } } } pnlHopsCalc = new JPanel(); BoxLayout pnlHopsCalcLayout = new BoxLayout(pnlHopsCalc, javax.swing.BoxLayout.Y_AXIS); pnlHopsCalc.setLayout(pnlHopsCalcLayout); pnlCalculations.add(pnlHopsCalc, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); pnlCalculations.add(getPnlWaterUsage(), new GridBagConstraints(1, 2, 1, 2, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); pnlCalculations.add(getPnlColourOptions(), new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); pnlCalculations.add(getPnlEvaporation(), new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); pnlHopsCalc.setPreferredSize(new java.awt.Dimension(117, 107)); pnlHopsCalc.setBorder(BorderFactory .createTitledBorder("IBU Calc Method:")); { rbTinseth = new JRadioButton(); pnlHopsCalc.add(rbTinseth); rbTinseth.setText("Tinseth"); bgHopsCalc.add(rbTinseth); } { rbRager = new JRadioButton(); pnlHopsCalc.add(rbRager); rbRager.setText("Rager"); bgHopsCalc.add(rbRager); } { rbGaretz = new JRadioButton(); pnlHopsCalc.add(rbGaretz); rbGaretz.setText("Garetz"); bgHopsCalc.add(rbGaretz); } } } } catch (Exception e) { e.printStackTrace(); } } } { costCarbPanel = new JPanel(); BorderLayout costCarbPanelLayout = new BorderLayout(); costCarbPanel.setLayout(costCarbPanelLayout); jTabbedPane1.addTab("Cost & Carb", null, costCarbPanel, null); { carbPanel = new JPanel(); costCarbPanel.add(carbPanel, BorderLayout.CENTER); carbPanel.setBorder(BorderFactory.createTitledBorder(null, "Carbonation", TitledBorder.LEADING, TitledBorder.TOP)); { jLabel3 = new JLabel(); carbPanel.add(jLabel3); jLabel3.setText("Not implemented"); } } { jPanel2 = new JPanel(); costCarbPanel.add(jPanel2, BorderLayout.NORTH); GridBagLayout jPanel2Layout = new GridBagLayout(); jPanel2Layout.rowWeights = new double[]{0.1, 0.1, 0.4}; jPanel2Layout.rowHeights = new int[]{7, 7, 7}; jPanel2Layout.columnWeights = new double[]{0.1, 0.1, 0.1}; jPanel2Layout.columnWidths = new int[]{7, 7, 7}; jPanel2.setPreferredSize(new java.awt.Dimension(232, 176)); jPanel2.setBorder(BorderFactory.createTitledBorder("Cost")); jPanel2.setLayout(jPanel2Layout); { jLabel1 = new JLabel(); jPanel2.add(jLabel1, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel1.setText("Other Cost:"); } { txtOtherCost = new JTextField(); jPanel2.add(txtOtherCost, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); txtOtherCost.setText("$0.00"); txtOtherCost.setPreferredSize(new java.awt.Dimension(62, 20)); } { jLabel2 = new JLabel(); jPanel2.add(jLabel2, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel2.setText("Bottle Size:"); } { cmbBottleSize = new JComboBox(); cmbBottleSizeModel = new ComboModel(); cmbBottleSizeModel.setList(new Quantity().getListofUnits("vol")); cmbBottleSize.setModel(cmbBottleSizeModel); jPanel2.add(cmbBottleSize, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); cmbBottleSize.setPreferredSize(new java.awt.Dimension(89, 20)); jPanel2.add(getTxtBottleSize(), new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); } } { } } { pnlBrewer = new JPanel(); GridBagLayout pnlBrewerLayout = new GridBagLayout(); pnlBrewerLayout.rowWeights = new double[]{0.1, 0.1, 0.3, 0.3}; pnlBrewerLayout.rowHeights = new int[]{2, 2, 7, 7}; pnlBrewerLayout.columnWeights = new double[]{0.1, 0.1, 0.1, 0.1}; pnlBrewerLayout.columnWidths = new int[]{7, 7, 7, 7}; pnlBrewer.setLayout(pnlBrewerLayout); jTabbedPane1.addTab("Brewer", null, pnlBrewer, null); { jLabel4 = new JLabel(); pnlBrewer.add(jLabel4, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel4.setText("Name:"); } { txtBrewerName = new JTextField(); pnlBrewer.add(txtBrewerName, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); txtBrewerName.setText("Your Name"); } { jLabel5 = new JLabel(); pnlBrewer.add(jLabel5, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel5.setText("Phone:"); } { txtPhone = new JTextField(); pnlBrewer.add(txtPhone, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); txtPhone.setText("Your Phone"); } { jLabel6 = new JLabel(); pnlBrewer.add(jLabel6, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel6.setText("Club Name:"); } { txtClubName = new JTextField(); pnlBrewer.add(txtClubName, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); txtClubName.setText("Club Name"); } { jLabel7 = new JLabel(); pnlBrewer.add(jLabel7, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel7.setText("Email:"); } { txtEmail = new JTextField(); pnlBrewer.add(txtEmail, new GridBagConstraints(3, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); txtEmail.setText("Email"); } } { pnlDatabase = new JPanel(); BorderLayout pnlDatabaseLayout = new BorderLayout(); pnlDatabase.setLayout(pnlDatabaseLayout); pnlDatabase.add(getPnlDefaultDB(), BorderLayout.NORTH); pnlDatabase.add(getPnlSortOrder(), BorderLayout.WEST); jTabbedPane1.addTab("Database", null, pnlDatabase, null); pnlDatabase.setVisible(false); } newRecipePanel = new JPanel(); GridBagLayout newRecipePanelLayout = new GridBagLayout(); newRecipePanelLayout.rowWeights = new double[]{0.1, 0.1, 0.1, 0.1}; newRecipePanelLayout.rowHeights = new int[]{7, 7, 7, 7}; newRecipePanelLayout.columnWeights = new double[]{0.1, 0.1, 0.1, 0.1}; newRecipePanelLayout.columnWidths = new int[]{7, 7, 7, 7}; newRecipePanel.setLayout(newRecipePanelLayout); jTabbedPane1.addTab("New Recipe Defaults", null, newRecipePanel, null); appearancePanel = new JPanel(); BorderLayout appearancePanelLayout = new BorderLayout(); appearancePanel.setLayout(appearancePanelLayout); jTabbedPane1.addTab("Appearance", null, appearancePanel, null);/* landfPanel = new JPanel(); appearancePanel.add(landfPanel, BorderLayout.NORTH); jLabel19 = new JLabel(); landfPanel.add(jLabel19); jLabel19.setText("Look and Feel:"); landfCombo = new JComboBox(looks.toArray()); landfPanel.add(landfCombo);*/ colourPanel = new JPanel(); appearancePanel.add(colourPanel, BorderLayout.CENTER); GridBagLayout colourPanelLayout = new GridBagLayout(); colourPanelLayout.rowWeights = new double[] {0.1, 0.1, 0.1, 0.1, 0.1, 0.1}; colourPanelLayout.rowHeights = new int[] {7, 7, 7, 7, 7, 7}; colourPanelLayout.columnWeights = new double[] {0.1, 0.1, 0.1, 0.1, 0.1, 0.1}; colourPanelLayout.columnWidths = new int[] {7, 7, 7, 7, 7, 7}; colourPanel.setLayout(colourPanelLayout); colourPanel.setPreferredSize(new java.awt.Dimension(340, 223)); colourPanel.setBorder(BorderFactory.createTitledBorder("Colour Swatch")); colMethod1rb = new JRadioButton(); colMethod1rb.addActionListener(this); colourGroup.add(colMethod1rb); colourPanel.add(colMethod1rb, new GridBagConstraints(0, 0, 3, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); colMethod1rb.setText("Colour Method 1"); colMethod2rb = new JRadioButton(); colMethod2rb.addActionListener(this); colourGroup.add(colMethod2rb); colourPanel.add(colMethod2rb, new GridBagConstraints(3, 0, 3, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); colMethod2rb.setText("Colour Method 2"); jLabel13 = new JLabel(); colourPanel.add(jLabel13, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); jLabel13.setText("Straw \n(2)"); jLabel14 = new JLabel(); colourPanel.add(jLabel14, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); jLabel14.setText("Pale\n(4)"); jLabel15 = new JLabel(); colourPanel.add(jLabel15, new GridBagConstraints(2, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); jLabel15.setText("Amber\n(8)"); jLabel16 = new JLabel(); colourPanel.add(jLabel16, new GridBagConstraints(3, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); jLabel16.setText("Copper (15)"); jLabel17 = new JLabel(); colourPanel.add(jLabel17, new GridBagConstraints(4, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); jLabel17.setText("Brown (20)"); jLabel18 = new JLabel(); colourPanel.add(jLabel18, new GridBagConstraints(5, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); jLabel18.setText("Black (30)"); stawPanel = new JPanel(); colourPanel.add(stawPanel, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); stawPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); palePanel = new JPanel(); colourPanel.add(palePanel, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); palePanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); amberPanel = new JPanel(); colourPanel.add(amberPanel, new GridBagConstraints(2, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); amberPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); copperPanel = new JPanel(); colourPanel.add(copperPanel, new GridBagConstraints(3, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); copperPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); brownPanel = new JPanel(); colourPanel.add(brownPanel, new GridBagConstraints(4, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); brownPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); blackPanel = new JPanel(); colourPanel.add(blackPanel, new GridBagConstraints(5, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); blackPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); SpinnerNumberModel redSpnModel = new SpinnerNumberModel(8,0,255,1); redSpn = new JSpinner(); colourPanel.add(redSpn, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); redSpn.setModel(redSpnModel); redSpn.addChangeListener(this); SpinnerNumberModel greenSpnModel = new SpinnerNumberModel(30,0,255,1); greenSpn = new JSpinner(); colourPanel.add(greenSpn, new GridBagConstraints(3, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); greenSpn.setModel(greenSpnModel); greenSpn.addChangeListener(this); SpinnerNumberModel blueSpnModel = new SpinnerNumberModel(20,0,255,1); blueSpn = new JSpinner(); colourPanel.add(blueSpn, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); blueSpn.setModel(blueSpnModel); blueSpn.addChangeListener(this); SpinnerNumberModel alphaSpnModel = new SpinnerNumberModel(255,0,255,1); alphaSpn = new JSpinner(); colourPanel.add(alphaSpn, new GridBagConstraints(3, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); alphaSpn.setModel(alphaSpnModel); alphaSpn.addChangeListener(this); jLabel20 = new JLabel(); colourPanel.add(jLabel20, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel20.setText("Red:"); jLabel21 = new JLabel(); colourPanel.add(jLabel21, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel21.setText("Blue:"); jLabel22 = new JLabel(); colourPanel.add(jLabel22, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel22.setText("Green:"); jLabel23 = new JLabel(); colourPanel.add(jLabel23, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel23.setText("Alpha:"); mashPanel = new JPanel(); newRecipePanel.add(mashPanel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); mashPanel.setBorder(BorderFactory.createTitledBorder("Mash")); jPanel1 = new JPanel(); GridBagLayout jPanel1Layout = new GridBagLayout(); jPanel1Layout.rowWeights = new double[] {0.1, 0.1, 0.1, 0.1}; jPanel1Layout.rowHeights = new int[] {7, 7, 7, 7}; jPanel1Layout.columnWeights = new double[] {0.1, 0.1}; jPanel1Layout.columnWidths = new int[] {7, 7}; jPanel1.setLayout(jPanel1Layout); newRecipePanel.add(jPanel1, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); jPanel1.setBorder(BorderFactory.createTitledBorder("Units")); jLabel19 = new JLabel(); jPanel1.add(jLabel19, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel19.setText("Malt Units:"); maltUnitsCombo = new JComboBox(); jPanel1.add(maltUnitsCombo, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); maltUnitsComboModel = new ComboModel(); maltUnitsComboModel.setList(new Quantity().getListofUnits("weight")); maltUnitsCombo.setModel(maltUnitsComboModel); jLabel24 = new JLabel(); jPanel1.add(jLabel24, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel24.setText("Hops Units:"); hopsUnitsCombo = new JComboBox(); jPanel1.add(hopsUnitsCombo, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); hopsUnitsComboModel = new ComboModel(); hopsUnitsComboModel.setList(new Quantity().getListofUnits("weight")); hopsUnitsCombo.setModel(hopsUnitsComboModel); jLabel25 = new JLabel(); jPanel1.add(jLabel25, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel25.setText("Vol Units:"); volUnitsCombo = new JComboBox(); volUnitsCombo.addActionListener(new ActionListener() { public void actionPerformed (ActionEvent e){ setEvapLable(); } }); jPanel1.add(volUnitsCombo, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); volUnitsComboModel = new ComboModel(); volUnitsComboModel.setList(new Quantity().getListofUnits("vol")); volUnitsCombo.setModel(volUnitsComboModel); jLabel26 = new JLabel(); jPanel1.add(jLabel26, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel26.setText("Batch Size:"); batchSizeTxt = new JTextField(); jPanel1.add(batchSizeTxt, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); batchSizeTxt.setText("jTextField1"); jLabel12 = new JLabel(); mashPanel.add(jLabel12); jLabel12.setText("Boil Temp (F):"); boilTempTxt = new JTextField(); mashPanel.add(boilTempTxt); boilTempTxt.setText("212"); boilTempTxt.setPreferredSize(new java.awt.Dimension(45, 20)); boilTempULbl = new JLabel(); mashPanel.add(boilTempULbl, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); boilTempULbl.setText("F"); boilTempULbl.setPreferredSize(new java.awt.Dimension(21, 14)); jLabel27 = new JLabel(); mashPanel.add(jLabel27, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel27.setText("Temp Units:"); frb = new JRadioButton(); mashPanel.add(frb, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); frb.setText("F"); tempUBG.add(frb); frb.setSelected(true); frb.addActionListener(this); crb = new JRadioButton(); mashPanel.add(crb, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); crb.setText("C"); tempUBG.add(crb); crb.addActionListener(this); jLabel28 = new JLabel(); mashPanel.add(jLabel28, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel28.setText("Vol Units:"); mashVolComboModel = new ComboModel(); mashVolComboModel.setList(new Quantity().getListofUnits("vol")); mashVolCombo = new JComboBox(); mashPanel.add(mashVolCombo, new GridBagConstraints(1, 0, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); mashVolCombo.setModel(mashVolComboModel); mashVolCombo.setPreferredSize(new java.awt.Dimension(137, 20)); jLabel29 = new JLabel(); mashPanel.add(jLabel29, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel29.setText("Ratio:"); mashRatioTxt = new JTextField(); mashPanel.add(mashRatioTxt, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); mashRatioTxt.setText("1.25"); mashRatioTxt.setPreferredSize(new java.awt.Dimension(45, 20)); ComboBoxModel mashRatioUComboModel = new DefaultComboBoxModel(new String[] { "qt/l", "l/kg" }); mashRatioUCombo = new JComboBox(); mashPanel.add(mashRatioUCombo, new GridBagConstraints(2, 3, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); mashRatioUCombo.setModel(mashRatioUComboModel); mashRatioUCombo.setPreferredSize(new java.awt.Dimension(71, 20)); } getContentPane().add(BorderLayout.CENTER, jTabbedPane1); getContentPane().add(BorderLayout.SOUTH, buttons); setSize(500, 500); }
1,116,780
private void saveOptions() { // cost tab: opts.setProperty("optMiscCost", txtOtherCost.getText()); opts.setProperty("optBottleSize", txtBottleSize.getText()); opts.setProperty("optBottleU", (String) cmbBottleSize.getSelectedItem()); // Brewer tab: opts.setProperty("optBrewer", txtBrewerName.getText()); opts.setProperty("optPhone", txtPhone.getText()); opts.setProperty("optClub", txtClubName.getText()); opts.setProperty("optEmail", txtEmail.getText()); // calculations tab: if (rbTinseth.isSelected()) opts.setProperty("optIBUCalcMethod", "Tinseth"); if (rbRager.isSelected()) opts.setProperty("optIBUCalcMethod", "Rager"); if (rbGaretz.isSelected()) opts.setProperty("optIBUCalcMethod", "Garetz"); if (rbABV.isSelected()) opts.setProperty("optAlcCalcMethod", "Volume"); if (rbABW.isSelected()) opts.setProperty("optAlcCalcMethod", "Weight"); if (rbSRM.isSelected()) opts.setProperty("optColourMethod", "SRM"); if (rbEBC.isSelected()) opts.setProperty("optColourMethod", "EBC"); if (rbPercent.isSelected()) opts.setProperty("optEvapCalcMethod", "Percent"); if (rbConstant.isSelected()) opts.setProperty("optEvapCalcMethod", "Constant"); opts.setProperty("optEvaporation", evapAmountTxt.getText()); opts.setProperty("optPelletHopsPct", txtPellet.getText()); opts.setProperty("optHopsUtil", txtTinsethUtil.getText()); opts.setProperty("optDryHopTime", txtDryHopTime.getText()); opts.setProperty("optFWHTime", txtFWHTime.getText()); opts.setProperty("optMashHopTime", txtMashHopTime.getText()); opts.setProperty("optKettleLoss", txtLeftInKettle.getText()); opts.setProperty("optMiscLoss", txtMiscLosses.getText()); opts.setProperty("optTrubLoss", txtLostInTrub.getText()); // new recipe tab: opts.setProperty("optBoilTempF", boilTempTxt.getText()); opts.setProperty("optPostBoilVol", batchSizeTxt.getText()); opts.setProperty("optMaltU", maltUnitsComboModel.getSelectedItem().toString()); opts.setProperty("optHopsU", hopsUnitsComboModel.getSelectedItem().toString()); opts.setProperty("optSizeU", volUnitsComboModel.getSelectedItem().toString()); // appearances: opts.setProperty("optRed", redSpn.getValue().toString()); opts.setProperty("optGreen", greenSpn.getValue().toString()); opts.setProperty("optBlue", blueSpn.getValue().toString()); opts.setProperty("optAlpha", alphaSpn.getValue().toString()); if (colMethod1rb.isSelected()) opts.setProperty("optRGBMethod", "1"); else opts.setProperty("optRGBMethod", "2"); }
private void saveOptions() { // cost tab: opts.setProperty("optMiscCost", txtOtherCost.getText()); opts.setProperty("optBottleSize", txtBottleSize.getText()); opts.setProperty("optBottleU", (String) cmbBottleSize.getSelectedItem()); // Brewer tab: opts.setProperty("optBrewer", txtBrewerName.getText()); opts.setProperty("optPhone", txtPhone.getText()); opts.setProperty("optClub", txtClubName.getText()); opts.setProperty("optEmail", txtEmail.getText()); // calculations tab: if (rbTinseth.isSelected()) opts.setProperty("optIBUCalcMethod", "Tinseth"); if (rbRager.isSelected()) opts.setProperty("optIBUCalcMethod", "Rager"); if (rbGaretz.isSelected()) opts.setProperty("optIBUCalcMethod", "Garetz"); if (rbABV.isSelected()) opts.setProperty("optAlcCalcMethod", "Volume"); if (rbABW.isSelected()) opts.setProperty("optAlcCalcMethod", "Weight"); if (rbSRM.isSelected()) opts.setProperty("optColourMethod", "SRM"); if (rbEBC.isSelected()) opts.setProperty("optColourMethod", "EBC"); if (rbPercent.isSelected()) opts.setProperty("optEvapCalcMethod", "Percent"); if (rbConstant.isSelected()) opts.setProperty("optEvapCalcMethod", "Constant"); opts.setProperty("optEvaporation", evapAmountTxt.getText()); opts.setProperty("optPelletHopsPct", txtPellet.getText()); opts.setProperty("optHopsUtil", txtTinsethUtil.getText()); opts.setProperty("optDryHopTime", txtDryHopTime.getText()); opts.setProperty("optFWHTime", txtFWHTime.getText()); opts.setProperty("optMashHopTime", txtMashHopTime.getText()); opts.setProperty("optKettleLoss", txtLeftInKettle.getText()); opts.setProperty("optMiscLoss", txtMiscLosses.getText()); opts.setProperty("optTrubLoss", txtLostInTrub.getText()); // new recipe tab: opts.setProperty("optPostBoilVol", batchSizeTxt.getText()); opts.setProperty("optMaltU", maltUnitsComboModel.getSelectedItem().toString()); opts.setProperty("optHopsU", hopsUnitsComboModel.getSelectedItem().toString()); opts.setProperty("optSizeU", volUnitsComboModel.getSelectedItem().toString()); // appearances: opts.setProperty("optRed", redSpn.getValue().toString()); opts.setProperty("optGreen", greenSpn.getValue().toString()); opts.setProperty("optBlue", blueSpn.getValue().toString()); opts.setProperty("optAlpha", alphaSpn.getValue().toString()); if (colMethod1rb.isSelected()) opts.setProperty("optRGBMethod", "1"); else opts.setProperty("optRGBMethod", "2"); }
1,116,781
private void setOptions() { // 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")); // 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")); setEvapLable(); 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")); // 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() { // new recipe tab: batchSizeTxt.setText(opts.getProperty("optPostBoilVol")); maltUnitsComboModel.addOrInsert(opts.getProperty("optMaltU")); hopsUnitsComboModel.addOrInsert(opts.getProperty("optHopsU")); volUnitsComboModel.addOrInsert(opts.getProperty("optSizeU")); // 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")); setEvapLable(); 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")); // 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,783
public static void main(String args[]) throws IOException { DJepApplet app = new DJepApplet(); app.init(); Frame mainFrame = new Frame("Wallpaper patterns"); mainFrame.setBounds(0,0,200,200); mainFrame.add(app); mainFrame.show(); }
public static void main(String args[]) { DJepApplet app = new DJepApplet(); app.init(); Frame mainFrame = new Frame("Wallpaper patterns"); mainFrame.setBounds(0,0,200,200); mainFrame.add(app); mainFrame.show(); }
1,116,785
private boolean calcChangeLog(Build build, List<String> changedFiles, File changelogFile, BuildListener listener) { if(build.getPreviousBuild()==null || changedFiles.isEmpty()) { // nothing to compare against, or no changes listener.getLogger().println("$ no changes detected"); return createEmptyChangeLog(changelogFile,listener, "changelog"); } listener.getLogger().println("$ computing changelog"); ChangeLogTask task = new ChangeLogTask() { { setOutputStream(System.out); setErrorStream(System.err); } }; task.setProject(new org.apache.tools.ant.Project()); task.setDir(build.getProject().getWorkspace().getLocal()); if(DESCRIPTOR.getCvspassFile().length()!=0) task.setPassfile(new File(DESCRIPTOR.getCvspassFile())); task.setCvsRoot(cvsroot); task.setCvsRsh(cvsRsh); task.setFailOnError(true); task.setDestfile(changelogFile); task.setStart(build.getPreviousBuild().getTimestamp().getTime()); task.setEnd(build.getTimestamp().getTime()); task.setFile(changedFiles); try { task.execute(); return true; } catch( BuildException e ) { e.printStackTrace(listener.error(e.getMessage())); return false; } catch( RuntimeException e ) { // an user reported a NPE inside the changeLog task. // we don't want a bug in Ant to prevent a build. e.printStackTrace(listener.error(e.getMessage())); return true; // so record the message but continue } }
private boolean calcChangeLog(Build build, List<String> changedFiles, File changelogFile, BuildListener listener) { if(build.getPreviousBuild()==null || (changedFiles!=null && changedFiles.isEmpty())) { // nothing to compare against, or no changes listener.getLogger().println("$ no changes detected"); return createEmptyChangeLog(changelogFile,listener, "changelog"); } listener.getLogger().println("$ computing changelog"); ChangeLogTask task = new ChangeLogTask() { { setOutputStream(System.out); setErrorStream(System.err); } }; task.setProject(new org.apache.tools.ant.Project()); task.setDir(build.getProject().getWorkspace().getLocal()); if(DESCRIPTOR.getCvspassFile().length()!=0) task.setPassfile(new File(DESCRIPTOR.getCvspassFile())); task.setCvsRoot(cvsroot); task.setCvsRsh(cvsRsh); task.setFailOnError(true); task.setDestfile(changelogFile); task.setStart(build.getPreviousBuild().getTimestamp().getTime()); task.setEnd(build.getTimestamp().getTime()); task.setFile(changedFiles); try { task.execute(); return true; } catch( BuildException e ) { e.printStackTrace(listener.error(e.getMessage())); return false; } catch( RuntimeException e ) { // an user reported a NPE inside the changeLog task. // we don't want a bug in Ant to prevent a build. e.printStackTrace(listener.error(e.getMessage())); return true; // so record the message but continue } }
1,116,786
private boolean calcChangeLog(Build build, List<String> changedFiles, File changelogFile, BuildListener listener) { if(build.getPreviousBuild()==null || changedFiles.isEmpty()) { // nothing to compare against, or no changes listener.getLogger().println("$ no changes detected"); return createEmptyChangeLog(changelogFile,listener, "changelog"); } listener.getLogger().println("$ computing changelog"); ChangeLogTask task = new ChangeLogTask() { { setOutputStream(System.out); setErrorStream(System.err); } }; task.setProject(new org.apache.tools.ant.Project()); task.setDir(build.getProject().getWorkspace().getLocal()); if(DESCRIPTOR.getCvspassFile().length()!=0) task.setPassfile(new File(DESCRIPTOR.getCvspassFile())); task.setCvsRoot(cvsroot); task.setCvsRsh(cvsRsh); task.setFailOnError(true); task.setDestfile(changelogFile); task.setStart(build.getPreviousBuild().getTimestamp().getTime()); task.setEnd(build.getTimestamp().getTime()); task.setFile(changedFiles); try { task.execute(); return true; } catch( BuildException e ) { e.printStackTrace(listener.error(e.getMessage())); return false; } catch( RuntimeException e ) { // an user reported a NPE inside the changeLog task. // we don't want a bug in Ant to prevent a build. e.printStackTrace(listener.error(e.getMessage())); return true; // so record the message but continue } }
private boolean calcChangeLog(Build build, List<String> changedFiles, File changelogFile, BuildListener listener) { if(build.getPreviousBuild()==null || changedFiles.isEmpty()) { // nothing to compare against, or no changes listener.getLogger().println("$ no changes detected"); return createEmptyChangeLog(changelogFile,listener, "changelog"); } listener.getLogger().println("$ computing changelog"); ChangeLogTask task = new ChangeLogTask() { { setOutputStream(System.out); setErrorStream(System.err); } }; task.setProject(new org.apache.tools.ant.Project()); task.setDir(build.getProject().getWorkspace().getLocal()); if(DESCRIPTOR.getCvspassFile().length()!=0) task.setPassfile(new File(DESCRIPTOR.getCvspassFile())); task.setCvsRoot(cvsroot); task.setCvsRsh(cvsRsh); task.setFailOnError(true); task.setDestfile(changelogFile); task.setStart(build.getPreviousBuild().getTimestamp().getTime()); task.setEnd(build.getTimestamp().getTime()); if(changedFiles!=null) task.setFile(changedFiles); else { if(!flatten) task.setPackage(module); } try { task.execute(); return true; } catch( BuildException e ) { e.printStackTrace(listener.error(e.getMessage())); return false; } catch( RuntimeException e ) { // an user reported a NPE inside the changeLog task. // we don't want a bug in Ant to prevent a build. e.printStackTrace(listener.error(e.getMessage())); return true; // so record the message but continue } }
1,116,787
public boolean checkout(Build build, Launcher launcher, FilePath dir, BuildListener listener, File changelogFile) throws IOException { List<String> changedFiles = null; // files that were affected by update. null this is a check out if(canUseUpdate && isUpdatable(dir.getLocal())) { changedFiles = update(false,launcher,dir,listener); if(changedFiles==null) return false; // failed } else { dir.deleteContents(); String cmd = MessageFormat.format("cvs -Q -z9 -d {0} co {1} {2} {3}", cvsroot, branch!=null?"-r "+branch:"", flatten?"-d "+dir.getName():"", module ); if(!run(launcher,cmd,listener, flatten ? dir.getParent() : dir)) return false; } // archive the workspace to support later tagging // TODO: doing this partially remotely would be faster File archiveFile = getArchiveFile(build); ZipOutputStream zos = new ZipOutputStream(archiveFile); if(flatten) { archive(build.getProject().getWorkspace().getLocal(), module, zos); } else { StringTokenizer tokens = new StringTokenizer(module); while(tokens.hasMoreTokens()) { String m = tokens.nextToken(); archive(new File(build.getProject().getWorkspace().getLocal(),m),m,zos); } } zos.close(); // contribute the tag action build.getActions().add(new TagAction(build)); if(changedFiles==null) // nothing to compare against return createEmptyChangeLog(changelogFile,listener, "changelog"); else return calcChangeLog(build, changedFiles, changelogFile, listener); }
public boolean checkout(Build build, Launcher launcher, FilePath dir, BuildListener listener, File changelogFile) throws IOException { List<String> changedFiles = null; // files that were affected by update. null this is a check out if(canUseUpdate && isUpdatable(dir.getLocal())) { changedFiles = update(false,launcher,dir,listener); if(changedFiles==null) return false; // failed } else { dir.deleteContents(); String cmd = MessageFormat.format("cvs -Q -z9 -d {0} co {1} {2} {3}", cvsroot, branch!=null?"-r "+branch:"", flatten?"-d "+dir.getName():"", module ); if(!run(launcher,cmd,listener, flatten ? dir.getParent() : dir)) return false; } // archive the workspace to support later tagging // TODO: doing this partially remotely would be faster File archiveFile = getArchiveFile(build); ZipOutputStream zos = new ZipOutputStream(archiveFile); if(flatten) { archive(build.getProject().getWorkspace().getLocal(), module, zos); } else { StringTokenizer tokens = new StringTokenizer(module); while(tokens.hasMoreTokens()) { String m = tokens.nextToken(); archive(new File(build.getProject().getWorkspace().getLocal(),m),m,zos); } } zos.close(); // contribute the tag action build.getActions().add(new TagAction(build)); if(changedFiles==null) // nothing to compare against return createEmptyChangeLog(changelogFile,listener, "changelog"); else return calcChangeLog(build, changedFiles, changelogFile, listener); }
1,116,788
public String toXML() { StringBuffer sb = new StringBuffer(); sb.append("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n"); sb.append("<STRANGEBREWRECIPE version = \"2.0A\">\n"); sb.append(" <DETAILS>\n"); sb.append(" <NAME>" + name + "</NAME>\n"); sb.append(" <NOTES>" + comments + "</NOTES>\n"); sb.append(" <EFFICIENCY>" + efficiency + "</EFFICIENCY>\n"); sb.append(" <OG>" + df3.format(estOg) + "</OG>\n"); sb.append(" <FG>" + df3.format(estFg) + "</FG>\n"); sb.append(" <STYLE>" + style.getName() + "</STYLE>\n"); sb.append(" <MASH>" + mashed + "</MASH>\n"); sb.append(" <LOV>" + df1.format(srm) + "</LOV>\n"); sb.append(" <IBU>" + df1.format(ibu) + "</IBU>\n"); sb.append(" <ALC>" + df1.format(alcohol) + "</ALC>\n"); sb.append(" <BOIL_TIME>" + boilMinutes + "</BOIL_TIME>\n"); sb.append(" <PRESIZE>" + preBoilVol.getValue() + "</PRESIZE>\n"); sb.append(" <SIZE>" + postBoilVol.getValue() + "</SIZE>\n"); sb.append(" <SIZE_UNITS>" + postBoilVol.getUnits() + "</SIZE_UNITS>\n"); sb.append(" <MALT_UNITS>" + maltUnits + "</MALT_UNITS>\n"); sb.append(" <HOPS_UNITS>" + hopUnits + "</HOPS_UNITS>\n"); sb.append(" <YEAST>" + yeast.getName() + "</YEAST>\n"); SimpleDateFormat df = new SimpleDateFormat(); sb.append(" <RECIPE_DATE>" + df.format(created.getTime()) + "</RECIPE_DATE>\n"); sb.append(" <ATTENUATION>" + attenuation + "</ATTENUATION>\n"); sb.append(" </DETAILS>\n"); // fermentables list: sb.append(" <FERMENTABLES>\n"); for (int i = 0; i < fermentables.size(); i++) { Fermentable m = (Fermentable) fermentables.get(i); sb.append(m.toXML()); } sb.append(" </FERMENTABLES>\n"); // hops list: sb.append(" <HOPS>\n"); for (int i = 0; i < hops.size(); i++) { Hop h = (Hop) hops.get(i); sb.append(h.toXML()); } sb.append(" </HOPS>\n"); // misc ingredients list: sb.append(" <MISC>\n"); for (int i = 0; i < misc.size(); i++) { Misc mi = (Misc) misc.get(i); sb.append(mi.toXML()); } sb.append(" </MISC>\n"); sb.append(mash.toXml()); sb.append("</STRANGEBREWRECIPE>"); return sb.toString(); }
public String toXML() { StringBuffer sb = new StringBuffer(); sb.append("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n"); sb.append("<STRANGEBREWRECIPE version = \"2.0A\">\n"); sb.append(" <DETAILS>\n"); sb.append(" <NAME>" + name + "</NAME>\n"); sb.append(" <NOTES>" + comments + "</NOTES>\n"); sb.append(" <EFFICIENCY>" + efficiency + "</EFFICIENCY>\n"); sb.append(" <OG>" + df3.format(estOg) + "</OG>\n"); sb.append(" <FG>" + df3.format(estFg) + "</FG>\n"); sb.append(" <STYLE>" + style.getName() + "</STYLE>\n"); sb.append(" <MASH>" + mashed + "</MASH>\n"); sb.append(" <LOV>" + df1.format(srm) + "</LOV>\n"); sb.append(" <IBU>" + df1.format(ibu) + "</IBU>\n"); sb.append(" <ALC>" + df1.format(alcohol) + "</ALC>\n"); sb.append(" <BOIL_TIME>" + boilMinutes + "</BOIL_TIME>\n"); sb.append(" <PRESIZE>" + preBoilVol.getValue() + "</PRESIZE>\n"); sb.append(" <SIZE>" + postBoilVol.getValue() + "</SIZE>\n"); sb.append(" <SIZE_UNITS>" + postBoilVol.getUnits() + "</SIZE_UNITS>\n"); sb.append(" <MALT_UNITS>" + maltUnits + "</MALT_UNITS>\n"); sb.append(" <HOPS_UNITS>" + hopUnits + "</HOPS_UNITS>\n"); sb.append(" <YEAST>" + yeast.getName() + "</YEAST>\n"); SimpleDateFormat df = new SimpleDateFormat("MM/dd/yyyy"); sb.append(" <RECIPE_DATE>" + df.format(created.getTime()) + "</RECIPE_DATE>\n"); sb.append(" <ATTENUATION>" + attenuation + "</ATTENUATION>\n"); sb.append(" </DETAILS>\n"); // fermentables list: sb.append(" <FERMENTABLES>\n"); for (int i = 0; i < fermentables.size(); i++) { Fermentable m = (Fermentable) fermentables.get(i); sb.append(m.toXML()); } sb.append(" </FERMENTABLES>\n"); // hops list: sb.append(" <HOPS>\n"); for (int i = 0; i < hops.size(); i++) { Hop h = (Hop) hops.get(i); sb.append(h.toXML()); } sb.append(" </HOPS>\n"); // misc ingredients list: sb.append(" <MISC>\n"); for (int i = 0; i < misc.size(); i++) { Misc mi = (Misc) misc.get(i); sb.append(mi.toXML()); } sb.append(" </MISC>\n"); sb.append(mash.toXml()); sb.append("</STRANGEBREWRECIPE>"); return sb.toString(); }
1,116,789
public boolean drawName(Graphics2D canvas, int xPosition, int yPosition){ if(visible){ canvas.setPaint(color); canvas.drawString(name, xPosition, yPosition); return true; } return false; }
public boolean drawName(Graphics2D canvas, int xPosition, int yPosition){ if(visible){ canvas.setPaint(color); canvas.drawString(getName(), xPosition, yPosition); return true; } return false; }
1,116,790
public String getName(){ return name; }
public String getName(){ return getSeismogram().getName(); }
1,116,791
public String toString(){ return name; }
public String toString(){ return getName(); }
1,116,792
public int countCredentialByPrincipal(String principal) { return ( (Integer) iterate(CREDENTIAL_QRY_CNT, principal).next() ).intValue(); }
public int countCredentialByPrincipal(String principal) { return find(CREDENTIAL_QRY, principal).size(); }
1,116,793
private void initGUI() { try { this.setSize(520, 532); this.addWindowListener(new WindowAdapter() { public void windowClosed(WindowEvent evt) { System.exit(1); } }); { pnlMain = new JPanel(); GridBagLayout jPanel2Layout = new GridBagLayout(); jPanel2Layout.columnWeights = new double[]{0.1}; jPanel2Layout.columnWidths = new int[]{7}; jPanel2Layout.rowWeights = new double[]{0.1, 0.1, 0.1}; jPanel2Layout.rowHeights = new int[]{7, 7, 7}; pnlMain.setLayout(jPanel2Layout); this.getContentPane().add(pnlMain, BorderLayout.CENTER); { jPanel1 = new JPanel(); pnlMain.add(jPanel1, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); FlowLayout jPanel1Layout = new FlowLayout(); jPanel1Layout.setAlignment(FlowLayout.LEFT); jPanel1.setLayout(jPanel1Layout); { lblName = new JLabel(); jPanel1.add(lblName); lblName.setText("Name:"); } { txtName = new JTextField(); jPanel1.add(txtName); txtName.setText("Name"); txtName .setPreferredSize(new java.awt.Dimension(179, 20)); txtName.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { myRecipe.setName(txtName.getText()); } }); } } { 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}; pnlDetailsLayout.columnWidths = new int[]{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); { lblBrewer = new JLabel(); pnlDetails.add(lblBrewer, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblBrewer.setText("Brewer:"); } { txtBrewer = new JTextField(); pnlDetails.add(txtBrewer, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets( 0, 0, 0, 0), 0, 0)); txtBrewer.setText("Brewer"); txtBrewer.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { myRecipe.setBrewer(txtBrewer.getText()); } }); } { 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:"); } { lblMash = new JLabel(); pnlDetails.add(lblMash, new GridBagConstraints(0, 6, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblMash.setText("Mash:"); } { lblEffic = new JLabel(); pnlDetails.add(lblEffic, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblEffic.setText("Effic:"); } { lblAtten = new JLabel(); pnlDetails.add(lblAtten, new GridBagConstraints(3, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblAtten.setText("Atten:"); } { lblOG = new JLabel(); pnlDetails.add(lblOG, new GridBagConstraints(3, 2, 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(3, 3, 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(5, 0, 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(5, 2, 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(5, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblColour.setText("Colour:"); } { txtDate = new JTextField(); pnlDetails.add(txtDate, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets( 0, 0, 0, 0), 0, 0)); txtDate.setText("Date"); } { cmbStyleModel = new ComboModel(); cmbStyle = new JComboBox(); pnlDetails.add(cmbStyle, new GridBagConstraints(1, 2, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets( 0, 0, 0, 0), 0, 0)); cmbStyle.setModel(cmbStyleModel); cmbStyle.setMaximumSize(new java.awt.Dimension(100, 32767)); cmbStyle.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { Style s = (Style) cmbStyleModel .getSelectedItem(); if (myRecipe != null && s != myRecipe.getStyleObj()) { myRecipe.setStyle(s); } } }); } { txtPreBoil = new JFormattedTextField(); pnlDetails.add(txtPreBoil, new GridBagConstraints( 1, 4, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets( 0, 0, 0, 0), 0, 0)); txtPreBoil.setText("Pre Boil"); txtPreBoil.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { myRecipe.setPreBoil(Double .parseDouble(txtPreBoil.getText() .toString())); displayRecipe(); } }); } { txtPostBoil = new JFormattedTextField(); pnlDetails.add(txtPostBoil, new GridBagConstraints( 1, 5, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets( 0, 0, 0, 0), 0, 0)); txtPostBoil.setText("Post Boil"); txtPostBoil.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { System.out .println("txtPostBoil.actionPerformed, event=" + evt); myRecipe.setPostBoil(Double .parseDouble(txtPostBoil.getText() .toString())); displayRecipe(); } }); } { lblComments = new JLabel(); pnlDetails.add(lblComments, new GridBagConstraints( 3, 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.#")); } { SpinnerNumberModel spnAttenModel = new SpinnerNumberModel( 75.0, 0.0, 100.0, 1.0); spnAtten = new JSpinner(); pnlDetails.add(spnAtten, new GridBagConstraints(4, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets( 0, 0, 0, 0), 0, 0)); spnAtten.setModel(spnAttenModel); spnAtten.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent evt) { myRecipe.setAttenuation(Double .parseDouble(spnAtten.getValue() .toString())); displayRecipe(); } }); spnAtten.setEditor(new JSpinner.NumberEditor( spnAtten, "00.#")); } { SpinnerNumberModel spnOgModel = new SpinnerNumberModel( 1.000, 0.900, 2.000, 0.001); spnOG = new JSpinner(); pnlDetails.add(spnOG, new GridBagConstraints(4, 2, 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")); } { SpinnerNumberModel spnFgModel = new SpinnerNumberModel( 1.000, 0.900, 2.000, 0.001); spnFG = new JSpinner(); pnlDetails.add(spnFG, new GridBagConstraints(4, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets( 0, 0, 0, 0), 0, 0)); spnFG.setModel(spnFgModel); spnFG.setEditor(new JSpinner.NumberEditor(spnFG, "0.000")); spnFG.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent evt) { // set the new FG, and update alc: myRecipe.setEstFg(Double.parseDouble(spnFG .getValue().toString())); displayRecipe(); } }); } { lblIBUvalue = new JLabel(); pnlDetails.add(lblIBUvalue, new GridBagConstraints( 6, 0, 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(6, 1, 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( 6, 2, 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( 3, 5, 4, 2, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); { txtComments = new JTextArea(); scpComments.setViewportView(txtComments); txtComments.setText("Comments"); txtComments.setWrapStyleWord(true); txtComments .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, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets( 0, 0, 0, 0), 0, 0)); cmbYeast.setModel(cmbYeastModel); cmbYeast.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { Yeast y = (Yeast) cmbYeastModel .getSelectedItem(); if (myRecipe!= null && y != myRecipe.getYeastObj()) { myRecipe.setYeast(y); } } }); } { ComboBoxModel cmbSizeUnitsModel = new DefaultComboBoxModel( new String[]{"Item One", "Item Two"}); cmbSizeUnits = new JComboBox(); pnlDetails.add(cmbSizeUnits, new GridBagConstraints(2, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); cmbSizeUnits.setModel(cmbSizeUnitsModel); } { lblSizeUnits = new JLabel(); pnlDetails.add(lblSizeUnits, new GridBagConstraints(2, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblSizeUnits.setText("Size Units"); } } { pnlStyle = new JPanel(); FlowLayout pnlStyleLayout = new FlowLayout(); pnlStyle.setLayout(pnlStyleLayout); jTabbedPane1.addTab("Style", null, pnlStyle, null); { lblStyle2 = new JLabel(); pnlStyle.add(lblStyle2); lblStyle2.setText("Style:"); } { ComboBoxModel cmbStyle2Model = new DefaultComboBoxModel( new String[] { "Item One", "Item Two" }); cmbStyle2 = new JComboBox(); pnlStyle.add(cmbStyle2); cmbStyle2.setModel(cmbStyle2Model); } { jPanel2 = new JPanel(); GridBagLayout jPanel2Layout1 = new GridBagLayout(); jPanel2Layout1.columnWeights = new double[] {0.1,0.1,0.1,0.1}; jPanel2Layout1.columnWidths = new int[] {7,7,7,7}; jPanel2Layout1.rowWeights = new double[] {0.1,0.1,0.1,0.1,0.1,0.1}; jPanel2Layout1.rowHeights = new int[] {7,7,7,7,7,7}; jPanel2.setPreferredSize(new java.awt.Dimension(179, 120)); jPanel2.setLayout(jPanel2Layout1); pnlStyle.add(jPanel2); jPanel2.setBorder(BorderFactory.createTitledBorder(new LineBorder(new java.awt.Color(0,0,0), 1, false), "Recipe Conformance:", TitledBorder.LEADING, TitledBorder.TOP, new java.awt.Font("Dialog",0,12), new java.awt.Color(0,0,0))); { jLabel5 = new JLabel(); jPanel2.add(jLabel5, new GridBagConstraints( 0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel5.setText("OG:"); jLabel5.setBounds(74, 3, 60, 30); } { jLabel1 = new JLabel(); jPanel2.add(jLabel1, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); GridLayout jLabel1Layout = new GridLayout(1, 1); jLabel1.setLayout(jLabel1Layout); jLabel1.setText("Low:"); } { jLabel2 = new JLabel(); jPanel2.add(jLabel2, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel2.setText("Recipe:"); } { jLabel3 = new JLabel(); jPanel2.add(jLabel3, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel3.setText("High:"); } { jLabel4 = new JLabel(); jPanel2.add(jLabel4, new GridBagConstraints( 0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel4.setText("IBU:"); } { jLabel6 = new JLabel(); jPanel2.add(jLabel6, new GridBagConstraints( 0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel6.setText("Colour:"); } { jLabel7 = new JLabel(); jPanel2.add(jLabel7, new GridBagConstraints( 0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel7.setText("ABV:"); } } { jScrollPane3 = new JScrollPane(); pnlStyle.add(jScrollPane3); { txaStyles = new JTextArea(); jScrollPane3.setViewportView(txaStyles); txaStyles.setText("Matched Styles"); } } { sldMatch = new JSlider(); pnlStyle.add(sldMatch); } } } { pnlTables = new JPanel(); BoxLayout pnlMaltsLayout = new BoxLayout(pnlTables, javax.swing.BoxLayout.Y_AXIS); pnlMain.add(pnlTables, new GridBagConstraints(0, 2, 1, 1, 0.5, 0.5, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); pnlTables.setLayout(pnlMaltsLayout); { pnlMalt = new JPanel(); pnlTables.add(pnlMalt); BorderLayout pnlMaltLayout1 = new BorderLayout(); FlowLayout pnlMaltLayout = new FlowLayout(); pnlMalt.setBorder(BorderFactory.createTitledBorder( new LineBorder(new java.awt.Color(0, 0, 0), 1, false), "Fermentables", TitledBorder.LEADING, TitledBorder.TOP, new java.awt.Font("Dialog", 1, 12), new java.awt.Color(51, 51, 51))); pnlMalt.setLayout(pnlMaltLayout1); { jScrollPane1 = new JScrollPane(); pnlMalt.add(jScrollPane1, BorderLayout.CENTER); { tblMaltModel = new MaltTableModel(this); tblMalt = new JTable(); jScrollPane1.setViewportView(tblMalt); BorderLayout tblMaltLayout = new BorderLayout(); tblMalt.setLayout(tblMaltLayout); tblMalt.setModel(tblMaltModel); // TableColumn column = null; TableColumn maltColumn = tblMalt.getColumnModel().getColumn(0); JComboBox maltComboBox = new JComboBox(); cmbMaltModel = new ComboModel(); maltComboBox.setModel(cmbMaltModel); maltColumn.setCellEditor(new DefaultCellEditor(maltComboBox)); /* for (int i = 0; i < tblMalt.getColumnCount(); i++) { column = tblMalt.getColumnModel() .getColumn(i); if (i == 0) { column.setPreferredWidth(100); } else { column.setPreferredWidth(50); } }*/ maltComboBox .addActionListener(new ActionListener() { public void actionPerformed( ActionEvent evt) { Fermentable f = (Fermentable) cmbMaltModel .getSelectedItem(); int i = tblMalt .getSelectedRow(); if (myRecipe != null) { Fermentable f2 = (Fermentable) myRecipe .getFermentablesList() .get(i); f2.setLov(f.getLov()); f2.setPppg(f.getPppg()); } } }); } } { tblMaltTotalsModel = new DefaultTableModel( new String[][]{{""}}, new String[]{"Malt", "Amount", "Units", "Points", "Lov", "Cost/U", "%"}); tblMaltTotals = new JTable(); pnlMalt.add(tblMaltTotals, BorderLayout.SOUTH); tblMaltTotals.setModel(tblMaltTotalsModel); tblMaltTotals.getTableHeader().setEnabled(false); } } { 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[]{ "Column 1", "Column 2"}); tblHopsTotals = new JTable(); pnlHops.add(tblHopsTotals, BorderLayout.SOUTH); tblHopsTotals.setModel(tblHopsTotalsModel); } { jScrollPane2 = new JScrollPane(); pnlHops.add(jScrollPane2, BorderLayout.CENTER); { tblHopsModel = new HopsTableModel(this); tblHops = new JTable(); jScrollPane2.setViewportView(tblHops); BorderLayout tblHopsLayout = new BorderLayout(); tblHops.setLayout(tblHopsLayout); tblHops.setModel(tblHopsModel); TableColumn hopColumn = tblHops.getColumnModel().getColumn(0); JComboBox hopComboBox = new JComboBox(); cmbHopsModel = new ComboModel(); hopComboBox.setModel(cmbHopsModel); hopColumn.setCellEditor(new DefaultCellEditor(hopComboBox)); } } } } } { jMenuBar1 = new JMenuBar(); setJMenuBar(jMenuBar1); { jMenu3 = new JMenu(); jMenuBar1.add(jMenu3); jMenu3.setText("File"); { newFileMenuItem = new JMenuItem(); jMenu3.add(newFileMenuItem); newFileMenuItem.setText("New"); } { openFileMenuItem = new JMenuItem(); jMenu3.add(openFileMenuItem); openFileMenuItem.setText("Open"); openFileMenuItem .addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { String path = getClass() .getProtectionDomain() .getCodeSource().getLocation() .toString().substring(6) + "\\"; JFileChooser fc = new JFileChooser(path); // Show open dialog; this method does // not return until the dialog is closed int returnVal = fc .showOpenDialog(jMenuBar1); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); System.out.print("Opening: " + file.getName() + ".\n"); ImportXml imp = new ImportXml(file .toString()); myRecipe = imp.handler.getRecipe(); myRecipe.calcMaltTotals(); myRecipe.calcHopsTotals(); myRecipe.mash .setMaltWeight(myRecipe .getTotalMashLbs()); myRecipe.mash.calcMashSchedule(); displayRecipe(); } else { System.out .print("Open command cancelled by user.\n"); } } }); } { saveMenuItem = new JMenuItem(); jMenu3.add(saveMenuItem); saveMenuItem.setText("Save"); } { saveAsMenuItem = new JMenuItem(); jMenu3.add(saveAsMenuItem); saveAsMenuItem.setText("Save As ..."); saveAsMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // This is just a test right now to see that // stuff is changed. System.out.print(myRecipe.toText()); } }); } { exportMenu = new JMenu(); jMenu3.add(exportMenu); exportMenu.setText("Export"); { exportHTMLmenu = new JMenuItem(); exportMenu.add(exportHTMLmenu); exportHTMLmenu.setText("HTML"); exportHTMLmenu .addActionListener(new ActionListener() { public void actionPerformed ( ActionEvent evt) { try{ saveAsHTML(); } catch (Exception e){ } } }); } } { closeFileMenuItem = new JMenuItem(); jMenu3.add(closeFileMenuItem); closeFileMenuItem.setText("Close"); } { jSeparator2 = new JSeparator(); jMenu3.add(jSeparator2); } { exitMenuItem = new JMenuItem(); jMenu3.add(exitMenuItem); exitMenuItem.setText("Exit"); exitMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // exit program System.exit(0); } }); } } { jMenu4 = new JMenu(); jMenuBar1.add(jMenu4); jMenu4.setText("Edit"); { cutMenuItem = new JMenuItem(); jMenu4.add(cutMenuItem); cutMenuItem.setText("Cut"); } { copyMenuItem = new JMenuItem(); jMenu4.add(copyMenuItem); copyMenuItem.setText("Copy"); } { pasteMenuItem = new JMenuItem(); jMenu4.add(pasteMenuItem); pasteMenuItem.setText("Paste"); } { jSeparator1 = new JSeparator(); jMenu4.add(jSeparator1); } { deleteMenuItem = new JMenuItem(); jMenu4.add(deleteMenuItem); deleteMenuItem.setText("Delete"); } } { jMenu5 = new JMenu(); jMenuBar1.add(jMenu5); jMenu5.setText("Help"); { helpMenuItem = new JMenuItem(); jMenu5.add(helpMenuItem); helpMenuItem.setText("Help"); } } } } catch (Exception e) { e.printStackTrace(); } }
private void initGUI() { try { this.setSize(520, 532); this.addWindowListener(new WindowAdapter() { public void windowClosed(WindowEvent evt) { System.exit(1); } }); { pnlMain = new JPanel(); GridBagLayout jPanel2Layout = new GridBagLayout(); jPanel2Layout.columnWeights = new double[]{0.1}; jPanel2Layout.columnWidths = new int[]{7}; jPanel2Layout.rowWeights = new double[]{0.1, 0.1, 0.1}; jPanel2Layout.rowHeights = new int[]{7, 7, 7}; pnlMain.setLayout(jPanel2Layout); this.getContentPane().add(pnlMain, BorderLayout.CENTER); { jPanel1 = new JPanel(); pnlMain.add(jPanel1, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); FlowLayout jPanel1Layout = new FlowLayout(); jPanel1Layout.setAlignment(FlowLayout.LEFT); jPanel1.setLayout(jPanel1Layout); { lblName = new JLabel(); jPanel1.add(lblName); lblName.setText("Name:"); } { txtName = new JTextField(); jPanel1.add(txtName); txtName.setText("Name"); txtName .setPreferredSize(new java.awt.Dimension(179, 20)); txtName.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { myRecipe.setName(txtName.getText()); } }); } } { 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}; pnlDetailsLayout.columnWidths = new int[]{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); { lblBrewer = new JLabel(); pnlDetails.add(lblBrewer, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblBrewer.setText("Brewer:"); } { txtBrewer = new JTextField(); pnlDetails.add(txtBrewer, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets( 0, 0, 0, 0), 0, 0)); txtBrewer.setText("Brewer"); txtBrewer.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { myRecipe.setBrewer(txtBrewer.getText()); } }); } { 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:"); } { lblMash = new JLabel(); pnlDetails.add(lblMash, new GridBagConstraints(0, 6, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblMash.setText("Mash:"); } { lblEffic = new JLabel(); pnlDetails.add(lblEffic, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblEffic.setText("Effic:"); } { lblAtten = new JLabel(); pnlDetails.add(lblAtten, new GridBagConstraints(3, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblAtten.setText("Atten:"); } { lblOG = new JLabel(); pnlDetails.add(lblOG, new GridBagConstraints(3, 2, 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(3, 3, 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(5, 0, 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(5, 2, 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(5, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblColour.setText("Colour:"); } { txtDate = new JTextField(); pnlDetails.add(txtDate, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets( 0, 0, 0, 0), 0, 0)); txtDate.setText("Date"); } { cmbStyleModel = new ComboModel(); cmbStyle = new JComboBox(); pnlDetails.add(cmbStyle, new GridBagConstraints(1, 2, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets( 0, 0, 0, 0), 0, 0)); cmbStyle.setModel(cmbStyleModel); cmbStyle.setMaximumSize(new java.awt.Dimension(100, 32767)); cmbStyle.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { Style s = (Style) cmbStyleModel .getSelectedItem(); if (myRecipe != null && s != myRecipe.getStyleObj()) { myRecipe.setStyle(s); } } }); } { txtPreBoil = new JFormattedTextField(); pnlDetails.add(txtPreBoil, new GridBagConstraints( 1, 4, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets( 0, 0, 0, 0), 0, 0)); txtPreBoil.setText("Pre Boil"); txtPreBoil.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { myRecipe.setPreBoil(Double .parseDouble(txtPreBoil.getText() .toString())); displayRecipe(); } }); } { txtPostBoil = new JFormattedTextField(); pnlDetails.add(txtPostBoil, new GridBagConstraints( 1, 5, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets( 0, 0, 0, 0), 0, 0)); txtPostBoil.setText("Post Boil"); txtPostBoil.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { System.out .println("txtPostBoil.actionPerformed, event=" + evt); myRecipe.setPostBoil(Double .parseDouble(txtPostBoil.getText() .toString())); displayRecipe(); } }); } { lblComments = new JLabel(); pnlDetails.add(lblComments, new GridBagConstraints( 3, 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.#")); } { SpinnerNumberModel spnAttenModel = new SpinnerNumberModel( 75.0, 0.0, 100.0, 1.0); spnAtten = new JSpinner(); pnlDetails.add(spnAtten, new GridBagConstraints(4, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets( 0, 0, 0, 0), 0, 0)); spnAtten.setModel(spnAttenModel); spnAtten.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent evt) { myRecipe.setAttenuation(Double .parseDouble(spnAtten.getValue() .toString())); displayRecipe(); } }); spnAtten.setEditor(new JSpinner.NumberEditor( spnAtten, "00.#")); } { SpinnerNumberModel spnOgModel = new SpinnerNumberModel( 1.000, 0.900, 2.000, 0.001); spnOG = new JSpinner(); pnlDetails.add(spnOG, new GridBagConstraints(4, 2, 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")); } { SpinnerNumberModel spnFgModel = new SpinnerNumberModel( 1.000, 0.900, 2.000, 0.001); spnFG = new JSpinner(); pnlDetails.add(spnFG, new GridBagConstraints(4, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets( 0, 0, 0, 0), 0, 0)); spnFG.setModel(spnFgModel); spnFG.setEditor(new JSpinner.NumberEditor(spnFG, "0.000")); spnFG.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent evt) { // set the new FG, and update alc: myRecipe.setEstFg(Double.parseDouble(spnFG .getValue().toString())); displayRecipe(); } }); } { lblIBUvalue = new JLabel(); pnlDetails.add(lblIBUvalue, new GridBagConstraints( 6, 0, 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(6, 1, 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( 6, 2, 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( 3, 5, 4, 2, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); { txtComments = new JTextArea(); scpComments.setViewportView(txtComments); txtComments.setText("Comments"); txtComments.setWrapStyleWord(true); txtComments .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, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets( 0, 0, 0, 0), 0, 0)); cmbYeast.setModel(cmbYeastModel); cmbYeast.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { Yeast y = (Yeast) cmbYeastModel .getSelectedItem(); if (myRecipe!= null && y != myRecipe.getYeastObj()) { myRecipe.setYeast(y); } } }); } { ComboBoxModel cmbSizeUnitsModel = new DefaultComboBoxModel( new String[]{"Item One", "Item Two"}); cmbSizeUnits = new JComboBox(); pnlDetails.add(cmbSizeUnits, new GridBagConstraints(2, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); cmbSizeUnits.setModel(cmbSizeUnitsModel); } { lblSizeUnits = new JLabel(); pnlDetails.add(lblSizeUnits, new GridBagConstraints(2, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblSizeUnits.setText("Size Units"); } } { pnlStyle = new JPanel(); FlowLayout pnlStyleLayout = new FlowLayout(); pnlStyle.setLayout(pnlStyleLayout); jTabbedPane1.addTab("Style", null, pnlStyle, null); { lblStyle2 = new JLabel(); pnlStyle.add(lblStyle2); lblStyle2.setText("Style:"); } { ComboBoxModel cmbStyle2Model = new DefaultComboBoxModel( new String[] { "Item One", "Item Two" }); cmbStyle2 = new JComboBox(); pnlStyle.add(cmbStyle2); cmbStyle2.setModel(cmbStyle2Model); } { jPanel2 = new JPanel(); GridBagLayout jPanel2Layout1 = new GridBagLayout(); jPanel2Layout1.columnWeights = new double[] {0.1,0.1,0.1,0.1}; jPanel2Layout1.columnWidths = new int[] {7,7,7,7}; jPanel2Layout1.rowWeights = new double[] {0.1,0.1,0.1,0.1,0.1,0.1}; jPanel2Layout1.rowHeights = new int[] {7,7,7,7,7,7}; jPanel2.setPreferredSize(new java.awt.Dimension(179, 120)); jPanel2.setLayout(jPanel2Layout1); pnlStyle.add(jPanel2); jPanel2.setBorder(BorderFactory.createTitledBorder(new LineBorder(new java.awt.Color(0,0,0), 1, false), "Recipe Conformance:", TitledBorder.LEADING, TitledBorder.TOP, new java.awt.Font("Dialog",0,12), new java.awt.Color(0,0,0))); { jLabel5 = new JLabel(); jPanel2.add(jLabel5, new GridBagConstraints( 0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel5.setText("OG:"); jLabel5.setBounds(74, 3, 60, 30); } { jLabel1 = new JLabel(); jPanel2.add(jLabel1, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); GridLayout jLabel1Layout = new GridLayout(1, 1); jLabel1.setLayout(jLabel1Layout); jLabel1.setText("Low:"); } { jLabel2 = new JLabel(); jPanel2.add(jLabel2, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel2.setText("Recipe:"); } { jLabel3 = new JLabel(); jPanel2.add(jLabel3, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel3.setText("High:"); } { jLabel4 = new JLabel(); jPanel2.add(jLabel4, new GridBagConstraints( 0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel4.setText("IBU:"); } { jLabel6 = new JLabel(); jPanel2.add(jLabel6, new GridBagConstraints( 0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel6.setText("Colour:"); } { jLabel7 = new JLabel(); jPanel2.add(jLabel7, new GridBagConstraints( 0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel7.setText("ABV:"); } } { jScrollPane3 = new JScrollPane(); pnlStyle.add(jScrollPane3); { txaStyles = new JTextArea(); jScrollPane3.setViewportView(txaStyles); txaStyles.setText("Matched Styles"); } } { sldMatch = new JSlider(); pnlStyle.add(sldMatch); } } } { pnlTables = new JPanel(); BoxLayout pnlMaltsLayout = new BoxLayout(pnlTables, javax.swing.BoxLayout.Y_AXIS); pnlMain.add(pnlTables, new GridBagConstraints(0, 2, 1, 1, 0.5, 0.5, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); pnlTables.setLayout(pnlMaltsLayout); { pnlMalt = new JPanel(); pnlTables.add(pnlMalt); BorderLayout pnlMaltLayout1 = new BorderLayout(); FlowLayout pnlMaltLayout = new FlowLayout(); pnlMalt.setBorder(BorderFactory.createTitledBorder( new LineBorder(new java.awt.Color(0, 0, 0), 1, false), "Fermentables", TitledBorder.LEADING, TitledBorder.TOP, new java.awt.Font("Dialog", 1, 12), new java.awt.Color(51, 51, 51))); pnlMalt.setLayout(pnlMaltLayout1); { jScrollPane1 = new JScrollPane(); pnlMalt.add(jScrollPane1, BorderLayout.CENTER); { tblMaltModel = new MaltTableModel(this); tblMalt = new JTable(); jScrollPane1.setViewportView(tblMalt); BorderLayout tblMaltLayout = new BorderLayout(); tblMalt.setLayout(tblMaltLayout); tblMalt.setModel(tblMaltModel); // TableColumn column = null; TableColumn maltColumn = tblMalt.getColumnModel().getColumn(0); JComboBox maltComboBox = new JComboBox(); cmbMaltModel = new ComboModel(); maltComboBox.setModel(cmbMaltModel); maltColumn.setCellEditor(new DefaultCellEditor(maltComboBox)); /* for (int i = 0; i < tblMalt.getColumnCount(); i++) { column = tblMalt.getColumnModel() .getColumn(i); if (i == 0) { column.setPreferredWidth(100); } else { column.setPreferredWidth(50); } }*/ maltComboBox .addActionListener(new ActionListener() { public void actionPerformed( ActionEvent evt) { Fermentable f = (Fermentable) cmbMaltModel .getSelectedItem(); int i = tblMalt .getSelectedRow(); if (myRecipe != null) { Fermentable f2 = (Fermentable) myRecipe .getFermentablesList() .get(i); f2.setLov(f.getLov()); f2.setPppg(f.getPppg()); } } }); } } { tblMaltTotalsModel = new DefaultTableModel( new String[][]{{""}}, new String[]{"Malt", "Amount", "Units", "Points", "Lov", "Cost/U", "%"}); tblMaltTotals = new JTable(); pnlMalt.add(tblMaltTotals, BorderLayout.SOUTH); tblMaltTotals.setModel(tblMaltTotalsModel); tblMaltTotals.getTableHeader().setEnabled(false); } } { 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[]{ "Column 1", "Column 2"}); tblHopsTotals = new JTable(); pnlHops.add(tblHopsTotals, BorderLayout.SOUTH); tblHopsTotals.setModel(tblHopsTotalsModel); } { jScrollPane2 = new JScrollPane(); pnlHops.add(jScrollPane2, BorderLayout.CENTER); { tblHopsModel = new HopsTableModel(this); tblHops = new JTable(); jScrollPane2.setViewportView(tblHops); BorderLayout tblHopsLayout = new BorderLayout(); tblHops.setLayout(tblHopsLayout); tblHops.setModel(tblHopsModel); TableColumn hopColumn = tblHops.getColumnModel().getColumn(0); JComboBox hopComboBox = new JComboBox(); cmbHopsModel = new ComboModel(); hopComboBox.setModel(cmbHopsModel); hopColumn.setCellEditor(new DefaultCellEditor(hopComboBox)); } } } } } { jMenuBar1 = new JMenuBar(); setJMenuBar(jMenuBar1); { jMenu3 = new JMenu(); jMenuBar1.add(jMenu3); jMenu3.setText("File"); { newFileMenuItem = new JMenuItem(); jMenu3.add(newFileMenuItem); newFileMenuItem.setText("New"); } { openFileMenuItem = new JMenuItem(); jMenu3.add(openFileMenuItem); openFileMenuItem.setText("Open"); openFileMenuItem .addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { String path = getClass() .getProtectionDomain() .getCodeSource().getLocation() .toString().substring(6) + "\\"; JFileChooser fc = new JFileChooser(path); // Show open dialog; this method does // not return until the dialog is closed int returnVal = fc .showOpenDialog(jMenuBar1); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); System.out.print("Opening: " + file.getName() + ".\n"); ImportXml imp = new ImportXml(file .toString()); myRecipe = imp.handler.getRecipe(); myRecipe.calcMaltTotals(); myRecipe.calcHopsTotals(); myRecipe.mash .setMaltWeight(myRecipe .getTotalMashLbs()); myRecipe.mash.calcMashSchedule(); displayRecipe(); } else { System.out .print("Open command cancelled by user.\n"); } } }); } { saveMenuItem = new JMenuItem(); jMenu3.add(saveMenuItem); saveMenuItem.setText("Save"); } { saveAsMenuItem = new JMenuItem(); jMenu3.add(saveAsMenuItem); saveAsMenuItem.setText("Save As ..."); saveAsMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // This is just a test right now to see that // stuff is changed. System.out.print(myRecipe.toText()); } }); } { exportMenu = new JMenu(); jMenu3.add(exportMenu); exportMenu.setText("Export"); { exportHTMLmenu = new JMenuItem(); exportMenu.add(exportHTMLmenu); exportHTMLmenu.setText("HTML"); exportHTMLmenu .addActionListener(new ActionListener() { public void actionPerformed ( ActionEvent evt) { try{ saveAsHTML(); } catch (Exception e){ } } }); } } { closeFileMenuItem = new JMenuItem(); jMenu3.add(closeFileMenuItem); closeFileMenuItem.setText("Close"); } { jSeparator2 = new JSeparator(); jMenu3.add(jSeparator2); } { exitMenuItem = new JMenuItem(); jMenu3.add(exitMenuItem); exitMenuItem.setText("Exit"); exitMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // exit program System.exit(0); } }); } } { jMenu4 = new JMenu(); jMenuBar1.add(jMenu4); jMenu4.setText("Edit"); { cutMenuItem = new JMenuItem(); jMenu4.add(cutMenuItem); cutMenuItem.setText("Cut"); } { copyMenuItem = new JMenuItem(); jMenu4.add(copyMenuItem); copyMenuItem.setText("Copy"); } { pasteMenuItem = new JMenuItem(); jMenu4.add(pasteMenuItem); pasteMenuItem.setText("Paste"); } { jSeparator1 = new JSeparator(); jMenu4.add(jSeparator1); } { deleteMenuItem = new JMenuItem(); jMenu4.add(deleteMenuItem); deleteMenuItem.setText("Delete"); } } { jMenu5 = new JMenu(); jMenuBar1.add(jMenu5); jMenu5.setText("Help"); { helpMenuItem = new JMenuItem(); jMenu5.add(helpMenuItem); helpMenuItem.setText("Help"); } } } } catch (Exception e) { e.printStackTrace(); } }
1,116,795
private void initGUI() { try { this.setSize(520, 532); this.addWindowListener(new WindowAdapter() { public void windowClosed(WindowEvent evt) { System.exit(1); } }); { pnlMain = new JPanel(); GridBagLayout jPanel2Layout = new GridBagLayout(); jPanel2Layout.columnWeights = new double[]{0.1}; jPanel2Layout.columnWidths = new int[]{7}; jPanel2Layout.rowWeights = new double[]{0.1, 0.1, 0.1}; jPanel2Layout.rowHeights = new int[]{7, 7, 7}; pnlMain.setLayout(jPanel2Layout); this.getContentPane().add(pnlMain, BorderLayout.CENTER); { jPanel1 = new JPanel(); pnlMain.add(jPanel1, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); FlowLayout jPanel1Layout = new FlowLayout(); jPanel1Layout.setAlignment(FlowLayout.LEFT); jPanel1.setLayout(jPanel1Layout); { lblName = new JLabel(); jPanel1.add(lblName); lblName.setText("Name:"); } { txtName = new JTextField(); jPanel1.add(txtName); txtName.setText("Name"); txtName .setPreferredSize(new java.awt.Dimension(179, 20)); txtName.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { myRecipe.setName(txtName.getText()); } }); } } { 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}; pnlDetailsLayout.columnWidths = new int[]{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); { lblBrewer = new JLabel(); pnlDetails.add(lblBrewer, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblBrewer.setText("Brewer:"); } { txtBrewer = new JTextField(); pnlDetails.add(txtBrewer, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets( 0, 0, 0, 0), 0, 0)); txtBrewer.setText("Brewer"); txtBrewer.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { myRecipe.setBrewer(txtBrewer.getText()); } }); } { 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:"); } { lblMash = new JLabel(); pnlDetails.add(lblMash, new GridBagConstraints(0, 6, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblMash.setText("Mash:"); } { lblEffic = new JLabel(); pnlDetails.add(lblEffic, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblEffic.setText("Effic:"); } { lblAtten = new JLabel(); pnlDetails.add(lblAtten, new GridBagConstraints(3, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblAtten.setText("Atten:"); } { lblOG = new JLabel(); pnlDetails.add(lblOG, new GridBagConstraints(3, 2, 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(3, 3, 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(5, 0, 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(5, 2, 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(5, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblColour.setText("Colour:"); } { txtDate = new JTextField(); pnlDetails.add(txtDate, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets( 0, 0, 0, 0), 0, 0)); txtDate.setText("Date"); } { cmbStyleModel = new ComboModel(); cmbStyle = new JComboBox(); pnlDetails.add(cmbStyle, new GridBagConstraints(1, 2, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets( 0, 0, 0, 0), 0, 0)); cmbStyle.setModel(cmbStyleModel); cmbStyle.setMaximumSize(new java.awt.Dimension(100, 32767)); cmbStyle.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { Style s = (Style) cmbStyleModel .getSelectedItem(); if (myRecipe != null && s != myRecipe.getStyleObj()) { myRecipe.setStyle(s); } } }); } { txtPreBoil = new JFormattedTextField(); pnlDetails.add(txtPreBoil, new GridBagConstraints( 1, 4, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets( 0, 0, 0, 0), 0, 0)); txtPreBoil.setText("Pre Boil"); txtPreBoil.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { myRecipe.setPreBoil(Double .parseDouble(txtPreBoil.getText() .toString())); displayRecipe(); } }); } { txtPostBoil = new JFormattedTextField(); pnlDetails.add(txtPostBoil, new GridBagConstraints( 1, 5, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets( 0, 0, 0, 0), 0, 0)); txtPostBoil.setText("Post Boil"); txtPostBoil.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { System.out .println("txtPostBoil.actionPerformed, event=" + evt); myRecipe.setPostBoil(Double .parseDouble(txtPostBoil.getText() .toString())); displayRecipe(); } }); } { lblComments = new JLabel(); pnlDetails.add(lblComments, new GridBagConstraints( 3, 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.#")); } { SpinnerNumberModel spnAttenModel = new SpinnerNumberModel( 75.0, 0.0, 100.0, 1.0); spnAtten = new JSpinner(); pnlDetails.add(spnAtten, new GridBagConstraints(4, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets( 0, 0, 0, 0), 0, 0)); spnAtten.setModel(spnAttenModel); spnAtten.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent evt) { myRecipe.setAttenuation(Double .parseDouble(spnAtten.getValue() .toString())); displayRecipe(); } }); spnAtten.setEditor(new JSpinner.NumberEditor( spnAtten, "00.#")); } { SpinnerNumberModel spnOgModel = new SpinnerNumberModel( 1.000, 0.900, 2.000, 0.001); spnOG = new JSpinner(); pnlDetails.add(spnOG, new GridBagConstraints(4, 2, 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")); } { SpinnerNumberModel spnFgModel = new SpinnerNumberModel( 1.000, 0.900, 2.000, 0.001); spnFG = new JSpinner(); pnlDetails.add(spnFG, new GridBagConstraints(4, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets( 0, 0, 0, 0), 0, 0)); spnFG.setModel(spnFgModel); spnFG.setEditor(new JSpinner.NumberEditor(spnFG, "0.000")); spnFG.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent evt) { // set the new FG, and update alc: myRecipe.setEstFg(Double.parseDouble(spnFG .getValue().toString())); displayRecipe(); } }); } { lblIBUvalue = new JLabel(); pnlDetails.add(lblIBUvalue, new GridBagConstraints( 6, 0, 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(6, 1, 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( 6, 2, 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( 3, 5, 4, 2, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); { txtComments = new JTextArea(); scpComments.setViewportView(txtComments); txtComments.setText("Comments"); txtComments.setWrapStyleWord(true); txtComments .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, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets( 0, 0, 0, 0), 0, 0)); cmbYeast.setModel(cmbYeastModel); cmbYeast.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { Yeast y = (Yeast) cmbYeastModel .getSelectedItem(); if (myRecipe!= null && y != myRecipe.getYeastObj()) { myRecipe.setYeast(y); } } }); } { ComboBoxModel cmbSizeUnitsModel = new DefaultComboBoxModel( new String[]{"Item One", "Item Two"}); cmbSizeUnits = new JComboBox(); pnlDetails.add(cmbSizeUnits, new GridBagConstraints(2, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); cmbSizeUnits.setModel(cmbSizeUnitsModel); } { lblSizeUnits = new JLabel(); pnlDetails.add(lblSizeUnits, new GridBagConstraints(2, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblSizeUnits.setText("Size Units"); } } { pnlStyle = new JPanel(); FlowLayout pnlStyleLayout = new FlowLayout(); pnlStyle.setLayout(pnlStyleLayout); jTabbedPane1.addTab("Style", null, pnlStyle, null); { lblStyle2 = new JLabel(); pnlStyle.add(lblStyle2); lblStyle2.setText("Style:"); } { ComboBoxModel cmbStyle2Model = new DefaultComboBoxModel( new String[] { "Item One", "Item Two" }); cmbStyle2 = new JComboBox(); pnlStyle.add(cmbStyle2); cmbStyle2.setModel(cmbStyle2Model); } { jPanel2 = new JPanel(); GridBagLayout jPanel2Layout1 = new GridBagLayout(); jPanel2Layout1.columnWeights = new double[] {0.1,0.1,0.1,0.1}; jPanel2Layout1.columnWidths = new int[] {7,7,7,7}; jPanel2Layout1.rowWeights = new double[] {0.1,0.1,0.1,0.1,0.1,0.1}; jPanel2Layout1.rowHeights = new int[] {7,7,7,7,7,7}; jPanel2.setPreferredSize(new java.awt.Dimension(179, 120)); jPanel2.setLayout(jPanel2Layout1); pnlStyle.add(jPanel2); jPanel2.setBorder(BorderFactory.createTitledBorder(new LineBorder(new java.awt.Color(0,0,0), 1, false), "Recipe Conformance:", TitledBorder.LEADING, TitledBorder.TOP, new java.awt.Font("Dialog",0,12), new java.awt.Color(0,0,0))); { jLabel5 = new JLabel(); jPanel2.add(jLabel5, new GridBagConstraints( 0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel5.setText("OG:"); jLabel5.setBounds(74, 3, 60, 30); } { jLabel1 = new JLabel(); jPanel2.add(jLabel1, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); GridLayout jLabel1Layout = new GridLayout(1, 1); jLabel1.setLayout(jLabel1Layout); jLabel1.setText("Low:"); } { jLabel2 = new JLabel(); jPanel2.add(jLabel2, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel2.setText("Recipe:"); } { jLabel3 = new JLabel(); jPanel2.add(jLabel3, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel3.setText("High:"); } { jLabel4 = new JLabel(); jPanel2.add(jLabel4, new GridBagConstraints( 0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel4.setText("IBU:"); } { jLabel6 = new JLabel(); jPanel2.add(jLabel6, new GridBagConstraints( 0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel6.setText("Colour:"); } { jLabel7 = new JLabel(); jPanel2.add(jLabel7, new GridBagConstraints( 0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel7.setText("ABV:"); } } { jScrollPane3 = new JScrollPane(); pnlStyle.add(jScrollPane3); { txaStyles = new JTextArea(); jScrollPane3.setViewportView(txaStyles); txaStyles.setText("Matched Styles"); } } { sldMatch = new JSlider(); pnlStyle.add(sldMatch); } } } { pnlTables = new JPanel(); BoxLayout pnlMaltsLayout = new BoxLayout(pnlTables, javax.swing.BoxLayout.Y_AXIS); pnlMain.add(pnlTables, new GridBagConstraints(0, 2, 1, 1, 0.5, 0.5, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); pnlTables.setLayout(pnlMaltsLayout); { pnlMalt = new JPanel(); pnlTables.add(pnlMalt); BorderLayout pnlMaltLayout1 = new BorderLayout(); FlowLayout pnlMaltLayout = new FlowLayout(); pnlMalt.setBorder(BorderFactory.createTitledBorder( new LineBorder(new java.awt.Color(0, 0, 0), 1, false), "Fermentables", TitledBorder.LEADING, TitledBorder.TOP, new java.awt.Font("Dialog", 1, 12), new java.awt.Color(51, 51, 51))); pnlMalt.setLayout(pnlMaltLayout1); { jScrollPane1 = new JScrollPane(); pnlMalt.add(jScrollPane1, BorderLayout.CENTER); { tblMaltModel = new MaltTableModel(this); tblMalt = new JTable(); jScrollPane1.setViewportView(tblMalt); BorderLayout tblMaltLayout = new BorderLayout(); tblMalt.setLayout(tblMaltLayout); tblMalt.setModel(tblMaltModel); // TableColumn column = null; TableColumn maltColumn = tblMalt.getColumnModel().getColumn(0); JComboBox maltComboBox = new JComboBox(); cmbMaltModel = new ComboModel(); maltComboBox.setModel(cmbMaltModel); maltColumn.setCellEditor(new DefaultCellEditor(maltComboBox)); /* for (int i = 0; i < tblMalt.getColumnCount(); i++) { column = tblMalt.getColumnModel() .getColumn(i); if (i == 0) { column.setPreferredWidth(100); } else { column.setPreferredWidth(50); } }*/ maltComboBox .addActionListener(new ActionListener() { public void actionPerformed( ActionEvent evt) { Fermentable f = (Fermentable) cmbMaltModel .getSelectedItem(); int i = tblMalt .getSelectedRow(); if (myRecipe != null) { Fermentable f2 = (Fermentable) myRecipe .getFermentablesList() .get(i); f2.setLov(f.getLov()); f2.setPppg(f.getPppg()); } } }); } } { tblMaltTotalsModel = new DefaultTableModel( new String[][]{{""}}, new String[]{"Malt", "Amount", "Units", "Points", "Lov", "Cost/U", "%"}); tblMaltTotals = new JTable(); pnlMalt.add(tblMaltTotals, BorderLayout.SOUTH); tblMaltTotals.setModel(tblMaltTotalsModel); tblMaltTotals.getTableHeader().setEnabled(false); } } { 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[]{ "Column 1", "Column 2"}); tblHopsTotals = new JTable(); pnlHops.add(tblHopsTotals, BorderLayout.SOUTH); tblHopsTotals.setModel(tblHopsTotalsModel); } { jScrollPane2 = new JScrollPane(); pnlHops.add(jScrollPane2, BorderLayout.CENTER); { tblHopsModel = new HopsTableModel(this); tblHops = new JTable(); jScrollPane2.setViewportView(tblHops); BorderLayout tblHopsLayout = new BorderLayout(); tblHops.setLayout(tblHopsLayout); tblHops.setModel(tblHopsModel); TableColumn hopColumn = tblHops.getColumnModel().getColumn(0); JComboBox hopComboBox = new JComboBox(); cmbHopsModel = new ComboModel(); hopComboBox.setModel(cmbHopsModel); hopColumn.setCellEditor(new DefaultCellEditor(hopComboBox)); } } } } } { jMenuBar1 = new JMenuBar(); setJMenuBar(jMenuBar1); { jMenu3 = new JMenu(); jMenuBar1.add(jMenu3); jMenu3.setText("File"); { newFileMenuItem = new JMenuItem(); jMenu3.add(newFileMenuItem); newFileMenuItem.setText("New"); } { openFileMenuItem = new JMenuItem(); jMenu3.add(openFileMenuItem); openFileMenuItem.setText("Open"); openFileMenuItem .addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { String path = getClass() .getProtectionDomain() .getCodeSource().getLocation() .toString().substring(6) + "\\"; JFileChooser fc = new JFileChooser(path); // Show open dialog; this method does // not return until the dialog is closed int returnVal = fc .showOpenDialog(jMenuBar1); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); System.out.print("Opening: " + file.getName() + ".\n"); ImportXml imp = new ImportXml(file .toString()); myRecipe = imp.handler.getRecipe(); myRecipe.calcMaltTotals(); myRecipe.calcHopsTotals(); myRecipe.mash .setMaltWeight(myRecipe .getTotalMashLbs()); myRecipe.mash.calcMashSchedule(); displayRecipe(); } else { System.out .print("Open command cancelled by user.\n"); } } }); } { saveMenuItem = new JMenuItem(); jMenu3.add(saveMenuItem); saveMenuItem.setText("Save"); } { saveAsMenuItem = new JMenuItem(); jMenu3.add(saveAsMenuItem); saveAsMenuItem.setText("Save As ..."); saveAsMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // This is just a test right now to see that // stuff is changed. System.out.print(myRecipe.toText()); } }); } { exportMenu = new JMenu(); jMenu3.add(exportMenu); exportMenu.setText("Export"); { exportHTMLmenu = new JMenuItem(); exportMenu.add(exportHTMLmenu); exportHTMLmenu.setText("HTML"); exportHTMLmenu .addActionListener(new ActionListener() { public void actionPerformed ( ActionEvent evt) { try{ saveAsHTML(); } catch (Exception e){ } } }); } } { closeFileMenuItem = new JMenuItem(); jMenu3.add(closeFileMenuItem); closeFileMenuItem.setText("Close"); } { jSeparator2 = new JSeparator(); jMenu3.add(jSeparator2); } { exitMenuItem = new JMenuItem(); jMenu3.add(exitMenuItem); exitMenuItem.setText("Exit"); exitMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // exit program System.exit(0); } }); } } { jMenu4 = new JMenu(); jMenuBar1.add(jMenu4); jMenu4.setText("Edit"); { cutMenuItem = new JMenuItem(); jMenu4.add(cutMenuItem); cutMenuItem.setText("Cut"); } { copyMenuItem = new JMenuItem(); jMenu4.add(copyMenuItem); copyMenuItem.setText("Copy"); } { pasteMenuItem = new JMenuItem(); jMenu4.add(pasteMenuItem); pasteMenuItem.setText("Paste"); } { jSeparator1 = new JSeparator(); jMenu4.add(jSeparator1); } { deleteMenuItem = new JMenuItem(); jMenu4.add(deleteMenuItem); deleteMenuItem.setText("Delete"); } } { jMenu5 = new JMenu(); jMenuBar1.add(jMenu5); jMenu5.setText("Help"); { helpMenuItem = new JMenuItem(); jMenu5.add(helpMenuItem); helpMenuItem.setText("Help"); } } } } catch (Exception e) { e.printStackTrace(); } }
private void initGUI() { try { this.setSize(520, 532); this.addWindowListener(new WindowAdapter() { public void windowClosed(WindowEvent evt) { System.exit(1); } }); { pnlMain = new JPanel(); GridBagLayout jPanel2Layout = new GridBagLayout(); jPanel2Layout.columnWeights = new double[]{0.1}; jPanel2Layout.columnWidths = new int[]{7}; jPanel2Layout.rowWeights = new double[]{0.1, 0.1, 0.1}; jPanel2Layout.rowHeights = new int[]{7, 7, 7}; pnlMain.setLayout(jPanel2Layout); this.getContentPane().add(pnlMain, BorderLayout.CENTER); { jPanel1 = new JPanel(); pnlMain.add(jPanel1, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); FlowLayout jPanel1Layout = new FlowLayout(); jPanel1Layout.setAlignment(FlowLayout.LEFT); jPanel1.setLayout(jPanel1Layout); { lblName = new JLabel(); jPanel1.add(lblName); lblName.setText("Name:"); } { txtName = new JTextField(); jPanel1.add(txtName); txtName.setText("Name"); txtName .setPreferredSize(new java.awt.Dimension(179, 20)); txtName.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { myRecipe.setName(txtName.getText()); } }); } } { 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}; pnlDetailsLayout.columnWidths = new int[]{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); { lblBrewer = new JLabel(); pnlDetails.add(lblBrewer, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblBrewer.setText("Brewer:"); } { txtBrewer = new JTextField(); pnlDetails.add(txtBrewer, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets( 0, 0, 0, 0), 0, 0)); txtBrewer.setText("Brewer"); txtBrewer.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { myRecipe.setBrewer(txtBrewer.getText()); } }); } { 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:"); } { lblMash = new JLabel(); pnlDetails.add(lblMash, new GridBagConstraints(0, 6, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblMash.setText("Mash:"); } { lblEffic = new JLabel(); pnlDetails.add(lblEffic, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblEffic.setText("Effic:"); } { lblAtten = new JLabel(); pnlDetails.add(lblAtten, new GridBagConstraints(3, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblAtten.setText("Atten:"); } { lblOG = new JLabel(); pnlDetails.add(lblOG, new GridBagConstraints(3, 2, 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(3, 3, 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(5, 0, 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(5, 2, 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(5, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblColour.setText("Colour:"); } { txtDate = new JTextField(); pnlDetails.add(txtDate, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets( 0, 0, 0, 0), 0, 0)); txtDate.setText("Date"); } { cmbStyleModel = new ComboModel(); cmbStyle = new JComboBox(); pnlDetails.add(cmbStyle, new GridBagConstraints(1, 2, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets( 0, 0, 0, 0), 0, 0)); cmbStyle.setModel(cmbStyleModel); cmbStyle.setMaximumSize(new java.awt.Dimension(100, 32767)); cmbStyle.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { Style s = (Style) cmbStyleModel .getSelectedItem(); if (myRecipe != null && s != myRecipe.getStyleObj()) { myRecipe.setStyle(s); } } }); } { txtPreBoil = new JFormattedTextField(); pnlDetails.add(txtPreBoil, new GridBagConstraints( 1, 4, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets( 0, 0, 0, 0), 0, 0)); txtPreBoil.setText("Pre Boil"); txtPreBoil.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { myRecipe.setPreBoil(Double .parseDouble(txtPreBoil.getText() .toString())); displayRecipe(); } }); } { txtPostBoil = new JFormattedTextField(); pnlDetails.add(txtPostBoil, new GridBagConstraints( 1, 5, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets( 0, 0, 0, 0), 0, 0)); txtPostBoil.setText("Post Boil"); txtPostBoil.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { System.out .println("txtPostBoil.actionPerformed, event=" + evt); myRecipe.setPostBoil(Double .parseDouble(txtPostBoil.getText() .toString())); displayRecipe(); } }); } { lblComments = new JLabel(); pnlDetails.add(lblComments, new GridBagConstraints( 3, 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.#")); } { SpinnerNumberModel spnAttenModel = new SpinnerNumberModel( 75.0, 0.0, 100.0, 1.0); spnAtten = new JSpinner(); pnlDetails.add(spnAtten, new GridBagConstraints(4, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets( 0, 0, 0, 0), 0, 0)); spnAtten.setModel(spnAttenModel); spnAtten.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent evt) { myRecipe.setAttenuation(Double .parseDouble(spnAtten.getValue() .toString())); displayRecipe(); } }); spnAtten.setEditor(new JSpinner.NumberEditor( spnAtten, "00.#")); } { SpinnerNumberModel spnOgModel = new SpinnerNumberModel( 1.000, 0.900, 2.000, 0.001); spnOG = new JSpinner(); pnlDetails.add(spnOG, new GridBagConstraints(4, 2, 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")); } { SpinnerNumberModel spnFgModel = new SpinnerNumberModel( 1.000, 0.900, 2.000, 0.001); spnFG = new JSpinner(); pnlDetails.add(spnFG, new GridBagConstraints(4, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets( 0, 0, 0, 0), 0, 0)); spnFG.setModel(spnFgModel); spnFG.setEditor(new JSpinner.NumberEditor(spnFG, "0.000")); spnFG.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent evt) { // set the new FG, and update alc: myRecipe.setEstFg(Double.parseDouble(spnFG .getValue().toString())); displayRecipe(); } }); } { lblIBUvalue = new JLabel(); pnlDetails.add(lblIBUvalue, new GridBagConstraints( 6, 0, 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(6, 1, 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( 6, 2, 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( 3, 5, 4, 2, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); { txtComments = new JTextArea(); scpComments.setViewportView(txtComments); txtComments.setText("Comments"); txtComments.setWrapStyleWord(true); txtComments .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, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets( 0, 0, 0, 0), 0, 0)); cmbYeast.setModel(cmbYeastModel); cmbYeast.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { Yeast y = (Yeast) cmbYeastModel .getSelectedItem(); if (myRecipe!= null && y != myRecipe.getYeastObj()) { myRecipe.setYeast(y); } } }); } { ComboBoxModel cmbSizeUnitsModel = new DefaultComboBoxModel( new String[]{"Item One", "Item Two"}); cmbSizeUnits = new JComboBox(); pnlDetails.add(cmbSizeUnits, new GridBagConstraints(2, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); cmbSizeUnits.setModel(cmbSizeUnitsModel); } { lblSizeUnits = new JLabel(); pnlDetails.add(lblSizeUnits, new GridBagConstraints(2, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblSizeUnits.setText("Size Units"); } } { pnlStyle = new JPanel(); FlowLayout pnlStyleLayout = new FlowLayout(); pnlStyle.setLayout(pnlStyleLayout); jTabbedPane1.addTab("Style", null, pnlStyle, null); { lblStyle2 = new JLabel(); pnlStyle.add(lblStyle2); lblStyle2.setText("Style:"); } { ComboBoxModel cmbStyle2Model = new DefaultComboBoxModel( new String[] { "Item One", "Item Two" }); cmbStyle2 = new JComboBox(); pnlStyle.add(cmbStyle2); cmbStyle2.setModel(cmbStyle2Model); } { jPanel2 = new JPanel(); GridBagLayout jPanel2Layout1 = new GridBagLayout(); jPanel2Layout1.columnWeights = new double[] {0.1,0.1,0.1,0.1}; jPanel2Layout1.columnWidths = new int[] {7,7,7,7}; jPanel2Layout1.rowWeights = new double[] {0.1,0.1,0.1,0.1,0.1,0.1}; jPanel2Layout1.rowHeights = new int[] {7,7,7,7,7,7}; jPanel2.setPreferredSize(new java.awt.Dimension(179, 120)); jPanel2.setLayout(jPanel2Layout1); pnlStyle.add(jPanel2); jPanel2.setBorder(BorderFactory.createTitledBorder(new LineBorder(new java.awt.Color(0,0,0), 1, false), "Recipe Conformance:", TitledBorder.LEADING, TitledBorder.TOP, new java.awt.Font("Dialog",0,12), new java.awt.Color(0,0,0))); { jLabel5 = new JLabel(); jPanel2.add(jLabel5, new GridBagConstraints( 0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel5.setText("OG:"); jLabel5.setBounds(74, 3, 60, 30); } { jLabel1 = new JLabel(); jPanel2.add(jLabel1, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); GridLayout jLabel1Layout = new GridLayout(1, 1); jLabel1.setLayout(jLabel1Layout); jLabel1.setText("Low:"); } { jLabel2 = new JLabel(); jPanel2.add(jLabel2, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel2.setText("Recipe:"); } { jLabel3 = new JLabel(); jPanel2.add(jLabel3, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel3.setText("High:"); } { jLabel4 = new JLabel(); jPanel2.add(jLabel4, new GridBagConstraints( 0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel4.setText("IBU:"); } { jLabel6 = new JLabel(); jPanel2.add(jLabel6, new GridBagConstraints( 0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel6.setText("Colour:"); } { jLabel7 = new JLabel(); jPanel2.add(jLabel7, new GridBagConstraints( 0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel7.setText("ABV:"); } } { jScrollPane3 = new JScrollPane(); pnlStyle.add(jScrollPane3); { txaStyles = new JTextArea(); jScrollPane3.setViewportView(txaStyles); txaStyles.setText("Matched Styles"); } } { sldMatch = new JSlider(); pnlStyle.add(sldMatch); } } } { pnlTables = new JPanel(); BoxLayout pnlMaltsLayout = new BoxLayout(pnlTables, javax.swing.BoxLayout.Y_AXIS); pnlMain.add(pnlTables, new GridBagConstraints(0, 2, 1, 1, 0.5, 0.5, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); pnlTables.setLayout(pnlMaltsLayout); { pnlMalt = new JPanel(); pnlTables.add(pnlMalt); BorderLayout pnlMaltLayout1 = new BorderLayout(); FlowLayout pnlMaltLayout = new FlowLayout(); pnlMalt.setBorder(BorderFactory.createTitledBorder( new LineBorder(new java.awt.Color(0, 0, 0), 1, false), "Fermentables", TitledBorder.LEADING, TitledBorder.TOP, new java.awt.Font("Dialog", 1, 12), new java.awt.Color(51, 51, 51))); pnlMalt.setLayout(pnlMaltLayout1); { jScrollPane1 = new JScrollPane(); pnlMalt.add(jScrollPane1, BorderLayout.CENTER); { tblMaltModel = new MaltTableModel(this); tblMalt = new JTable(); jScrollPane1.setViewportView(tblMalt); BorderLayout tblMaltLayout = new BorderLayout(); tblMalt.setLayout(tblMaltLayout); tblMalt.setModel(tblMaltModel); // TableColumn column = null; TableColumn maltColumn = tblMalt.getColumnModel().getColumn(0); JComboBox maltComboBox = new JComboBox(); cmbMaltModel = new ComboModel(); maltComboBox.setModel(cmbMaltModel); maltColumn.setCellEditor(new DefaultCellEditor(maltComboBox)); for (int i = 0; i < tblMalt.getColumnCount(); i++) { column = tblMalt.getColumnModel() .getColumn(i); if (i == 0) { column.setPreferredWidth(100); } else { column.setPreferredWidth(50); } }*/ maltComboBox .addActionListener(new ActionListener() { public void actionPerformed( ActionEvent evt) { Fermentable f = (Fermentable) cmbMaltModel .getSelectedItem(); int i = tblMalt .getSelectedRow(); if (myRecipe != null) { Fermentable f2 = (Fermentable) myRecipe .getFermentablesList() .get(i); f2.setLov(f.getLov()); f2.setPppg(f.getPppg()); } } }); } } { tblMaltTotalsModel = new DefaultTableModel( new String[][]{{""}}, new String[]{"Malt", "Amount", "Units", "Points", "Lov", "Cost/U", "%"}); tblMaltTotals = new JTable(); pnlMalt.add(tblMaltTotals, BorderLayout.SOUTH); tblMaltTotals.setModel(tblMaltTotalsModel); tblMaltTotals.getTableHeader().setEnabled(false); } } { 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[]{ "Column 1", "Column 2"}); tblHopsTotals = new JTable(); pnlHops.add(tblHopsTotals, BorderLayout.SOUTH); tblHopsTotals.setModel(tblHopsTotalsModel); } { jScrollPane2 = new JScrollPane(); pnlHops.add(jScrollPane2, BorderLayout.CENTER); { tblHopsModel = new HopsTableModel(this); tblHops = new JTable(); jScrollPane2.setViewportView(tblHops); BorderLayout tblHopsLayout = new BorderLayout(); tblHops.setLayout(tblHopsLayout); tblHops.setModel(tblHopsModel); TableColumn hopColumn = tblHops.getColumnModel().getColumn(0); JComboBox hopComboBox = new JComboBox(); cmbHopsModel = new ComboModel(); hopComboBox.setModel(cmbHopsModel); hopColumn.setCellEditor(new DefaultCellEditor(hopComboBox)); } } } } } { jMenuBar1 = new JMenuBar(); setJMenuBar(jMenuBar1); { jMenu3 = new JMenu(); jMenuBar1.add(jMenu3); jMenu3.setText("File"); { newFileMenuItem = new JMenuItem(); jMenu3.add(newFileMenuItem); newFileMenuItem.setText("New"); } { openFileMenuItem = new JMenuItem(); jMenu3.add(openFileMenuItem); openFileMenuItem.setText("Open"); openFileMenuItem .addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { String path = getClass() .getProtectionDomain() .getCodeSource().getLocation() .toString().substring(6) + "\\"; JFileChooser fc = new JFileChooser(path); // Show open dialog; this method does // not return until the dialog is closed int returnVal = fc .showOpenDialog(jMenuBar1); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); System.out.print("Opening: " + file.getName() + ".\n"); ImportXml imp = new ImportXml(file .toString()); myRecipe = imp.handler.getRecipe(); myRecipe.calcMaltTotals(); myRecipe.calcHopsTotals(); myRecipe.mash .setMaltWeight(myRecipe .getTotalMashLbs()); myRecipe.mash.calcMashSchedule(); displayRecipe(); } else { System.out .print("Open command cancelled by user.\n"); } } }); } { saveMenuItem = new JMenuItem(); jMenu3.add(saveMenuItem); saveMenuItem.setText("Save"); } { saveAsMenuItem = new JMenuItem(); jMenu3.add(saveAsMenuItem); saveAsMenuItem.setText("Save As ..."); saveAsMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // This is just a test right now to see that // stuff is changed. System.out.print(myRecipe.toText()); } }); } { exportMenu = new JMenu(); jMenu3.add(exportMenu); exportMenu.setText("Export"); { exportHTMLmenu = new JMenuItem(); exportMenu.add(exportHTMLmenu); exportHTMLmenu.setText("HTML"); exportHTMLmenu .addActionListener(new ActionListener() { public void actionPerformed ( ActionEvent evt) { try{ saveAsHTML(); } catch (Exception e){ } } }); } } { closeFileMenuItem = new JMenuItem(); jMenu3.add(closeFileMenuItem); closeFileMenuItem.setText("Close"); } { jSeparator2 = new JSeparator(); jMenu3.add(jSeparator2); } { exitMenuItem = new JMenuItem(); jMenu3.add(exitMenuItem); exitMenuItem.setText("Exit"); exitMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // exit program System.exit(0); } }); } } { jMenu4 = new JMenu(); jMenuBar1.add(jMenu4); jMenu4.setText("Edit"); { cutMenuItem = new JMenuItem(); jMenu4.add(cutMenuItem); cutMenuItem.setText("Cut"); } { copyMenuItem = new JMenuItem(); jMenu4.add(copyMenuItem); copyMenuItem.setText("Copy"); } { pasteMenuItem = new JMenuItem(); jMenu4.add(pasteMenuItem); pasteMenuItem.setText("Paste"); } { jSeparator1 = new JSeparator(); jMenu4.add(jSeparator1); } { deleteMenuItem = new JMenuItem(); jMenu4.add(deleteMenuItem); deleteMenuItem.setText("Delete"); } } { jMenu5 = new JMenu(); jMenuBar1.add(jMenu5); jMenu5.setText("Help"); { helpMenuItem = new JMenuItem(); jMenu5.add(helpMenuItem); helpMenuItem.setText("Help"); } } } } catch (Exception e) { e.printStackTrace(); } }
1,116,796
private void initGUI() { try { this.setSize(520, 532); this.addWindowListener(new WindowAdapter() { public void windowClosed(WindowEvent evt) { System.exit(1); } }); { pnlMain = new JPanel(); GridBagLayout jPanel2Layout = new GridBagLayout(); jPanel2Layout.columnWeights = new double[]{0.1}; jPanel2Layout.columnWidths = new int[]{7}; jPanel2Layout.rowWeights = new double[]{0.1, 0.1, 0.1}; jPanel2Layout.rowHeights = new int[]{7, 7, 7}; pnlMain.setLayout(jPanel2Layout); this.getContentPane().add(pnlMain, BorderLayout.CENTER); { jPanel1 = new JPanel(); pnlMain.add(jPanel1, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); FlowLayout jPanel1Layout = new FlowLayout(); jPanel1Layout.setAlignment(FlowLayout.LEFT); jPanel1.setLayout(jPanel1Layout); { lblName = new JLabel(); jPanel1.add(lblName); lblName.setText("Name:"); } { txtName = new JTextField(); jPanel1.add(txtName); txtName.setText("Name"); txtName .setPreferredSize(new java.awt.Dimension(179, 20)); txtName.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { myRecipe.setName(txtName.getText()); } }); } } { 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}; pnlDetailsLayout.columnWidths = new int[]{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); { lblBrewer = new JLabel(); pnlDetails.add(lblBrewer, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblBrewer.setText("Brewer:"); } { txtBrewer = new JTextField(); pnlDetails.add(txtBrewer, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets( 0, 0, 0, 0), 0, 0)); txtBrewer.setText("Brewer"); txtBrewer.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { myRecipe.setBrewer(txtBrewer.getText()); } }); } { 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:"); } { lblMash = new JLabel(); pnlDetails.add(lblMash, new GridBagConstraints(0, 6, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblMash.setText("Mash:"); } { lblEffic = new JLabel(); pnlDetails.add(lblEffic, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblEffic.setText("Effic:"); } { lblAtten = new JLabel(); pnlDetails.add(lblAtten, new GridBagConstraints(3, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblAtten.setText("Atten:"); } { lblOG = new JLabel(); pnlDetails.add(lblOG, new GridBagConstraints(3, 2, 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(3, 3, 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(5, 0, 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(5, 2, 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(5, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblColour.setText("Colour:"); } { txtDate = new JTextField(); pnlDetails.add(txtDate, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets( 0, 0, 0, 0), 0, 0)); txtDate.setText("Date"); } { cmbStyleModel = new ComboModel(); cmbStyle = new JComboBox(); pnlDetails.add(cmbStyle, new GridBagConstraints(1, 2, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets( 0, 0, 0, 0), 0, 0)); cmbStyle.setModel(cmbStyleModel); cmbStyle.setMaximumSize(new java.awt.Dimension(100, 32767)); cmbStyle.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { Style s = (Style) cmbStyleModel .getSelectedItem(); if (myRecipe != null && s != myRecipe.getStyleObj()) { myRecipe.setStyle(s); } } }); } { txtPreBoil = new JFormattedTextField(); pnlDetails.add(txtPreBoil, new GridBagConstraints( 1, 4, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets( 0, 0, 0, 0), 0, 0)); txtPreBoil.setText("Pre Boil"); txtPreBoil.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { myRecipe.setPreBoil(Double .parseDouble(txtPreBoil.getText() .toString())); displayRecipe(); } }); } { txtPostBoil = new JFormattedTextField(); pnlDetails.add(txtPostBoil, new GridBagConstraints( 1, 5, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets( 0, 0, 0, 0), 0, 0)); txtPostBoil.setText("Post Boil"); txtPostBoil.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { System.out .println("txtPostBoil.actionPerformed, event=" + evt); myRecipe.setPostBoil(Double .parseDouble(txtPostBoil.getText() .toString())); displayRecipe(); } }); } { lblComments = new JLabel(); pnlDetails.add(lblComments, new GridBagConstraints( 3, 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.#")); } { SpinnerNumberModel spnAttenModel = new SpinnerNumberModel( 75.0, 0.0, 100.0, 1.0); spnAtten = new JSpinner(); pnlDetails.add(spnAtten, new GridBagConstraints(4, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets( 0, 0, 0, 0), 0, 0)); spnAtten.setModel(spnAttenModel); spnAtten.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent evt) { myRecipe.setAttenuation(Double .parseDouble(spnAtten.getValue() .toString())); displayRecipe(); } }); spnAtten.setEditor(new JSpinner.NumberEditor( spnAtten, "00.#")); } { SpinnerNumberModel spnOgModel = new SpinnerNumberModel( 1.000, 0.900, 2.000, 0.001); spnOG = new JSpinner(); pnlDetails.add(spnOG, new GridBagConstraints(4, 2, 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")); } { SpinnerNumberModel spnFgModel = new SpinnerNumberModel( 1.000, 0.900, 2.000, 0.001); spnFG = new JSpinner(); pnlDetails.add(spnFG, new GridBagConstraints(4, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets( 0, 0, 0, 0), 0, 0)); spnFG.setModel(spnFgModel); spnFG.setEditor(new JSpinner.NumberEditor(spnFG, "0.000")); spnFG.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent evt) { // set the new FG, and update alc: myRecipe.setEstFg(Double.parseDouble(spnFG .getValue().toString())); displayRecipe(); } }); } { lblIBUvalue = new JLabel(); pnlDetails.add(lblIBUvalue, new GridBagConstraints( 6, 0, 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(6, 1, 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( 6, 2, 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( 3, 5, 4, 2, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); { txtComments = new JTextArea(); scpComments.setViewportView(txtComments); txtComments.setText("Comments"); txtComments.setWrapStyleWord(true); txtComments .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, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets( 0, 0, 0, 0), 0, 0)); cmbYeast.setModel(cmbYeastModel); cmbYeast.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { Yeast y = (Yeast) cmbYeastModel .getSelectedItem(); if (myRecipe!= null && y != myRecipe.getYeastObj()) { myRecipe.setYeast(y); } } }); } { ComboBoxModel cmbSizeUnitsModel = new DefaultComboBoxModel( new String[]{"Item One", "Item Two"}); cmbSizeUnits = new JComboBox(); pnlDetails.add(cmbSizeUnits, new GridBagConstraints(2, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); cmbSizeUnits.setModel(cmbSizeUnitsModel); } { lblSizeUnits = new JLabel(); pnlDetails.add(lblSizeUnits, new GridBagConstraints(2, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblSizeUnits.setText("Size Units"); } } { pnlStyle = new JPanel(); FlowLayout pnlStyleLayout = new FlowLayout(); pnlStyle.setLayout(pnlStyleLayout); jTabbedPane1.addTab("Style", null, pnlStyle, null); { lblStyle2 = new JLabel(); pnlStyle.add(lblStyle2); lblStyle2.setText("Style:"); } { ComboBoxModel cmbStyle2Model = new DefaultComboBoxModel( new String[] { "Item One", "Item Two" }); cmbStyle2 = new JComboBox(); pnlStyle.add(cmbStyle2); cmbStyle2.setModel(cmbStyle2Model); } { jPanel2 = new JPanel(); GridBagLayout jPanel2Layout1 = new GridBagLayout(); jPanel2Layout1.columnWeights = new double[] {0.1,0.1,0.1,0.1}; jPanel2Layout1.columnWidths = new int[] {7,7,7,7}; jPanel2Layout1.rowWeights = new double[] {0.1,0.1,0.1,0.1,0.1,0.1}; jPanel2Layout1.rowHeights = new int[] {7,7,7,7,7,7}; jPanel2.setPreferredSize(new java.awt.Dimension(179, 120)); jPanel2.setLayout(jPanel2Layout1); pnlStyle.add(jPanel2); jPanel2.setBorder(BorderFactory.createTitledBorder(new LineBorder(new java.awt.Color(0,0,0), 1, false), "Recipe Conformance:", TitledBorder.LEADING, TitledBorder.TOP, new java.awt.Font("Dialog",0,12), new java.awt.Color(0,0,0))); { jLabel5 = new JLabel(); jPanel2.add(jLabel5, new GridBagConstraints( 0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel5.setText("OG:"); jLabel5.setBounds(74, 3, 60, 30); } { jLabel1 = new JLabel(); jPanel2.add(jLabel1, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); GridLayout jLabel1Layout = new GridLayout(1, 1); jLabel1.setLayout(jLabel1Layout); jLabel1.setText("Low:"); } { jLabel2 = new JLabel(); jPanel2.add(jLabel2, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel2.setText("Recipe:"); } { jLabel3 = new JLabel(); jPanel2.add(jLabel3, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel3.setText("High:"); } { jLabel4 = new JLabel(); jPanel2.add(jLabel4, new GridBagConstraints( 0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel4.setText("IBU:"); } { jLabel6 = new JLabel(); jPanel2.add(jLabel6, new GridBagConstraints( 0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel6.setText("Colour:"); } { jLabel7 = new JLabel(); jPanel2.add(jLabel7, new GridBagConstraints( 0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel7.setText("ABV:"); } } { jScrollPane3 = new JScrollPane(); pnlStyle.add(jScrollPane3); { txaStyles = new JTextArea(); jScrollPane3.setViewportView(txaStyles); txaStyles.setText("Matched Styles"); } } { sldMatch = new JSlider(); pnlStyle.add(sldMatch); } } } { pnlTables = new JPanel(); BoxLayout pnlMaltsLayout = new BoxLayout(pnlTables, javax.swing.BoxLayout.Y_AXIS); pnlMain.add(pnlTables, new GridBagConstraints(0, 2, 1, 1, 0.5, 0.5, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); pnlTables.setLayout(pnlMaltsLayout); { pnlMalt = new JPanel(); pnlTables.add(pnlMalt); BorderLayout pnlMaltLayout1 = new BorderLayout(); FlowLayout pnlMaltLayout = new FlowLayout(); pnlMalt.setBorder(BorderFactory.createTitledBorder( new LineBorder(new java.awt.Color(0, 0, 0), 1, false), "Fermentables", TitledBorder.LEADING, TitledBorder.TOP, new java.awt.Font("Dialog", 1, 12), new java.awt.Color(51, 51, 51))); pnlMalt.setLayout(pnlMaltLayout1); { jScrollPane1 = new JScrollPane(); pnlMalt.add(jScrollPane1, BorderLayout.CENTER); { tblMaltModel = new MaltTableModel(this); tblMalt = new JTable(); jScrollPane1.setViewportView(tblMalt); BorderLayout tblMaltLayout = new BorderLayout(); tblMalt.setLayout(tblMaltLayout); tblMalt.setModel(tblMaltModel); // TableColumn column = null; TableColumn maltColumn = tblMalt.getColumnModel().getColumn(0); JComboBox maltComboBox = new JComboBox(); cmbMaltModel = new ComboModel(); maltComboBox.setModel(cmbMaltModel); maltColumn.setCellEditor(new DefaultCellEditor(maltComboBox)); /* for (int i = 0; i < tblMalt.getColumnCount(); i++) { column = tblMalt.getColumnModel() .getColumn(i); if (i == 0) { column.setPreferredWidth(100); } else { column.setPreferredWidth(50); } }*/ maltComboBox .addActionListener(new ActionListener() { public void actionPerformed( ActionEvent evt) { Fermentable f = (Fermentable) cmbMaltModel .getSelectedItem(); int i = tblMalt .getSelectedRow(); if (myRecipe != null) { Fermentable f2 = (Fermentable) myRecipe .getFermentablesList() .get(i); f2.setLov(f.getLov()); f2.setPppg(f.getPppg()); } } }); } } { tblMaltTotalsModel = new DefaultTableModel( new String[][]{{""}}, new String[]{"Malt", "Amount", "Units", "Points", "Lov", "Cost/U", "%"}); tblMaltTotals = new JTable(); pnlMalt.add(tblMaltTotals, BorderLayout.SOUTH); tblMaltTotals.setModel(tblMaltTotalsModel); tblMaltTotals.getTableHeader().setEnabled(false); } } { 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[]{ "Column 1", "Column 2"}); tblHopsTotals = new JTable(); pnlHops.add(tblHopsTotals, BorderLayout.SOUTH); tblHopsTotals.setModel(tblHopsTotalsModel); } { jScrollPane2 = new JScrollPane(); pnlHops.add(jScrollPane2, BorderLayout.CENTER); { tblHopsModel = new HopsTableModel(this); tblHops = new JTable(); jScrollPane2.setViewportView(tblHops); BorderLayout tblHopsLayout = new BorderLayout(); tblHops.setLayout(tblHopsLayout); tblHops.setModel(tblHopsModel); TableColumn hopColumn = tblHops.getColumnModel().getColumn(0); JComboBox hopComboBox = new JComboBox(); cmbHopsModel = new ComboModel(); hopComboBox.setModel(cmbHopsModel); hopColumn.setCellEditor(new DefaultCellEditor(hopComboBox)); } } } } } { jMenuBar1 = new JMenuBar(); setJMenuBar(jMenuBar1); { jMenu3 = new JMenu(); jMenuBar1.add(jMenu3); jMenu3.setText("File"); { newFileMenuItem = new JMenuItem(); jMenu3.add(newFileMenuItem); newFileMenuItem.setText("New"); } { openFileMenuItem = new JMenuItem(); jMenu3.add(openFileMenuItem); openFileMenuItem.setText("Open"); openFileMenuItem .addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { String path = getClass() .getProtectionDomain() .getCodeSource().getLocation() .toString().substring(6) + "\\"; JFileChooser fc = new JFileChooser(path); // Show open dialog; this method does // not return until the dialog is closed int returnVal = fc .showOpenDialog(jMenuBar1); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); System.out.print("Opening: " + file.getName() + ".\n"); ImportXml imp = new ImportXml(file .toString()); myRecipe = imp.handler.getRecipe(); myRecipe.calcMaltTotals(); myRecipe.calcHopsTotals(); myRecipe.mash .setMaltWeight(myRecipe .getTotalMashLbs()); myRecipe.mash.calcMashSchedule(); displayRecipe(); } else { System.out .print("Open command cancelled by user.\n"); } } }); } { saveMenuItem = new JMenuItem(); jMenu3.add(saveMenuItem); saveMenuItem.setText("Save"); } { saveAsMenuItem = new JMenuItem(); jMenu3.add(saveAsMenuItem); saveAsMenuItem.setText("Save As ..."); saveAsMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // This is just a test right now to see that // stuff is changed. System.out.print(myRecipe.toText()); } }); } { exportMenu = new JMenu(); jMenu3.add(exportMenu); exportMenu.setText("Export"); { exportHTMLmenu = new JMenuItem(); exportMenu.add(exportHTMLmenu); exportHTMLmenu.setText("HTML"); exportHTMLmenu .addActionListener(new ActionListener() { public void actionPerformed ( ActionEvent evt) { try{ saveAsHTML(); } catch (Exception e){ } } }); } } { closeFileMenuItem = new JMenuItem(); jMenu3.add(closeFileMenuItem); closeFileMenuItem.setText("Close"); } { jSeparator2 = new JSeparator(); jMenu3.add(jSeparator2); } { exitMenuItem = new JMenuItem(); jMenu3.add(exitMenuItem); exitMenuItem.setText("Exit"); exitMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // exit program System.exit(0); } }); } } { jMenu4 = new JMenu(); jMenuBar1.add(jMenu4); jMenu4.setText("Edit"); { cutMenuItem = new JMenuItem(); jMenu4.add(cutMenuItem); cutMenuItem.setText("Cut"); } { copyMenuItem = new JMenuItem(); jMenu4.add(copyMenuItem); copyMenuItem.setText("Copy"); } { pasteMenuItem = new JMenuItem(); jMenu4.add(pasteMenuItem); pasteMenuItem.setText("Paste"); } { jSeparator1 = new JSeparator(); jMenu4.add(jSeparator1); } { deleteMenuItem = new JMenuItem(); jMenu4.add(deleteMenuItem); deleteMenuItem.setText("Delete"); } } { jMenu5 = new JMenu(); jMenuBar1.add(jMenu5); jMenu5.setText("Help"); { helpMenuItem = new JMenuItem(); jMenu5.add(helpMenuItem); helpMenuItem.setText("Help"); } } } } catch (Exception e) { e.printStackTrace(); } }
private void initGUI() { try { this.setSize(520, 532); this.addWindowListener(new WindowAdapter() { public void windowClosed(WindowEvent evt) { System.exit(1); } }); { pnlMain = new JPanel(); GridBagLayout jPanel2Layout = new GridBagLayout(); jPanel2Layout.columnWeights = new double[]{0.1}; jPanel2Layout.columnWidths = new int[]{7}; jPanel2Layout.rowWeights = new double[]{0.1, 0.1, 0.1}; jPanel2Layout.rowHeights = new int[]{7, 7, 7}; pnlMain.setLayout(jPanel2Layout); this.getContentPane().add(pnlMain, BorderLayout.CENTER); { jPanel1 = new JPanel(); pnlMain.add(jPanel1, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); FlowLayout jPanel1Layout = new FlowLayout(); jPanel1Layout.setAlignment(FlowLayout.LEFT); jPanel1.setLayout(jPanel1Layout); { lblName = new JLabel(); jPanel1.add(lblName); lblName.setText("Name:"); } { txtName = new JTextField(); jPanel1.add(txtName); txtName.setText("Name"); txtName .setPreferredSize(new java.awt.Dimension(179, 20)); txtName.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { myRecipe.setName(txtName.getText()); } }); } } { 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}; pnlDetailsLayout.columnWidths = new int[]{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); { lblBrewer = new JLabel(); pnlDetails.add(lblBrewer, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblBrewer.setText("Brewer:"); } { txtBrewer = new JTextField(); pnlDetails.add(txtBrewer, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets( 0, 0, 0, 0), 0, 0)); txtBrewer.setText("Brewer"); txtBrewer.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { myRecipe.setBrewer(txtBrewer.getText()); } }); } { 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:"); } { lblMash = new JLabel(); pnlDetails.add(lblMash, new GridBagConstraints(0, 6, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblMash.setText("Mash:"); } { lblEffic = new JLabel(); pnlDetails.add(lblEffic, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblEffic.setText("Effic:"); } { lblAtten = new JLabel(); pnlDetails.add(lblAtten, new GridBagConstraints(3, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblAtten.setText("Atten:"); } { lblOG = new JLabel(); pnlDetails.add(lblOG, new GridBagConstraints(3, 2, 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(3, 3, 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(5, 0, 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(5, 2, 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(5, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblColour.setText("Colour:"); } { txtDate = new JTextField(); pnlDetails.add(txtDate, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets( 0, 0, 0, 0), 0, 0)); txtDate.setText("Date"); } { cmbStyleModel = new ComboModel(); cmbStyle = new JComboBox(); pnlDetails.add(cmbStyle, new GridBagConstraints(1, 2, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets( 0, 0, 0, 0), 0, 0)); cmbStyle.setModel(cmbStyleModel); cmbStyle.setMaximumSize(new java.awt.Dimension(100, 32767)); cmbStyle.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { Style s = (Style) cmbStyleModel .getSelectedItem(); if (myRecipe != null && s != myRecipe.getStyleObj()) { myRecipe.setStyle(s); } } }); } { txtPreBoil = new JFormattedTextField(); pnlDetails.add(txtPreBoil, new GridBagConstraints( 1, 4, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets( 0, 0, 0, 0), 0, 0)); txtPreBoil.setText("Pre Boil"); txtPreBoil.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { myRecipe.setPreBoil(Double .parseDouble(txtPreBoil.getText() .toString())); displayRecipe(); } }); } { txtPostBoil = new JFormattedTextField(); pnlDetails.add(txtPostBoil, new GridBagConstraints( 1, 5, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets( 0, 0, 0, 0), 0, 0)); txtPostBoil.setText("Post Boil"); txtPostBoil.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { System.out .println("txtPostBoil.actionPerformed, event=" + evt); myRecipe.setPostBoil(Double .parseDouble(txtPostBoil.getText() .toString())); displayRecipe(); } }); } { lblComments = new JLabel(); pnlDetails.add(lblComments, new GridBagConstraints( 3, 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.#")); } { SpinnerNumberModel spnAttenModel = new SpinnerNumberModel( 75.0, 0.0, 100.0, 1.0); spnAtten = new JSpinner(); pnlDetails.add(spnAtten, new GridBagConstraints(4, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets( 0, 0, 0, 0), 0, 0)); spnAtten.setModel(spnAttenModel); spnAtten.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent evt) { myRecipe.setAttenuation(Double .parseDouble(spnAtten.getValue() .toString())); displayRecipe(); } }); spnAtten.setEditor(new JSpinner.NumberEditor( spnAtten, "00.#")); } { SpinnerNumberModel spnOgModel = new SpinnerNumberModel( 1.000, 0.900, 2.000, 0.001); spnOG = new JSpinner(); pnlDetails.add(spnOG, new GridBagConstraints(4, 2, 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")); } { SpinnerNumberModel spnFgModel = new SpinnerNumberModel( 1.000, 0.900, 2.000, 0.001); spnFG = new JSpinner(); pnlDetails.add(spnFG, new GridBagConstraints(4, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets( 0, 0, 0, 0), 0, 0)); spnFG.setModel(spnFgModel); spnFG.setEditor(new JSpinner.NumberEditor(spnFG, "0.000")); spnFG.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent evt) { // set the new FG, and update alc: myRecipe.setEstFg(Double.parseDouble(spnFG .getValue().toString())); displayRecipe(); } }); } { lblIBUvalue = new JLabel(); pnlDetails.add(lblIBUvalue, new GridBagConstraints( 6, 0, 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(6, 1, 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( 6, 2, 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( 3, 5, 4, 2, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); { txtComments = new JTextArea(); scpComments.setViewportView(txtComments); txtComments.setText("Comments"); txtComments.setWrapStyleWord(true); txtComments .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, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets( 0, 0, 0, 0), 0, 0)); cmbYeast.setModel(cmbYeastModel); cmbYeast.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { Yeast y = (Yeast) cmbYeastModel .getSelectedItem(); if (myRecipe!= null && y != myRecipe.getYeastObj()) { myRecipe.setYeast(y); } } }); } { ComboBoxModel cmbSizeUnitsModel = new DefaultComboBoxModel( new String[]{"Item One", "Item Two"}); cmbSizeUnits = new JComboBox(); pnlDetails.add(cmbSizeUnits, new GridBagConstraints(2, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); cmbSizeUnits.setModel(cmbSizeUnitsModel); } { lblSizeUnits = new JLabel(); pnlDetails.add(lblSizeUnits, new GridBagConstraints(2, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblSizeUnits.setText("Size Units"); } } { pnlStyle = new JPanel(); FlowLayout pnlStyleLayout = new FlowLayout(); pnlStyle.setLayout(pnlStyleLayout); jTabbedPane1.addTab("Style", null, pnlStyle, null); { lblStyle2 = new JLabel(); pnlStyle.add(lblStyle2); lblStyle2.setText("Style:"); } { ComboBoxModel cmbStyle2Model = new DefaultComboBoxModel( new String[] { "Item One", "Item Two" }); cmbStyle2 = new JComboBox(); pnlStyle.add(cmbStyle2); cmbStyle2.setModel(cmbStyle2Model); } { jPanel2 = new JPanel(); GridBagLayout jPanel2Layout1 = new GridBagLayout(); jPanel2Layout1.columnWeights = new double[] {0.1,0.1,0.1,0.1}; jPanel2Layout1.columnWidths = new int[] {7,7,7,7}; jPanel2Layout1.rowWeights = new double[] {0.1,0.1,0.1,0.1,0.1,0.1}; jPanel2Layout1.rowHeights = new int[] {7,7,7,7,7,7}; jPanel2.setPreferredSize(new java.awt.Dimension(179, 120)); jPanel2.setLayout(jPanel2Layout1); pnlStyle.add(jPanel2); jPanel2.setBorder(BorderFactory.createTitledBorder(new LineBorder(new java.awt.Color(0,0,0), 1, false), "Recipe Conformance:", TitledBorder.LEADING, TitledBorder.TOP, new java.awt.Font("Dialog",0,12), new java.awt.Color(0,0,0))); { jLabel5 = new JLabel(); jPanel2.add(jLabel5, new GridBagConstraints( 0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel5.setText("OG:"); jLabel5.setBounds(74, 3, 60, 30); } { jLabel1 = new JLabel(); jPanel2.add(jLabel1, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); GridLayout jLabel1Layout = new GridLayout(1, 1); jLabel1.setLayout(jLabel1Layout); jLabel1.setText("Low:"); } { jLabel2 = new JLabel(); jPanel2.add(jLabel2, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel2.setText("Recipe:"); } { jLabel3 = new JLabel(); jPanel2.add(jLabel3, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel3.setText("High:"); } { jLabel4 = new JLabel(); jPanel2.add(jLabel4, new GridBagConstraints( 0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel4.setText("IBU:"); } { jLabel6 = new JLabel(); jPanel2.add(jLabel6, new GridBagConstraints( 0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel6.setText("Colour:"); } { jLabel7 = new JLabel(); jPanel2.add(jLabel7, new GridBagConstraints( 0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel7.setText("ABV:"); } } { jScrollPane3 = new JScrollPane(); pnlStyle.add(jScrollPane3); { txaStyles = new JTextArea(); jScrollPane3.setViewportView(txaStyles); txaStyles.setText("Matched Styles"); } } { sldMatch = new JSlider(); pnlStyle.add(sldMatch); } } } { pnlTables = new JPanel(); BoxLayout pnlMaltsLayout = new BoxLayout(pnlTables, javax.swing.BoxLayout.Y_AXIS); pnlMain.add(pnlTables, new GridBagConstraints(0, 2, 1, 1, 0.5, 0.5, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); pnlTables.setLayout(pnlMaltsLayout); { pnlMalt = new JPanel(); pnlTables.add(pnlMalt); BorderLayout pnlMaltLayout1 = new BorderLayout(); FlowLayout pnlMaltLayout = new FlowLayout(); pnlMalt.setBorder(BorderFactory.createTitledBorder( new LineBorder(new java.awt.Color(0, 0, 0), 1, false), "Fermentables", TitledBorder.LEADING, TitledBorder.TOP, new java.awt.Font("Dialog", 1, 12), new java.awt.Color(51, 51, 51))); pnlMalt.setLayout(pnlMaltLayout1); { jScrollPane1 = new JScrollPane(); pnlMalt.add(jScrollPane1, BorderLayout.CENTER); { tblMaltModel = new MaltTableModel(this); tblMalt = new JTable(); jScrollPane1.setViewportView(tblMalt); BorderLayout tblMaltLayout = new BorderLayout(); tblMalt.setLayout(tblMaltLayout); tblMalt.setModel(tblMaltModel); // TableColumn column = null; TableColumn maltColumn = tblMalt.getColumnModel().getColumn(0); JComboBox maltComboBox = new JComboBox(); cmbMaltModel = new ComboModel(); maltComboBox.setModel(cmbMaltModel); maltColumn.setCellEditor(new DefaultCellEditor(maltComboBox)); /* for (int i = 0; i < tblMalt.getColumnCount(); i++) { column = tblMalt.getColumnModel() .getColumn(i); if (i == 0) { column.setPreferredWidth(100); } else { column.setPreferredWidth(50); } } maltComboBox .addActionListener(new ActionListener() { public void actionPerformed( ActionEvent evt) { Fermentable f = (Fermentable) cmbMaltModel .getSelectedItem(); int i = tblMalt .getSelectedRow(); if (myRecipe != null) { Fermentable f2 = (Fermentable) myRecipe .getFermentablesList() .get(i); f2.setLov(f.getLov()); f2.setPppg(f.getPppg()); } } }); } } { tblMaltTotalsModel = new DefaultTableModel( new String[][]{{""}}, new String[]{"Malt", "Amount", "Units", "Points", "Lov", "Cost/U", "%"}); tblMaltTotals = new JTable(); pnlMalt.add(tblMaltTotals, BorderLayout.SOUTH); tblMaltTotals.setModel(tblMaltTotalsModel); tblMaltTotals.getTableHeader().setEnabled(false); } } { 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[]{ "Column 1", "Column 2"}); tblHopsTotals = new JTable(); pnlHops.add(tblHopsTotals, BorderLayout.SOUTH); tblHopsTotals.setModel(tblHopsTotalsModel); } { jScrollPane2 = new JScrollPane(); pnlHops.add(jScrollPane2, BorderLayout.CENTER); { tblHopsModel = new HopsTableModel(this); tblHops = new JTable(); jScrollPane2.setViewportView(tblHops); BorderLayout tblHopsLayout = new BorderLayout(); tblHops.setLayout(tblHopsLayout); tblHops.setModel(tblHopsModel); TableColumn hopColumn = tblHops.getColumnModel().getColumn(0); JComboBox hopComboBox = new JComboBox(); cmbHopsModel = new ComboModel(); hopComboBox.setModel(cmbHopsModel); hopColumn.setCellEditor(new DefaultCellEditor(hopComboBox)); } } } } } { jMenuBar1 = new JMenuBar(); setJMenuBar(jMenuBar1); { jMenu3 = new JMenu(); jMenuBar1.add(jMenu3); jMenu3.setText("File"); { newFileMenuItem = new JMenuItem(); jMenu3.add(newFileMenuItem); newFileMenuItem.setText("New"); } { openFileMenuItem = new JMenuItem(); jMenu3.add(openFileMenuItem); openFileMenuItem.setText("Open"); openFileMenuItem .addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { String path = getClass() .getProtectionDomain() .getCodeSource().getLocation() .toString().substring(6) + "\\"; JFileChooser fc = new JFileChooser(path); // Show open dialog; this method does // not return until the dialog is closed int returnVal = fc .showOpenDialog(jMenuBar1); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); System.out.print("Opening: " + file.getName() + ".\n"); ImportXml imp = new ImportXml(file .toString()); myRecipe = imp.handler.getRecipe(); myRecipe.calcMaltTotals(); myRecipe.calcHopsTotals(); myRecipe.mash .setMaltWeight(myRecipe .getTotalMashLbs()); myRecipe.mash.calcMashSchedule(); displayRecipe(); } else { System.out .print("Open command cancelled by user.\n"); } } }); } { saveMenuItem = new JMenuItem(); jMenu3.add(saveMenuItem); saveMenuItem.setText("Save"); } { saveAsMenuItem = new JMenuItem(); jMenu3.add(saveAsMenuItem); saveAsMenuItem.setText("Save As ..."); saveAsMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // This is just a test right now to see that // stuff is changed. System.out.print(myRecipe.toText()); } }); } { exportMenu = new JMenu(); jMenu3.add(exportMenu); exportMenu.setText("Export"); { exportHTMLmenu = new JMenuItem(); exportMenu.add(exportHTMLmenu); exportHTMLmenu.setText("HTML"); exportHTMLmenu .addActionListener(new ActionListener() { public void actionPerformed ( ActionEvent evt) { try{ saveAsHTML(); } catch (Exception e){ } } }); } } { closeFileMenuItem = new JMenuItem(); jMenu3.add(closeFileMenuItem); closeFileMenuItem.setText("Close"); } { jSeparator2 = new JSeparator(); jMenu3.add(jSeparator2); } { exitMenuItem = new JMenuItem(); jMenu3.add(exitMenuItem); exitMenuItem.setText("Exit"); exitMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // exit program System.exit(0); } }); } } { jMenu4 = new JMenu(); jMenuBar1.add(jMenu4); jMenu4.setText("Edit"); { cutMenuItem = new JMenuItem(); jMenu4.add(cutMenuItem); cutMenuItem.setText("Cut"); } { copyMenuItem = new JMenuItem(); jMenu4.add(copyMenuItem); copyMenuItem.setText("Copy"); } { pasteMenuItem = new JMenuItem(); jMenu4.add(pasteMenuItem); pasteMenuItem.setText("Paste"); } { jSeparator1 = new JSeparator(); jMenu4.add(jSeparator1); } { deleteMenuItem = new JMenuItem(); jMenu4.add(deleteMenuItem); deleteMenuItem.setText("Delete"); } } { jMenu5 = new JMenu(); jMenuBar1.add(jMenu5); jMenu5.setText("Help"); { helpMenuItem = new JMenuItem(); jMenu5.add(helpMenuItem); helpMenuItem.setText("Help"); } } } } catch (Exception e) { e.printStackTrace(); } }
1,116,797
public void filterData(){ float[] fdata = seis.get_as_floats(); // remove the mean before filtering double mean = 0; for (int i=0; i<fdata.length; i++) { mean += fdata[i]; } // end of for (int i=0; i<fdata.length; i++) mean /= fdata.length; float fmean = (float)mean; for (int i=0; i<fdata.length; i++) { fdata[i] -= fmean; } // end of for (int i=0; i<fdata.length; i++) Cmplx[] fftdata = Cmplx.fft(fdata); //save memory fdata = null; double dt = seis.getSampling().getPeriod().convertTo(UnitImpl.SECOND).getValue(); Cmplx[] filtered = filter.apply(dt, fftdata); // save memory fftdata = null; float[] outData = Cmplx.fftInverse(filtered, seis.getNumPoints()); TimeSeriesDataSel sel = new TimeSeriesDataSel(); sel.flt_values(outData); filteredSeis = new LocalSeismogramImpl(seis, sel); }
public void filterData(){ float[] fdata; if(seis.can_convert_to_float()) fdata = seis.get_as_floats(); else{ int[] idata = seis.get_as_longs(); fdata = new float[idata.length]; for(int i = 0; i < idata.length; i++) fdata[i] = idata[i]; idata = null; } // remove the mean before filtering double mean = 0; for (int i=0; i<fdata.length; i++) { mean += fdata[i]; } // end of for (int i=0; i<fdata.length; i++) mean /= fdata.length; float fmean = (float)mean; for (int i=0; i<fdata.length; i++) { fdata[i] -= fmean; } // end of for (int i=0; i<fdata.length; i++) Cmplx[] fftdata = Cmplx.fft(fdata); //save memory fdata = null; double dt = seis.getSampling().getPeriod().convertTo(UnitImpl.SECOND).getValue(); Cmplx[] filtered = filter.apply(dt, fftdata); // save memory fftdata = null; float[] outData = Cmplx.fftInverse(filtered, seis.getNumPoints()); TimeSeriesDataSel sel = new TimeSeriesDataSel(); sel.flt_values(outData); filteredSeis = new LocalSeismogramImpl(seis, sel); }
1,116,798
public void readYeast(String path) { // read the yeast from the csv file try { File yeastFile = new File(path, "yeast.csv"); CSVReader reader = new CSVReader(new FileReader( yeastFile), ',', '\"', true, false); try { // get the first line and set up the index: String[] fields = reader.getAllFieldsInLine(); int nameIdx = getIndex(fields, "Name"); int costIdx = getIndex(fields, "Cost"); int descrIdx = getIndex(fields, "Descr"); int modIdx = getIndex(fields, "Modified"); while (true) { Yeast y = new Yeast(); fields = reader.getAllFieldsInLine(); y.setName(fields[nameIdx]); if (!fields[costIdx].equals("")) y.setCost(Double.parseDouble(fields[costIdx])); y.setDescription(fields[descrIdx]); y.setModified(Boolean.valueOf(fields[modIdx]).booleanValue()); yeastDB.add(y); } } catch (EOFException e) { } reader.close(); } catch (IOException e) { e.printStackTrace(); System.out.println(e.getMessage()); } // sort: ObjComparator sc = new ObjComparator(); Collections.sort(yeastDB, sc); }
public void readYeast(String path) { // read the yeast from the csv file try { File yeastFile = new File(path, "yeast.csv"); CSVReader reader = new CSVReader(new FileReader( yeastFile), ',', '\"', true, false); try { // get the first line and set up the index: String[] fields = reader.getAllFieldsInLine(); int nameIdx = getIndex(fields, "Name"); int costIdx = getIndex(fields, "Cost"); int descrIdx = getIndex(fields, "Descr"); int modIdx = getIndex(fields, "Modified"); while (true) { Yeast y = new Yeast(); fields = reader.getAllFieldsInLine(); y.setName(fields[nameIdx]); if (!fields[costIdx].equals("")) y.setCost(Double.parseDouble(fields[costIdx])); y.setDescription(fields[descrIdx]); y.setModified(Boolean.valueOf(fields[modIdx]).booleanValue()); yeastDB.add(y); } } catch (EOFException e) { } reader.close(); } catch (IOException e) { e.printStackTrace(); System.out.println(e.getMessage()); } // sort: ObjComparator sc = new ObjComparator(); Collections.sort(yeastDB, sc); }
1,116,800
public Collection find(String query, Object values) { if (logger.isDebugEnabled()) { logger.debug("\n Finding object with query "+query); } if (values instanceof Object[]) { return queryAssembler(query, values).list(); } return this.getHibernateTemplate().find(query, values); }
public Collection find(String query, Object... values) throws DataAccessException { if (logger.isDebugEnabled()) { logger.debug("\n Finding object with query "+query); } if (values instanceof Object[]) { return queryAssembler(query, values).list(); } return this.getHibernateTemplate().find(query, values); }
1,116,801
public Collection find(String query, Object values) { if (logger.isDebugEnabled()) { logger.debug("\n Finding object with query "+query); } if (values instanceof Object[]) { return queryAssembler(query, values).list(); } return this.getHibernateTemplate().find(query, values); }
public Collection find(String query, Object values) { if (logger.isDebugEnabled()) { logger.debug("** DAO finding ["+query+"] with "+values); } if (values instanceof Object[]) { return queryAssembler(query, values).list(); } return this.getHibernateTemplate().find(query, values); }
1,116,802
public Collection find(String query, Object values) { if (logger.isDebugEnabled()) { logger.debug("\n Finding object with query "+query); } if (values instanceof Object[]) { return queryAssembler(query, values).list(); } return this.getHibernateTemplate().find(query, values); }
public Collection find(String query, Object values) { if (logger.isDebugEnabled()) { logger.debug("\n Finding object with query "+query); } if (values instanceof Object[]) { return queryAssembler(query, values).list(); } return this.getHibernateTemplate().find(query, values); }
1,116,803
public Object findUnique(String query, Object values) throws DataAccessException { Collection list = find(query, values); if (logger.isDebugEnabled()) { logger.debug("\n Query result size is "+list.size()); } if (list.size()==1) { Object object = list.toArray()[0]; if (logger.isDebugEnabled()) { logger.debug("\n Unique object "+object+" found"); } return object; } else if(list.size()==0) { if (logger.isDebugEnabled()) { logger.debug("\n Unique object not found"); } return null; } throw new DataIntegrityViolationException("Unique object expected"); }
public Object findUnique(String query, Object values) throws DataAccessException { Collection list = find(query, values); if (logger.isDebugEnabled()) { logger.debug("\n Query result size is "+list.size()); } if (list.size()==1) { Object object = list.toArray()[0]; if (logger.isDebugEnabled()) { logger.debug("\n Unique object "+object+" found"); } return object; } else if(list.size()==0) { if (logger.isDebugEnabled()) { logger.debug("\n Unique object not found"); } return null; } throw new DataIntegrityViolationException("Unique object expected"); }
1,116,804
public Object load(Class clazz, Serializable key) throws DataAccessException { if (logger.isDebugEnabled()) { logger.debug("\n Loading "+clazz.toString() +" with id "+key.toString()); } return this.getHibernateTemplate().load(clazz, key); }
public Object load(Class clazz, Serializable key) throws DataAccessException { if (logger.isDebugEnabled()) { logger.debug("** DAO Loading "+clazz.toString() +" with id "+key.toString()); } return this.getHibernateTemplate().load(clazz, key); }
1,116,805
public void merge(Object object) { if (logger.isDebugEnabled()) { logger.debug("\n Merging "+object.toString()); } this.getHibernateTemplate().merge(object); }
public void merge(Object object) { if (logger.isDebugEnabled()) { logger.debug("** DAO Merging "+object.toString()); } this.getHibernateTemplate().merge(object); }
1,116,806
protected Query queryAssembler(String query, Object values) { try { Session session = getSession(true); Query result = session.createQuery(query); if (values != null) { if (values instanceof Object[]) { Object[] valueList = (Object[]) values; for (int i = 0; i<valueList.length; i++) { result.setParameter(i, valueList[i]); if (logger.isDebugEnabled()) { logger.debug("\n Parameter "+i+"="+valueList[i]); } } } else { result.setParameter(0, values); if (logger.isDebugEnabled()) { logger.debug("\n Single parameter is "+values); } } } else { if (logger.isDebugEnabled()) { logger.debug("\n No parameters"); } } return result; } catch (Exception e) { throw new RuntimeException("Unable to assemble query"); } }
protected Query queryAssembler(String query, Object... values) { try { Session session = getSession(true); Query result = session.createQuery(query); if (values != null) { if (values instanceof Object[]) { Object[] valueList = (Object[]) values; for (int i = 0; i<valueList.length; i++) { result.setParameter(i, valueList[i]); if (logger.isDebugEnabled()) { logger.debug("\n Parameter "+i+"="+valueList[i]); } } } else { result.setParameter(0, values); if (logger.isDebugEnabled()) { logger.debug("\n Single parameter is "+values); } } } else { if (logger.isDebugEnabled()) { logger.debug("\n No parameters"); } } return result; } catch (Exception e) { throw new RuntimeException("Unable to assemble query"); } }
1,116,808
protected Query queryAssembler(String query, Object values) { try { Session session = getSession(true); Query result = session.createQuery(query); if (values != null) { if (values instanceof Object[]) { Object[] valueList = (Object[]) values; for (int i = 0; i<valueList.length; i++) { result.setParameter(i, valueList[i]); if (logger.isDebugEnabled()) { logger.debug("\n Parameter "+i+"="+valueList[i]); } } } else { result.setParameter(0, values); if (logger.isDebugEnabled()) { logger.debug("\n Single parameter is "+values); } } } else { if (logger.isDebugEnabled()) { logger.debug("\n No parameters"); } } return result; } catch (Exception e) { throw new RuntimeException("Unable to assemble query"); } }
protected Query queryAssembler(String query, Object values) { try { Session session = this.getHibernateTemplate().getSessionFactory().getCurrentSession(); Query result = session.createQuery(query); if (values != null) { if (values instanceof Object[]) { Object[] valueList = (Object[]) values; for (int i = 0; i<valueList.length; i++) { result.setParameter(i, valueList[i]); if (logger.isDebugEnabled()) { logger.debug("\n Parameter "+i+"="+valueList[i]); } } } else { result.setParameter(0, values); if (logger.isDebugEnabled()) { logger.debug("\n Single parameter is "+values); } } } else { if (logger.isDebugEnabled()) { logger.debug("\n No parameters"); } } return result; } catch (Exception e) { throw new RuntimeException("Unable to assemble query"); } }
1,116,809
protected Query queryAssembler(String query, Object values) { try { Session session = getSession(true); Query result = session.createQuery(query); if (values != null) { if (values instanceof Object[]) { Object[] valueList = (Object[]) values; for (int i = 0; i<valueList.length; i++) { result.setParameter(i, valueList[i]); if (logger.isDebugEnabled()) { logger.debug("\n Parameter "+i+"="+valueList[i]); } } } else { result.setParameter(0, values); if (logger.isDebugEnabled()) { logger.debug("\n Single parameter is "+values); } } } else { if (logger.isDebugEnabled()) { logger.debug("\n No parameters"); } } return result; } catch (Exception e) { throw new RuntimeException("Unable to assemble query"); } }
protected Query queryAssembler(String query, Object values) { try { Session session = getSession(true); Query result = session.createQuery(query); if (values != null) { if (values instanceof Object[]) { Object[] valueList = (Object[]) values; for (int i = 0; i<valueList.length; i++) { result.setParameter(i, valueList[i]); if (logger.isDebugEnabled()) { logger.debug("\n Parameter "+i+"="+valueList[i]); } } } else { result.setParameter(0, values); if (logger.isDebugEnabled()) { logger.debug("\n Single parameter is "+values); } } } else { if (logger.isDebugEnabled()) { logger.debug("\n No parameters"); } } return result; } catch (Exception e) { throw new RuntimeException("Unable to assemble query"); } }
1,116,810
protected Query queryAssembler(String query, Object values) { try { Session session = getSession(true); Query result = session.createQuery(query); if (values != null) { if (values instanceof Object[]) { Object[] valueList = (Object[]) values; for (int i = 0; i<valueList.length; i++) { result.setParameter(i, valueList[i]); if (logger.isDebugEnabled()) { logger.debug("\n Parameter "+i+"="+valueList[i]); } } } else { result.setParameter(0, values); if (logger.isDebugEnabled()) { logger.debug("\n Single parameter is "+values); } } } else { if (logger.isDebugEnabled()) { logger.debug("\n No parameters"); } } return result; } catch (Exception e) { throw new RuntimeException("Unable to assemble query"); } }
protected Query queryAssembler(String query, Object values) { try { Session session = getSession(true); Query result = session.createQuery(query); if (values != null) { if (values instanceof Object[]) { Object[] valueList = (Object[]) values; for (int i = 0; i<valueList.length; i++) { result.setParameter(i, valueList[i]); if (logger.isDebugEnabled()) { logger.debug("\n Parameter "+i+"="+valueList[i]); } } } else { result.setParameter(0, values); if (logger.isDebugEnabled()) { logger.debug("\n Single parameter is "+values); } } } else { if (logger.isDebugEnabled()) { logger.debug("Parameter "+i+"="+value); } } return result; } catch (Exception e) { throw new RuntimeException("Unable to assemble query"); } }
1,116,811
public void refresh(Object object) throws DataAccessException { if (logger.isDebugEnabled()) { logger.debug("\n Refreshing "+object); } this.getHibernateTemplate().refresh(object); }
public void refresh(Object object) throws DataAccessException { if (logger.isDebugEnabled()) { logger.debug("** DAO Refreshing "+object); } this.getHibernateTemplate().refresh(object); }
1,116,812
public void remove(Object object) { if (object instanceof String) { remove(find(object.toString(), null)); } else if (object instanceof Collection) { Collection collection = (Collection) object; if (logger.isDebugEnabled()) { logger.debug("\n Deleting collection of size "+collection.size()); } this.getHibernateTemplate().deleteAll(collection); } else { if (logger.isDebugEnabled()) { logger.debug("\n Deleting "+object.toString()); } this.getHibernateTemplate().delete(object); } }
public void remove(Object object) { if (object instanceof String) { remove(find(object.toString())); } else if (object instanceof Collection) { Collection collection = (Collection) object; if (logger.isDebugEnabled()) { logger.debug("\n Deleting collection of size "+collection.size()); } this.getHibernateTemplate().deleteAll(collection); } else { if (logger.isDebugEnabled()) { logger.debug("\n Deleting "+object.toString()); } this.getHibernateTemplate().delete(object); } }
1,116,813
public void remove(Object object) { if (object instanceof String) { remove(find(object.toString(), null)); } else if (object instanceof Collection) { Collection collection = (Collection) object; if (logger.isDebugEnabled()) { logger.debug("\n Deleting collection of size "+collection.size()); } this.getHibernateTemplate().deleteAll(collection); } else { if (logger.isDebugEnabled()) { logger.debug("\n Deleting "+object.toString()); } this.getHibernateTemplate().delete(object); } }
public void remove(Object object) { if (object instanceof String) { remove(find(object.toString(), null)); } else if (object instanceof Collection) { Collection collection = (Collection) object; if (logger.isDebugEnabled()) { logger.debug("** DAO Deleting collection of size "+collection.size()); } this.getHibernateTemplate().deleteAll(collection); } else { if (logger.isDebugEnabled()) { logger.debug("\n Deleting "+object.toString()); } this.getHibernateTemplate().delete(object); } }
1,116,814
public void remove(Object object) { if (object instanceof String) { remove(find(object.toString(), null)); } else if (object instanceof Collection) { Collection collection = (Collection) object; if (logger.isDebugEnabled()) { logger.debug("\n Deleting collection of size "+collection.size()); } this.getHibernateTemplate().deleteAll(collection); } else { if (logger.isDebugEnabled()) { logger.debug("\n Deleting "+object.toString()); } this.getHibernateTemplate().delete(object); } }
public void remove(Object object) { if (object instanceof String) { remove(find(object.toString(), null)); } else if (object instanceof Collection) { Collection collection = (Collection) object; if (logger.isDebugEnabled()) { logger.debug("\n Deleting collection of size "+collection.size()); } this.getHibernateTemplate().deleteAll(collection); } else { if (logger.isDebugEnabled()) { logger.debug("** DAO Deleting "+object.toString()); } this.getHibernateTemplate().delete(object); } }
1,116,815
public UserLog createAndPersistUserLog(User user) { if (userLogList==null) { userLogList = new ArrayList<UserLog>(); } UserLog userLog = new UserLog(); userLog.setUser(user); userLog.setLastLogin(lastLogin); userLogList.add(userLog); return userLog; }
public UserLog createAndPersistUserLog(User user) { if (userLogList==null) { userLogList = new ArrayList<UserLog>(); } UserLog userLog = new UserLog(); userLog.setUser(user); userLog.setLastLogin(lastLogin); userLogList.add(userLog); return userLog; }
1,116,816
public UserLog findLastUserLog(String principal) { return null; }
public UserLog findLastUserLog(String principal) { return lastUserLog; }
1,116,817
private boolean isInputValidAndUpdated() { final String localFilename = filenameTF.getText().trim(); if ( localFilename.length() == 0 ) { GUIUtils.showErrorMessage( this, Localizer.getString( "NoFileName" ) ); filenameTF.requestFocus(); return false; } final String researchTerm = researchTermTF.getText().trim(); if ( researchTerm.length() < Cfg.MIN_SEARCH_TERM_LENGTH ) { Object[] objArr = new Object[ 1 ]; objArr[ 0 ] = new Integer( Cfg.MIN_SEARCH_TERM_LENGTH ); GUIUtils.showErrorMessage( this, Localizer.getFormatedString( "MinSearchTerm", objArr ) ); researchTermTF.requestFocus(); return false; } if ( remoteFile != null ) { SwarmingManager.getInstance().addFileToDownload( remoteFile, ServiceManager.sCfg.mDownloadDir + File.separator + FileUtils.convertToLocalSystemFilename( localFilename ), researchTerm ); remoteFile.setInDownloadQueue( true ); } else if ( downloadFile != null ) { if ( !downloadFile.getDestinationFileName().equals( localFilename ) ) { boolean rename = renameOldFileCBx.isSelected(); try { File destFile; destFile = new File( ServiceManager.sCfg.mDownloadDir + File.separator + FileUtils.convertToLocalSystemFilename( localFilename ) ); downloadFile.setDestinationFile( destFile, rename ); } catch ( FileHandlingException exp ) { // setting the new local filename failed. show error if ( exp.getType() == FileHandlingException.FILE_ALREADY_EXISTS ) { Object[] objArr = new Object[ 1 ]; objArr[ 0 ] = localFilename; GUIUtils.showErrorMessage( this, Localizer.getFormatedString( "FileAlreadyExists", objArr ) ); } else if ( exp.getType() == FileHandlingException.RENAME_FAILED ) { GUIUtils.showErrorMessage( this, Localizer.getString( "FileRenameFailed" ) ); } else { exp.printStackTrace(); } } } downloadFile.getResearchSetting().setSearchTerm( researchTerm ); } return true; }
private boolean isInputValidAndUpdated() { final String localFilename = filenameTF.getText().trim(); if ( localFilename.length() == 0 ) { GUIUtils.showErrorMessage( this, Localizer.getString( "NoFileName" ) ); filenameTF.requestFocus(); return false; } final String researchTerm = researchTermTF.getText().trim(); if ( researchTerm.length() < Cfg.MIN_SEARCH_TERM_LENGTH ) { Object[] objArr = new Object[ 1 ]; objArr[ 0 ] = new Integer( Cfg.MIN_SEARCH_TERM_LENGTH ); GUIUtils.showErrorMessage( this, Localizer.getFormatedString( "MinSearchTerm", objArr ) ); researchTermTF.requestFocus(); return false; } if ( remoteFile != null ) { SwarmingManager.getInstance().addFileToDownload( remoteFile, ServiceManager.sCfg.mDownloadDir + File.separator + FileUtils.convertToLocalSystemFilename( localFilename ), researchTerm ); remoteFile.setInDownloadQueue( true ); } else if ( downloadFile != null ) { if ( !downloadFile.getDestinationFileName().equals( localFilename ) ) { boolean rename = renameOldFileCBx.isSelected(); try { File destFile; destFile = new File( ServiceManager.sCfg.mDownloadDir + File.separator + FileUtils.convertToLocalSystemFilename( localFilename ) ); downloadFile.setDestinationFile( destFile, rename ); } catch ( FileHandlingException exp ) { // setting the new local filename failed. show error if ( exp.getType() == FileHandlingException.FILE_ALREADY_EXISTS ) { Object[] objArr = new Object[ 1 ]; objArr[ 0 ] = localFilename; GUIUtils.showErrorMessage( this, Localizer.getFormatedString( "FileAlreadyExists", objArr ) ); } else { NLogger.error( DownloadConfigDialog.class, exp ); } } catch ( ManagedFileException exp ) { if ( exp.getCause() instanceof FileHandlingException && ((FileHandlingException)exp.getCause()).getType() == FileHandlingException.RENAME_FAILED ) { GUIUtils.showErrorMessage( this, Localizer.getString( "FileRenameFailed" ) ); } else { exp.printStackTrace(); } } } downloadFile.getResearchSetting().setSearchTerm( researchTerm ); } return true; }
1,116,819
private boolean isInputValidAndUpdated() { final String localFilename = filenameTF.getText().trim(); if ( localFilename.length() == 0 ) { GUIUtils.showErrorMessage( this, Localizer.getString( "NoFileName" ) ); filenameTF.requestFocus(); return false; } final String researchTerm = researchTermTF.getText().trim(); if ( researchTerm.length() < Cfg.MIN_SEARCH_TERM_LENGTH ) { Object[] objArr = new Object[ 1 ]; objArr[ 0 ] = new Integer( Cfg.MIN_SEARCH_TERM_LENGTH ); GUIUtils.showErrorMessage( this, Localizer.getFormatedString( "MinSearchTerm", objArr ) ); researchTermTF.requestFocus(); return false; } if ( remoteFile != null ) { SwarmingManager.getInstance().addFileToDownload( remoteFile, ServiceManager.sCfg.mDownloadDir + File.separator + FileUtils.convertToLocalSystemFilename( localFilename ), researchTerm ); remoteFile.setInDownloadQueue( true ); } else if ( downloadFile != null ) { if ( !downloadFile.getDestinationFileName().equals( localFilename ) ) { boolean rename = renameOldFileCBx.isSelected(); try { File destFile; destFile = new File( ServiceManager.sCfg.mDownloadDir + File.separator + FileUtils.convertToLocalSystemFilename( localFilename ) ); downloadFile.setDestinationFile( destFile, rename ); } catch ( FileHandlingException exp ) { // setting the new local filename failed. show error if ( exp.getType() == FileHandlingException.FILE_ALREADY_EXISTS ) { Object[] objArr = new Object[ 1 ]; objArr[ 0 ] = localFilename; GUIUtils.showErrorMessage( this, Localizer.getFormatedString( "FileAlreadyExists", objArr ) ); } else if ( exp.getType() == FileHandlingException.RENAME_FAILED ) { GUIUtils.showErrorMessage( this, Localizer.getString( "FileRenameFailed" ) ); } else { exp.printStackTrace(); } } } downloadFile.getResearchSetting().setSearchTerm( researchTerm ); } return true; }
private boolean isInputValidAndUpdated() { final String localFilename = filenameTF.getText().trim(); if ( localFilename.length() == 0 ) { GUIUtils.showErrorMessage( this, Localizer.getString( "NoFileName" ) ); filenameTF.requestFocus(); return false; } final String researchTerm = researchTermTF.getText().trim(); if ( researchTerm.length() < Cfg.MIN_SEARCH_TERM_LENGTH ) { Object[] objArr = new Object[ 1 ]; objArr[ 0 ] = new Integer( Cfg.MIN_SEARCH_TERM_LENGTH ); GUIUtils.showErrorMessage( this, Localizer.getFormatedString( "MinSearchTerm", objArr ) ); researchTermTF.requestFocus(); return false; } if ( remoteFile != null ) { SwarmingManager.getInstance().addFileToDownload( remoteFile, ServiceManager.sCfg.mDownloadDir + File.separator + FileUtils.convertToLocalSystemFilename( localFilename ), researchTerm ); remoteFile.setInDownloadQueue( true ); } else if ( downloadFile != null ) { if ( !downloadFile.getDestinationFileName().equals( localFilename ) ) { boolean rename = renameOldFileCBx.isSelected(); try { File destFile; destFile = new File( ServiceManager.sCfg.mDownloadDir + File.separator + FileUtils.convertToLocalSystemFilename( localFilename ) ); downloadFile.setDestinationFile( destFile, rename ); } catch ( FileHandlingException exp ) { // setting the new local filename failed. show error if ( exp.getType() == FileHandlingException.FILE_ALREADY_EXISTS ) { Object[] objArr = new Object[ 1 ]; objArr[ 0 ] = localFilename; GUIUtils.showErrorMessage( this, Localizer.getFormatedString( "FileAlreadyExists", objArr ) ); } else if ( exp.getType() == FileHandlingException.RENAME_FAILED ) { GUIUtils.showErrorMessage( this, Localizer.getString( "FileRenameFailed" ) ); } else { NLogger.error( DownloadConfigDialog.class, exp ); } } } downloadFile.getResearchSetting().setSearchTerm( researchTerm ); } return true; }
1,116,820
public Node differentiate(ASTFunNode node,String var,Node [] children,Node [] dchildren,DJep djep) throws ParseException { OperatorSet op = djep.getOperatorSet(); NodeFactory nf = djep.getNodeFactory(); int nchild = node.jjtGetNumChildren(); if(nchild==2) return nf.buildOperatorNode(op.getAdd(), nf.buildOperatorNode(op.getMultiply(), dchildren[0], djep.deepCopy(children[1])), nf.buildOperatorNode(op.getMultiply(), djep.deepCopy(children[0]), dchildren[1])); else throw new ParseException("Too many children "+nchild+" for "+node+"\n"); }
public Node differentiate(ASTFunNode node,String var,Node [] children,Node [] dchildren,DJep djep) throws ParseException { OperatorSet opset = djep.getOperatorSet(); NodeFactory nf = djep.getNodeFactory(); int nchild = node.jjtGetNumChildren(); if(nchild==2) return nf.buildOperatorNode(op.getAdd(), nf.buildOperatorNode(op.getMultiply(), dchildren[0], djep.deepCopy(children[1])), nf.buildOperatorNode(op.getMultiply(), djep.deepCopy(children[0]), dchildren[1])); else throw new ParseException("Too many children "+nchild+" for "+node+"\n"); }
1,116,821
public Node differentiate(ASTFunNode node,String var,Node [] children,Node [] dchildren,DJep djep) throws ParseException { OperatorSet op = djep.getOperatorSet(); NodeFactory nf = djep.getNodeFactory(); int nchild = node.jjtGetNumChildren(); if(nchild==2) return nf.buildOperatorNode(op.getAdd(), nf.buildOperatorNode(op.getMultiply(), dchildren[0], djep.deepCopy(children[1])), nf.buildOperatorNode(op.getMultiply(), djep.deepCopy(children[0]), dchildren[1])); else throw new ParseException("Too many children "+nchild+" for "+node+"\n"); }
public Node differentiate(ASTFunNode node,String var,Node [] children,Node [] dchildren,DJep djep) throws ParseException { OperatorSet op = djep.getOperatorSet(); NodeFactory nf = djep.getNodeFactory(); int nchild = node.jjtGetNumChildren(); if(nchild==2) return nf.buildOperatorNode(op.getAdd(), nf.buildOperatorNode(op.getMultiply(), dchildren[0], djep.deepCopy(children[1])), nf.buildOperatorNode(op.getMultiply(), djep.deepCopy(children[0]), dchildren[1])); else throw new ParseException("Too many children "+nchild+" for "+node+"\n"); }
1,116,823
public Node differentiate(ASTFunNode node,String var,Node [] children,Node [] dchildren,DJep djep) throws ParseException { OperatorSet op = djep.getOperatorSet(); NodeFactory nf = djep.getNodeFactory(); int nchild = node.jjtGetNumChildren(); if(nchild==2) return nf.buildOperatorNode(op.getAdd(), nf.buildOperatorNode(op.getMultiply(), dchildren[0], djep.deepCopy(children[1])), nf.buildOperatorNode(op.getMultiply(), djep.deepCopy(children[0]), dchildren[1])); else throw new ParseException("Too many children "+nchild+" for "+node+"\n"); }
public Node differentiate(ASTFunNode node,String var,Node [] children,Node [] dchildren,DJep djep) throws ParseException { OperatorSet op = djep.getOperatorSet(); NodeFactory nf = djep.getNodeFactory(); int nchild = node.jjtGetNumChildren(); if(nchild==2) return nf.buildOperatorNode(op.getAdd(), nf.buildOperatorNode(op, dchildren[0], djep.deepCopy(children[1])), nf.buildOperatorNode(op, djep.deepCopy(children[0]), dchildren[1])); else throw new ParseException("Too many children "+nchild+" for "+node+"\n"); }
1,116,824
public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals("preferredWidth")) { TableColumnModel tcm = tblHops.getColumnModel(); TableColumnModel tcmt = tblHopsTotals.getColumnModel(); int columnCount = tcm.getColumnCount(); // for each column, get its width for (int i = 0; i < columnCount; i++) { tcmt.getColumn(i).setPreferredWidth(tcm.getColumn(i).getPreferredWidth()); } } }
public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals("preferredWidth")) { TableColumnModel tcm = tblHops.getColumnModel(); TableColumnModel tcmt = tblHopsTotals.getColumnModel(); int columnCount = tcm.getColumnCount(); // for each column, get its width for (int i = 0; i < columnCount; i++) { tcmt.getColumn(i).setPreferredWidth(tcm.getColumn(i).getPreferredWidth()); } } }
1,116,826
private void initGUI() { try { this.setSize(520, 532); this.addWindowListener(new WindowAdapter() { public void windowClosed(WindowEvent evt) { System.exit(1); } }); { pnlMain = new JPanel(); GridBagLayout jPanel2Layout = new GridBagLayout(); jPanel2Layout.columnWeights = new double[] {0.1,0.1}; jPanel2Layout.columnWidths = new int[] {7,7}; jPanel2Layout.rowWeights = new double[] {0.1,0.1,0.9,0.1}; jPanel2Layout.rowHeights = new int[] {7,7,7,7}; pnlMain.setLayout(jPanel2Layout); this.getContentPane().add(pnlMain, BorderLayout.CENTER); { jPanel1 = new JPanel(); pnlMain.add(jPanel1, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); FlowLayout jPanel1Layout = new FlowLayout(); jPanel1Layout.setAlignment(FlowLayout.LEFT); jPanel1.setLayout(jPanel1Layout); { lblName = new JLabel(); jPanel1.add(lblName); lblName.setText("Name:"); } { txtName = new JTextField(); jPanel1.add(txtName); txtName.setText("Name"); txtName.setPreferredSize(new java.awt.Dimension(179, 20)); txtName.addActionListener(this); txtName.addFocusListener(this); } } { jTabbedPane1 = new JTabbedPane(); pnlMain.add(jTabbedPane1, new GridBagConstraints(0, 1, 1, 1, 0.1, 0.1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); { pnlDetails = new JPanel(); GridBagLayout pnlDetailsLayout = new GridBagLayout(); pnlDetailsLayout.columnWeights = new double[] {0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1}; pnlDetailsLayout.columnWidths = new int[] {7,7,7,7,7,7,7,7,7,7}; pnlDetailsLayout.rowWeights = new double[] {0.1,0.1,0.1,0.1,0.1,0.1,0.1}; pnlDetailsLayout.rowHeights = new int[] {7,7,7,7,7,7,7}; pnlDetails.setLayout(pnlDetailsLayout); jTabbedPane1.addTab("Details", null, pnlDetails, null); pnlDetails.setPreferredSize(new java.awt.Dimension(20, 16)); { lblBrewer = new JLabel(); pnlDetails.add(lblBrewer, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblBrewer.setText("Brewer:"); } { txtBrewer = new JTextField(); pnlDetails.add(txtBrewer, new GridBagConstraints( 1, 0, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); txtBrewer.addFocusListener(this); txtBrewer.addActionListener(this); txtBrewer.setText("Brewer"); } { lblDate = new JLabel(); pnlDetails.add(lblDate, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblDate.setText("Date:"); } { lblStyle = new JLabel(); pnlDetails.add(lblStyle, new GridBagConstraints( 0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblStyle.setText("Style:"); } { lblYeast = new JLabel(); pnlDetails.add(lblYeast, new GridBagConstraints( 0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblYeast.setText("Yeast:"); } { lblPreBoil = new JLabel(); pnlDetails.add(lblPreBoil, new GridBagConstraints( 0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblPreBoil.setText("Pre boil:"); } { lblPostBoil = new JLabel(); pnlDetails.add(lblPostBoil, new GridBagConstraints( 0, 5, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblPostBoil.setText("Post boil:"); } { lblEffic = new JLabel(); pnlDetails.add(lblEffic, new GridBagConstraints( 3, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblEffic.setText("Effic:"); } { lblAtten = new JLabel(); pnlDetails.add(lblAtten, new GridBagConstraints( 3, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblAtten.setText("Atten:"); } { lblOG = new JLabel(); pnlDetails.add(lblOG, new GridBagConstraints( 5, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblOG.setText("OG:"); } { lblFG = new JLabel(); pnlDetails.add(lblFG, new GridBagConstraints( 5, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblFG.setText("FG:"); } { lblIBU = new JLabel(); pnlDetails.add(lblIBU, new GridBagConstraints( 7, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblIBU.setText("IBU:"); } { lblAlc = new JLabel(); pnlDetails.add(lblAlc, new GridBagConstraints( 7, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblAlc.setText("%Alc:"); } { lblColour = new JLabel(); pnlDetails.add(lblColour, new GridBagConstraints( 7, 2, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblColour.setText("Colour:"); } { txtDate = new JFormattedTextField(); pnlDetails.add(txtDate, new GridBagConstraints( 1, 1, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); txtDate.setText("Date"); txtDate.addFocusListener(this); txtDate.addActionListener(this); } { cmbStyleModel = new ComboModel(); cmbStyle = new JComboBox(); pnlDetails.add(cmbStyle, new GridBagConstraints( 1, 2, 5, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); cmbStyle.setModel(cmbStyleModel); cmbStyle.setMaximumSize(new java.awt.Dimension(100, 32767)); cmbStyle.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { Style s = (Style) cmbStyleModel.getSelectedItem(); if (myRecipe != null && s != myRecipe.getStyleObj()) { myRecipe.setStyle(s); } descriptionTextArea.setText(s.getDescription()); cmbStyle.setToolTipText(multiLineToolTip(50,s.getDescription())); } }); } { txtPreBoil = new JFormattedTextField(); pnlDetails.add(txtPreBoil, new GridBagConstraints( 1, 4, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); txtPreBoil.setText("Pre Boil"); txtPreBoil.addFocusListener(this); txtPreBoil.addActionListener(this); } { postBoilText = new JFormattedTextField(); pnlDetails.add(postBoilText, new GridBagConstraints( 1, 5, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); postBoilText.setText("Post Boil"); postBoilText.addFocusListener(new FocusAdapter() { public void focusLost(FocusEvent evt) { myRecipe.setPostBoil(Double.parseDouble(postBoilText.getText() .toString())); displayRecipe(); } }); postBoilText.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { myRecipe.setPostBoil(Double.parseDouble(postBoilText.getText() .toString())); displayRecipe(); } }); } { lblComments = new JLabel(); pnlDetails.add(lblComments, new GridBagConstraints( 6, 3, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblComments.setText("Comments:"); } { SpinnerNumberModel spnEfficModel = new SpinnerNumberModel(75.0, 0.0, 100.0, 1.0); spnEffic = new JSpinner(); pnlDetails.add(spnEffic, new GridBagConstraints( 4, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); spnEffic.setModel(spnEfficModel); spnEffic.setMaximumSize(new java.awt.Dimension(70, 32767)); spnEffic.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent evt) { myRecipe.setEfficiency(Double.parseDouble(spnEffic.getValue() .toString())); displayRecipe(); } }); spnEffic.setEditor(new JSpinner.NumberEditor(spnEffic, "00.#")); spnEffic.getEditor().setPreferredSize(new java.awt.Dimension(28, 16)); } { SpinnerNumberModel spnAttenModel = new SpinnerNumberModel(75.0, 0.0, 100.0, 1.0); spnAtten = new JSpinner(); pnlDetails.add(spnAtten, new GridBagConstraints( 4, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); spnAtten.setModel(spnAttenModel); spnAtten.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent evt) { myRecipe.setAttenuation(Double.parseDouble(spnAtten.getValue() .toString())); displayRecipe(); } }); spnAtten.setEditor(new JSpinner.NumberEditor(spnAtten, "00.#")); } { SpinnerNumberModel spnOgModel = new SpinnerNumberModel(1.000, 0.900, 2.000, 0.001); spnOG = new JSpinner(); pnlDetails.add(spnOG, new GridBagConstraints( 6, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); spnOG.setModel(spnOgModel); spnOG.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent evt) { myRecipe.setEstOg(Double.parseDouble(spnOG.getValue() .toString())); displayRecipe(); } }); spnOG.setEditor(new JSpinner.NumberEditor(spnOG, "0.000")); spnOG.getEditor().setPreferredSize(new java.awt.Dimension(20, 16)); } { SpinnerNumberModel spnFgModel = new SpinnerNumberModel(1.000, 0.900, 2.000, 0.001); spnFG = new JSpinner(); pnlDetails.add(spnFG, new GridBagConstraints( 6, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); spnFG.setModel(spnFgModel); spnFG.setEditor(new JSpinner.NumberEditor(spnFG, "0.000")); spnFG.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent evt) { // set the new FG, and update alc: myRecipe.setEstFg(Double.parseDouble(spnFG.getValue() .toString())); displayRecipe(); } }); } { lblIBUvalue = new JLabel(); pnlDetails.add(lblIBUvalue, new GridBagConstraints( 8, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblIBUvalue.setText("IBUs"); } { lblColourValue = new JLabel(); pnlDetails.add(lblColourValue, new GridBagConstraints( 8, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblColourValue.setText("Colour"); } { lblAlcValue = new JLabel(); pnlDetails.add(lblAlcValue, new GridBagConstraints( 8, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblAlcValue.setText("Alc"); } { scpComments = new JScrollPane(); pnlDetails.add(scpComments, new GridBagConstraints( 6, 4, 3, 2, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); { txtComments = new JTextArea(); scpComments.setViewportView(txtComments); txtComments.setText("Comments"); txtComments.setWrapStyleWord(true); txtComments.setPreferredSize(new java.awt.Dimension(117, 42)); txtComments.addFocusListener(new FocusAdapter() { public void focusLost(FocusEvent evt) { if (!txtComments.getText().equals(myRecipe.getComments())) { myRecipe.setComments(txtComments.getText()); } } }); } } { cmbYeastModel = new ComboModel(); cmbYeast = new JComboBox(); pnlDetails.add(cmbYeast, new GridBagConstraints( 1, 3, 5, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); cmbYeast.setModel(cmbYeastModel); cmbYeast.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { Yeast y = (Yeast) cmbYeastModel.getSelectedItem(); if (myRecipe != null && y != myRecipe.getYeastObj()) { myRecipe.setYeast(y); } cmbYeast.setToolTipText(multiLineToolTip(40,y.getDescription())); } }); } { cmbSizeUnitsModel = new ComboModel(); cmbSizeUnits = new JComboBox(); pnlDetails.add(cmbSizeUnits, new GridBagConstraints( 2, 4, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); cmbSizeUnits.setModel(cmbSizeUnitsModel); cmbSizeUnits.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { String q = (String) cmbSizeUnits.getSelectedItem(); if (myRecipe != null && q != myRecipe.getVolUnits()) { myRecipe.setPostBoilVolUnits(q); displayRecipe(); } } }); } { lblSizeUnits = new JLabel(); pnlDetails.add(lblSizeUnits, new GridBagConstraints( 2, 5, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); lblSizeUnits.setText("Size Units"); } { boilTimeLable = new JLabel(); pnlDetails.add(boilTimeLable, new GridBagConstraints( 4, 4, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); boilTimeLable.setText("Boil Min:"); } { evapLabel = new JLabel(); pnlDetails.add(evapLabel, new GridBagConstraints( 4, 5, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); evapLabel.setText("Evap/hr:"); } { boilMinText = new JTextField(); pnlDetails.add(boilMinText, new GridBagConstraints( 5, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); boilMinText.setText("60"); boilMinText.addFocusListener(this); boilMinText.addActionListener(this); } { evapText = new JTextField(); pnlDetails.add(evapText, new GridBagConstraints( 5, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); evapText.setText("4"); evapText.addFocusListener(this); evapText.addActionListener(this); } } { pnlStyle = new JPanel(); FlowLayout pnlStyleLayout = new FlowLayout(); pnlStyle.setLayout(pnlStyleLayout); jTabbedPane1.addTab("Style", null, pnlStyle, null); { lblStyle2 = new JLabel(); pnlStyle.add(lblStyle2); lblStyle2.setText("Style:"); } { ComboBoxModel cmbStyle2Model = new DefaultComboBoxModel(new String[]{ "Item One", "Item Two"}); cmbStyle2 = new JComboBox(); pnlStyle.add(cmbStyle2); cmbStyle2.setModel(cmbStyle2Model); } { jPanel2 = new JPanel(); GridBagLayout jPanel2Layout1 = new GridBagLayout(); jPanel2Layout1.columnWeights = new double[]{0.1, 0.1, 0.1, 0.1}; jPanel2Layout1.columnWidths = new int[]{7, 7, 7, 7}; jPanel2Layout1.rowWeights = new double[]{0.1, 0.1, 0.1, 0.1, 0.1, 0.1}; jPanel2Layout1.rowHeights = new int[]{7, 7, 7, 7, 7, 7}; jPanel2.setPreferredSize(new java.awt.Dimension(179, 120)); jPanel2.setLayout(jPanel2Layout1); pnlStyle.add(jPanel2); jPanel2.setBorder(BorderFactory.createTitledBorder(new LineBorder( new java.awt.Color(0, 0, 0), 1, false), "Recipe Conformance:", TitledBorder.LEADING, TitledBorder.TOP, new java.awt.Font( "Dialog", 0, 12), new java.awt.Color(0, 0, 0))); { jLabel5 = new JLabel(); jPanel2.add(jLabel5, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel5.setText("OG:"); jLabel5.setBounds(74, 3, 60, 30); } { jLabel1 = new JLabel(); jPanel2.add(jLabel1, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); GridLayout jLabel1Layout = new GridLayout(1, 1); jLabel1.setLayout(jLabel1Layout); jLabel1.setText("Low:"); } { jLabel2 = new JLabel(); jPanel2.add(jLabel2, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel2.setText("Recipe:"); } { jLabel3 = new JLabel(); jPanel2.add(jLabel3, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel3.setText("High:"); } { jLabel4 = new JLabel(); jPanel2.add(jLabel4, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel4.setText("IBU:"); } { jLabel6 = new JLabel(); jPanel2.add(jLabel6, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel6.setText("Colour:"); } { jLabel7 = new JLabel(); jPanel2.add(jLabel7, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel7.setText("ABV:"); } } { jScrollPane3 = new JScrollPane(); pnlStyle.add(jScrollPane3); { txaStyles = new JTextArea(); jScrollPane3.setViewportView(txaStyles); txaStyles.setText("Matched Styles"); } } { sldMatch = new JSlider(); pnlStyle.add(sldMatch); } } { miscPanel = new MiscPanel(myRecipe); jTabbedPane1.addTab("Misc", null, miscPanel, null); } { notesPanel = new NotesPanel(); jTabbedPane1.addTab("Notes", null, notesPanel, null); } } { pnlTables = new JPanel(); BoxLayout pnlMaltsLayout = new BoxLayout(pnlTables, javax.swing.BoxLayout.Y_AXIS); pnlMain.add(pnlTables, new GridBagConstraints(0, 2, 1, 1, 0.5, 0.5, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); pnlTables.setLayout(pnlMaltsLayout); { pnlMalt = new JPanel(); pnlTables.add(pnlMalt); BorderLayout pnlMaltLayout1 = new BorderLayout(); FlowLayout pnlMaltLayout = new FlowLayout(); pnlMalt.setBorder(BorderFactory.createTitledBorder(new LineBorder( new java.awt.Color(0, 0, 0), 1, false), "Fermentables", TitledBorder.LEADING, TitledBorder.TOP, new java.awt.Font("Dialog", 1, 12), new java.awt.Color(51, 51, 51))); pnlMalt.setLayout(pnlMaltLayout1); { jScrollPane1 = new JScrollPane(); pnlMalt.add(jScrollPane1, BorderLayout.CENTER); { tblMaltModel = new MaltTableModel(this); tblMalt = new JTable(){ public String getToolTipText(MouseEvent e) { String tip = null; java.awt.Point p = e.getPoint(); int rowIndex = rowAtPoint(p); tip = multiLineToolTip(40,tblMaltModel.getDescriptionAt(rowIndex)); return tip; } }; jScrollPane1.setViewportView(tblMalt); tblMalt.setModel(tblMaltModel); tblMalt.setAutoCreateColumnsFromModel(false); tblMalt.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { int i = tblMalt.getSelectedRow(); // descriptionTextArea.setText(myRecipe.getMaltDescription(i)); } }); TableColumn maltColumn = tblMalt.getColumnModel().getColumn(0); // set up malt list combo JComboBox maltComboBox = new JComboBox(); cmbMaltModel = new ComboModel(); maltComboBox.setModel(cmbMaltModel); maltColumn.setCellEditor(new DefaultCellEditor(maltComboBox)); maltComboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { Fermentable f = (Fermentable) cmbMaltModel .getSelectedItem(); int i = tblMalt.getSelectedRow(); if (myRecipe != null && i != -1) { Fermentable f2 = myRecipe.getFermentable(i); f2.setLov(f.getLov()); f2.setPppg(f.getPppg()); f2.setDescription(f.getDescription()); f2.setMashed(f.getMashed()); f2.setSteep(f.getSteep()); } } }); // set up malt units combo JComboBox maltUnitsComboBox = new JComboBox(); cmbMaltUnitsModel = new ComboModel(); maltUnitsComboBox.setModel(cmbMaltUnitsModel); maltColumn = tblMalt.getColumnModel().getColumn(2); maltColumn.setCellEditor(new DefaultCellEditor(maltUnitsComboBox)); maltUnitsComboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { String u = (String) cmbMaltUnitsModel.getSelectedItem(); int i = tblMalt.getSelectedRow(); if (myRecipe != null && i != -1) { Fermentable f2 = myRecipe.getFermentable(i); f2.setUnitsFull(u); myRecipe.calcMaltTotals(); displayRecipe(); } } }); } } { tblMaltTotalsModel = new DefaultTableModel(new String[][]{{""}}, new String[]{"Malt", "Amount", "Units", "Points", "Lov", "Cost/U", "%"}); tblMaltTotals = new JTable(); pnlMalt.add(tblMaltTotals, BorderLayout.SOUTH); tblMaltTotals.setModel(tblMaltTotalsModel); tblMaltTotals.getTableHeader().setEnabled(false); tblMaltTotals.setAutoCreateColumnsFromModel(false); } } { pnlMaltButtons = new JPanel(); pnlTables.add(pnlMaltButtons); FlowLayout pnlMaltButtonsLayout = new FlowLayout(); pnlMaltButtonsLayout.setAlignment(FlowLayout.LEFT); pnlMaltButtonsLayout.setVgap(0); pnlMaltButtons.setLayout(pnlMaltButtonsLayout); pnlMaltButtons.setPreferredSize(new java.awt.Dimension(390, 34)); { tlbMalt = new JToolBar(); pnlMaltButtons.add(tlbMalt); tlbMalt.setPreferredSize(new java.awt.Dimension(140, 20)); tlbMalt.setFloatable(false); { btnAddMalt = new JButton(); tlbMalt.add(btnAddMalt); btnAddMalt.setText("+"); btnAddMalt.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (myRecipe != null) { Fermentable f = new Fermentable(myRecipe.getMaltUnits()); myRecipe.addMalt(f); tblMalt.updateUI(); displayRecipe(); } } }); } { btnDelMalt = new JButton(); tlbMalt.add(btnDelMalt); btnDelMalt.setText("-"); btnDelMalt.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (myRecipe != null) { int i = tblMalt.getSelectedRow(); myRecipe.delMalt(i); tblMalt.updateUI(); displayRecipe(); } } }); } } } { pnlHops = new JPanel(); BorderLayout pnlHopsLayout = new BorderLayout(); pnlHops.setBorder(BorderFactory.createTitledBorder(new LineBorder( new java.awt.Color(0, 0, 0), 1, false), "Hops", TitledBorder.LEADING, TitledBorder.TOP, new java.awt.Font("Dialog", 1, 12), new java.awt.Color(51, 51, 51))); pnlHops.setLayout(pnlHopsLayout); pnlTables.add(pnlHops); { tblHopsTotalsModel = new DefaultTableModel(new String[][]{{""}}, new String[]{"1", "2","3","4","5","6","7","8","9"}); tblHopsTotals = new JTable(); pnlHops.add(tblHopsTotals, BorderLayout.SOUTH); tblHopsTotals.setModel(tblHopsTotalsModel); tblHopsTotals.setAutoCreateColumnsFromModel(false); } { jScrollPane2 = new JScrollPane(); pnlHops.add(jScrollPane2, BorderLayout.CENTER); { tblHopsModel = new HopsTableModel(this); tblHops = new JTable(); jScrollPane2.setViewportView(tblHops); tblHops.setModel(tblHopsModel); tblHops.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { int i = tblHops.getSelectedRow(); descriptionTextArea.setText(myRecipe.getHopDescription(i)); } }); TableColumn hopColumn = tblHops.getColumnModel().getColumn(0); JComboBox hopComboBox = new JComboBox(); cmbHopsModel = new ComboModel(); hopComboBox.setModel(cmbHopsModel); hopColumn.setCellEditor(new DefaultCellEditor(hopComboBox)); hopComboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { Hop h = (Hop) cmbHopsModel.getSelectedItem(); int i = tblHops.getSelectedRow(); if (myRecipe != null && i != -1) { Hop h2 = (Hop) myRecipe.getHop(i); h2.setAlpha(h.getAlpha()); h2.setDescription(h.getDescription()); } } }); // set up hop units combo JComboBox hopsUnitsComboBox = new JComboBox(); cmbHopsUnitsModel = new ComboModel(); hopsUnitsComboBox.setModel(cmbHopsUnitsModel); hopColumn = tblHops.getColumnModel().getColumn(4); hopColumn.setCellEditor(new DefaultCellEditor(hopsUnitsComboBox)); hopsUnitsComboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { String u = (String) cmbHopsUnitsModel.getSelectedItem(); int i = tblHops.getSelectedRow(); if (myRecipe != null && i != -1) { Hop h = (Hop) myRecipe.getHop(i); h.setUnitsFull(u); myRecipe.calcHopsTotals(); // tblHops.updateUI(); displayRecipe(); } } }); // set up hop type combo String [] forms = {"Leaf","Pellet","Plug"}; JComboBox hopsFormComboBox = new JComboBox(forms); hopColumn = tblHops.getColumnModel().getColumn(1); hopColumn.setCellEditor(new DefaultCellEditor(hopsFormComboBox)); // set up hop add combo String [] add = {"Boil","FWH","Dry", "Mash"}; JComboBox hopsAddComboBox = new JComboBox(add); hopColumn = tblHops.getColumnModel().getColumn(5); hopColumn.setCellEditor(new DefaultCellEditor(hopsAddComboBox)); } } } { pnlHopsButtons = new JPanel(); FlowLayout pnlHopsButtonsLayout = new FlowLayout(); pnlHopsButtonsLayout.setAlignment(FlowLayout.LEFT); pnlHopsButtonsLayout.setVgap(0); pnlHopsButtons.setLayout(pnlHopsButtonsLayout); pnlTables.add(pnlHopsButtons); pnlHopsButtons.setPreferredSize(new java.awt.Dimension(512, 16)); { tlbHops = new JToolBar(); pnlHopsButtons.add(tlbHops); tlbHops.setPreferredSize(new java.awt.Dimension(70, 19)); tlbHops.setFloatable(false); { btnAddHop = new JButton(); tlbHops.add(btnAddHop); btnAddHop.setText("+"); btnAddHop.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (myRecipe != null) { Hop h = new Hop(myRecipe.getHopUnits()); myRecipe.addHop(h); tblHops.updateUI(); displayRecipe(); } } }); } { btnDelHop = new JButton(); tlbHops.add(btnDelHop); btnDelHop.setText("-"); btnDelHop.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (myRecipe != null) { int i = tblHops.getSelectedRow(); myRecipe.delHop(i); tblHops.updateUI(); displayRecipe(); } } }); } } } } { descriptionPanel = new JPanel(); FlowLayout descriptionPanelLayout = new FlowLayout(); descriptionPanel.setLayout(descriptionPanelLayout); pnlMain.add(descriptionPanel, new GridBagConstraints( 1, 0, 1, 3, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.VERTICAL, new Insets(0, 0, 0, 0), 0, 0)); descriptionPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); { descriptionTextArea = new JTextArea(); descriptionPanel.add(descriptionTextArea); descriptionTextArea.setText("Description"); descriptionTextArea.setFont(new java.awt.Font("Dialog", 0, 10)); descriptionTextArea.setEditable(false); descriptionTextArea.setFocusable(false); descriptionTextArea.setLineWrap(true); descriptionTextArea.setWrapStyleWord(true); } } { statusPanel = new JPanel(); FlowLayout statusPanelLayout = new FlowLayout(); statusPanelLayout.setAlignment(FlowLayout.LEFT); statusPanel.setLayout(statusPanelLayout); pnlMain.add(statusPanel, new GridBagConstraints( 0, 3, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); statusPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); { fileNameLabel = new JLabel(); statusPanel.add(fileNameLabel); fileNameLabel.setText("File Name"); fileNameLabel.setFont(new java.awt.Font("Dialog",1,10)); } } } { jMenuBar1 = new JMenuBar(); setJMenuBar(jMenuBar1); { jMenu3 = new JMenu(); jMenuBar1.add(jMenu3); jMenu3.setText("File"); { newFileMenuItem = new JMenuItem(); jMenu3.add(newFileMenuItem); newFileMenuItem.setText("New"); newFileMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // This is just a test right now to see that // stuff is changed. myRecipe = new Recipe(); attachRecipeData(); displayRecipe(); } }); } { openFileMenuItem = new JMenuItem(); jMenu3.add(openFileMenuItem); openFileMenuItem.setText("Open"); openFileMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // Show open dialog; this method does // not return until the dialog is closed int returnVal = fileChooser.showOpenDialog(jMenuBar1); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); System.out.print("Opening: " + file.getName() + ".\n"); ImportXml imp = new ImportXml(file.toString()); myRecipe = imp.handler.getRecipe(); myRecipe.calcMaltTotals(); myRecipe.calcHopsTotals(); myRecipe.mash.calcMashSchedule(); attachRecipeData(); displayRecipe(); // show true file name fileName = file.getName(); fileNameLabel.setText(fileName); } else { System.out.print("Open command cancelled by user.\n"); } } }); } { saveMenuItem = new JMenuItem(); jMenu3.add(saveMenuItem); saveMenuItem.setText("Save"); } { saveAsMenuItem = new JMenuItem(); jMenu3.add(saveAsMenuItem); saveAsMenuItem.setText("Save As ..."); saveAsMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (DEBUG){ // This is just a test right now to see that // stuff is changed. System.out.print(myRecipe.toXML()); } // Show save dialog; this method does // not return until the dialog is closed int returnVal = fileChooser.showSaveDialog(jMenuBar1); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); //This is where a real application would save the file. try { FileWriter out = new FileWriter(file); out.write(myRecipe.toXML()); out.close(); } catch (Exception e){ // TODO: handle io exception } } else { System.out.print("Save command cancelled by user.\n"); } } }); } { exportMenu = new JMenu(); jMenu3.add(exportMenu); exportMenu.setText("Export"); { exportHTMLmenu = new JMenuItem(); exportMenu.add(exportHTMLmenu); exportHTMLmenu.setText("HTML"); exportHTMLmenu.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // Show save dialog; this method does // not return until the dialog is closed fileChooser.setSelectedFile(new File(myRecipe.getName()+".html")); int returnVal = fileChooser.showSaveDialog(jMenuBar1); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); //This is where a real application would save the file. try { saveAsHTML(file); } catch (Exception e){ // TODO: handle io exception } } else { System.out.print("Save command cancelled by user.\n"); } } }); exportTextMenuItem = new JMenuItem(); exportMenu.add(exportTextMenuItem); exportTextMenuItem.setText("Text"); exportTextMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // Show save dialog; this method does // not return until the dialog is closed fileChooser.setSelectedFile(new File(myRecipe.getName()+".txt")); int returnVal = fileChooser.showSaveDialog(jMenuBar1); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); //This is where a real application would save the file. try { FileWriter out = new FileWriter(file); out.write(myRecipe.toText()); out.close(); } catch (Exception e){ // TODO: handle io exception } } else { System.out.print("Export text command cancelled by user.\n"); } } }); } } { jSeparator2 = new JSeparator(); jMenu3.add(jSeparator2); } { exitMenuItem = new JMenuItem(); jMenu3.add(exitMenuItem); exitMenuItem.setText("Exit"); exitMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // exit program System.exit(0); } }); } } { jMenu4 = new JMenu(); jMenuBar1.add(jMenu4); jMenu4.setText("Edit"); { final JFrame owner = this; editPrefsMenuItem = new JMenuItem(); jMenu4.add(editPrefsMenuItem); editPrefsMenuItem.setText("Preferences..."); editPrefsMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { PreferencesDialog d = new PreferencesDialog(owner, preferences); d.setVisible(true); } }); } { jSeparator1 = new JSeparator(); jMenu4.add(jSeparator1); } { deleteMenuItem = new JMenuItem(); jMenu4.add(deleteMenuItem); deleteMenuItem.setText("Delete"); deleteMenuItem.setEnabled(false); } } { mnuView = new JMenu(); jMenuBar1.add(mnuView); mnuView.setText("View"); { mashManagerMenuItem = new JMenuItem(); mnuView.add(mashManagerMenuItem); mashManagerMenuItem.setText("Mash Manager..."); mashManagerMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { mashMgr = new MashManager(myRecipe); mashMgr.setVisible(true); } }); } } { jMenu5 = new JMenu(); jMenuBar1.add(jMenu5); jMenu5.setText("Help"); { helpMenuItem = new JMenuItem(); jMenu5.add(helpMenuItem); helpMenuItem.setText("Help"); } { aboutMenuItem = new JMenuItem(); jMenu5.add(aboutMenuItem); aboutMenuItem.setText("About..."); final JFrame owner = this; aboutMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { aboutDlg = new AboutDialog(owner); aboutDlg.setVisible(true); } }); } } } } catch (Exception e) { e.printStackTrace(); } }
private void initGUI() { try { this.setSize(520, 532); this.addWindowListener(new WindowAdapter() { public void windowClosed(WindowEvent evt) { System.exit(1); } }); { pnlMain = new JPanel(); GridBagLayout jPanel2Layout = new GridBagLayout(); jPanel2Layout.columnWeights = new double[] {0.1,0.1}; jPanel2Layout.columnWidths = new int[] {7,7}; jPanel2Layout.rowWeights = new double[] {0.1,0.1,0.9,0.1}; jPanel2Layout.rowHeights = new int[] {7,7,7,7}; pnlMain.setLayout(jPanel2Layout); this.getContentPane().add(pnlMain, BorderLayout.CENTER); { jPanel1 = new JPanel(); pnlMain.add(jPanel1, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); FlowLayout jPanel1Layout = new FlowLayout(); jPanel1Layout.setAlignment(FlowLayout.LEFT); jPanel1.setLayout(jPanel1Layout); { lblName = new JLabel(); jPanel1.add(lblName); lblName.setText("Name:"); } { txtName = new JTextField(); jPanel1.add(txtName); txtName.setText("Name"); txtName.setPreferredSize(new java.awt.Dimension(179, 20)); txtName.addActionListener(this); txtName.addFocusListener(this); } } { jTabbedPane1 = new JTabbedPane(); pnlMain.add(jTabbedPane1, new GridBagConstraints(0, 1, 1, 1, 0.1, 0.1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); { pnlDetails = new JPanel(); GridBagLayout pnlDetailsLayout = new GridBagLayout(); pnlDetailsLayout.columnWeights = new double[] {0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1}; pnlDetailsLayout.columnWidths = new int[] {7,7,7,7,7,7,7,7,7,7}; pnlDetailsLayout.rowWeights = new double[] {0.1,0.1,0.1,0.1,0.1,0.1,0.1}; pnlDetailsLayout.rowHeights = new int[] {7,7,7,7,7,7,7}; pnlDetails.setLayout(pnlDetailsLayout); jTabbedPane1.addTab("Details", null, pnlDetails, null); pnlDetails.setPreferredSize(new java.awt.Dimension(20, 16)); { lblBrewer = new JLabel(); pnlDetails.add(lblBrewer, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblBrewer.setText("Brewer:"); } { txtBrewer = new JTextField(); pnlDetails.add(txtBrewer, new GridBagConstraints( 1, 0, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); txtBrewer.addFocusListener(this); txtBrewer.addActionListener(this); txtBrewer.setText("Brewer"); } { lblDate = new JLabel(); pnlDetails.add(lblDate, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblDate.setText("Date:"); } { lblStyle = new JLabel(); pnlDetails.add(lblStyle, new GridBagConstraints( 0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblStyle.setText("Style:"); } { lblYeast = new JLabel(); pnlDetails.add(lblYeast, new GridBagConstraints( 0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblYeast.setText("Yeast:"); } { lblPreBoil = new JLabel(); pnlDetails.add(lblPreBoil, new GridBagConstraints( 0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblPreBoil.setText("Pre boil:"); } { lblPostBoil = new JLabel(); pnlDetails.add(lblPostBoil, new GridBagConstraints( 0, 5, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblPostBoil.setText("Post boil:"); } { lblEffic = new JLabel(); pnlDetails.add(lblEffic, new GridBagConstraints( 3, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblEffic.setText("Effic:"); } { lblAtten = new JLabel(); pnlDetails.add(lblAtten, new GridBagConstraints( 3, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblAtten.setText("Atten:"); } { lblOG = new JLabel(); pnlDetails.add(lblOG, new GridBagConstraints( 5, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblOG.setText("OG:"); } { lblFG = new JLabel(); pnlDetails.add(lblFG, new GridBagConstraints( 5, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblFG.setText("FG:"); } { lblIBU = new JLabel(); pnlDetails.add(lblIBU, new GridBagConstraints( 7, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblIBU.setText("IBU:"); } { lblAlc = new JLabel(); pnlDetails.add(lblAlc, new GridBagConstraints( 7, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblAlc.setText("%Alc:"); } { lblColour = new JLabel(); pnlDetails.add(lblColour, new GridBagConstraints( 7, 2, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblColour.setText("Colour:"); } { txtDate = new JFormattedTextField(); pnlDetails.add(txtDate, new GridBagConstraints( 1, 1, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); txtDate.setText("Date"); txtDate.addFocusListener(this); txtDate.addActionListener(this); } { cmbStyleModel = new ComboModel(); cmbStyle = new JComboBox(); pnlDetails.add(cmbStyle, new GridBagConstraints( 1, 2, 5, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); cmbStyle.setModel(cmbStyleModel); cmbStyle.setMaximumSize(new java.awt.Dimension(100, 32767)); cmbStyle.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { Style s = (Style) cmbStyleModel.getSelectedItem(); if (myRecipe != null && s != myRecipe.getStyleObj()) { myRecipe.setStyle(s); } descriptionTextArea.setText(s.getDescription()); cmbStyle.setToolTipText(multiLineToolTip(50,s.getDescription())); } }); } { txtPreBoil = new JFormattedTextField(); pnlDetails.add(txtPreBoil, new GridBagConstraints( 1, 4, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); txtPreBoil.setText("Pre Boil"); txtPreBoil.addFocusListener(this); txtPreBoil.addActionListener(this); } { postBoilText = new JFormattedTextField(); pnlDetails.add(postBoilText, new GridBagConstraints( 1, 5, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); postBoilText.setText("Post Boil"); postBoilText.addFocusListener(new FocusAdapter() { public void focusLost(FocusEvent evt) { myRecipe.setPostBoil(Double.parseDouble(postBoilText.getText() .toString())); displayRecipe(); } }); postBoilText.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { myRecipe.setPostBoil(Double.parseDouble(postBoilText.getText() .toString())); displayRecipe(); } }); } { lblComments = new JLabel(); pnlDetails.add(lblComments, new GridBagConstraints( 6, 3, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblComments.setText("Comments:"); } { SpinnerNumberModel spnEfficModel = new SpinnerNumberModel(75.0, 0.0, 100.0, 1.0); spnEffic = new JSpinner(); pnlDetails.add(spnEffic, new GridBagConstraints( 4, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); spnEffic.setModel(spnEfficModel); spnEffic.setMaximumSize(new java.awt.Dimension(70, 32767)); spnEffic.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent evt) { myRecipe.setEfficiency(Double.parseDouble(spnEffic.getValue() .toString())); displayRecipe(); } }); spnEffic.setEditor(new JSpinner.NumberEditor(spnEffic, "00.#")); spnEffic.getEditor().setPreferredSize(new java.awt.Dimension(28, 16)); } { SpinnerNumberModel spnAttenModel = new SpinnerNumberModel(75.0, 0.0, 100.0, 1.0); spnAtten = new JSpinner(); pnlDetails.add(spnAtten, new GridBagConstraints( 4, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); spnAtten.setModel(spnAttenModel); spnAtten.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent evt) { myRecipe.setAttenuation(Double.parseDouble(spnAtten.getValue() .toString())); displayRecipe(); } }); spnAtten.setEditor(new JSpinner.NumberEditor(spnAtten, "00.#")); } { SpinnerNumberModel spnOgModel = new SpinnerNumberModel(1.000, 0.900, 2.000, 0.001); spnOG = new JSpinner(); pnlDetails.add(spnOG, new GridBagConstraints( 6, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); spnOG.setModel(spnOgModel); spnOG.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent evt) { myRecipe.setEstOg(Double.parseDouble(spnOG.getValue() .toString())); displayRecipe(); } }); spnOG.setEditor(new JSpinner.NumberEditor(spnOG, "0.000")); spnOG.getEditor().setPreferredSize(new java.awt.Dimension(20, 16)); } { SpinnerNumberModel spnFgModel = new SpinnerNumberModel(1.000, 0.900, 2.000, 0.001); spnFG = new JSpinner(); pnlDetails.add(spnFG, new GridBagConstraints( 6, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); spnFG.setModel(spnFgModel); spnFG.setEditor(new JSpinner.NumberEditor(spnFG, "0.000")); spnFG.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent evt) { // set the new FG, and update alc: myRecipe.setEstFg(Double.parseDouble(spnFG.getValue() .toString())); displayRecipe(); } }); } { lblIBUvalue = new JLabel(); pnlDetails.add(lblIBUvalue, new GridBagConstraints( 8, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblIBUvalue.setText("IBUs"); } { lblColourValue = new JLabel(); pnlDetails.add(lblColourValue, new GridBagConstraints( 8, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblColourValue.setText("Colour"); } { lblAlcValue = new JLabel(); pnlDetails.add(lblAlcValue, new GridBagConstraints( 8, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblAlcValue.setText("Alc"); } { scpComments = new JScrollPane(); pnlDetails.add(scpComments, new GridBagConstraints( 6, 4, 3, 2, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); { txtComments = new JTextArea(); scpComments.setViewportView(txtComments); txtComments.setText("Comments"); txtComments.setWrapStyleWord(true); txtComments.setPreferredSize(new java.awt.Dimension(117, 42)); txtComments.addFocusListener(new FocusAdapter() { public void focusLost(FocusEvent evt) { if (!txtComments.getText().equals(myRecipe.getComments())) { myRecipe.setComments(txtComments.getText()); } } }); } } { cmbYeastModel = new ComboModel(); cmbYeast = new JComboBox(); pnlDetails.add(cmbYeast, new GridBagConstraints( 1, 3, 5, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); cmbYeast.setModel(cmbYeastModel); cmbYeast.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { Yeast y = (Yeast) cmbYeastModel.getSelectedItem(); if (myRecipe != null && y != myRecipe.getYeastObj()) { myRecipe.setYeast(y); } cmbYeast.setToolTipText(multiLineToolTip(40,y.getDescription())); } }); } { cmbSizeUnitsModel = new ComboModel(); cmbSizeUnits = new JComboBox(); pnlDetails.add(cmbSizeUnits, new GridBagConstraints( 2, 4, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); cmbSizeUnits.setModel(cmbSizeUnitsModel); cmbSizeUnits.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { String q = (String) cmbSizeUnits.getSelectedItem(); if (myRecipe != null && q != myRecipe.getVolUnits()) { myRecipe.setPostBoilVolUnits(q); displayRecipe(); } } }); } { lblSizeUnits = new JLabel(); pnlDetails.add(lblSizeUnits, new GridBagConstraints( 2, 5, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); lblSizeUnits.setText("Size Units"); } { boilTimeLable = new JLabel(); pnlDetails.add(boilTimeLable, new GridBagConstraints( 4, 4, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); boilTimeLable.setText("Boil Min:"); } { evapLabel = new JLabel(); pnlDetails.add(evapLabel, new GridBagConstraints( 4, 5, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); evapLabel.setText("Evap/hr:"); } { boilMinText = new JTextField(); pnlDetails.add(boilMinText, new GridBagConstraints( 5, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); boilMinText.setText("60"); boilMinText.addFocusListener(this); boilMinText.addActionListener(this); } { evapText = new JTextField(); pnlDetails.add(evapText, new GridBagConstraints( 5, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); evapText.setText("4"); evapText.addFocusListener(this); evapText.addActionListener(this); } } { pnlStyle = new JPanel(); FlowLayout pnlStyleLayout = new FlowLayout(); pnlStyle.setLayout(pnlStyleLayout); jTabbedPane1.addTab("Style", null, pnlStyle, null); { lblStyle2 = new JLabel(); pnlStyle.add(lblStyle2); lblStyle2.setText("Style:"); } { ComboBoxModel cmbStyle2Model = new DefaultComboBoxModel(new String[]{ "Item One", "Item Two"}); cmbStyle2 = new JComboBox(); pnlStyle.add(cmbStyle2); cmbStyle2.setModel(cmbStyle2Model); } { jPanel2 = new JPanel(); GridBagLayout jPanel2Layout1 = new GridBagLayout(); jPanel2Layout1.columnWeights = new double[]{0.1, 0.1, 0.1, 0.1}; jPanel2Layout1.columnWidths = new int[]{7, 7, 7, 7}; jPanel2Layout1.rowWeights = new double[]{0.1, 0.1, 0.1, 0.1, 0.1, 0.1}; jPanel2Layout1.rowHeights = new int[]{7, 7, 7, 7, 7, 7}; jPanel2.setPreferredSize(new java.awt.Dimension(179, 120)); jPanel2.setLayout(jPanel2Layout1); pnlStyle.add(jPanel2); jPanel2.setBorder(BorderFactory.createTitledBorder(new LineBorder( new java.awt.Color(0, 0, 0), 1, false), "Recipe Conformance:", TitledBorder.LEADING, TitledBorder.TOP, new java.awt.Font( "Dialog", 0, 12), new java.awt.Color(0, 0, 0))); { jLabel5 = new JLabel(); jPanel2.add(jLabel5, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel5.setText("OG:"); jLabel5.setBounds(74, 3, 60, 30); } { jLabel1 = new JLabel(); jPanel2.add(jLabel1, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); GridLayout jLabel1Layout = new GridLayout(1, 1); jLabel1.setLayout(jLabel1Layout); jLabel1.setText("Low:"); } { jLabel2 = new JLabel(); jPanel2.add(jLabel2, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel2.setText("Recipe:"); } { jLabel3 = new JLabel(); jPanel2.add(jLabel3, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel3.setText("High:"); } { jLabel4 = new JLabel(); jPanel2.add(jLabel4, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel4.setText("IBU:"); } { jLabel6 = new JLabel(); jPanel2.add(jLabel6, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel6.setText("Colour:"); } { jLabel7 = new JLabel(); jPanel2.add(jLabel7, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel7.setText("ABV:"); } } { jScrollPane3 = new JScrollPane(); pnlStyle.add(jScrollPane3); { txaStyles = new JTextArea(); jScrollPane3.setViewportView(txaStyles); txaStyles.setText("Matched Styles"); } } { sldMatch = new JSlider(); pnlStyle.add(sldMatch); } } { miscPanel = new MiscPanel(myRecipe); jTabbedPane1.addTab("Misc", null, miscPanel, null); } { notesPanel = new NotesPanel(); jTabbedPane1.addTab("Notes", null, notesPanel, null); } } { pnlTables = new JPanel(); BoxLayout pnlMaltsLayout = new BoxLayout(pnlTables, javax.swing.BoxLayout.Y_AXIS); pnlMain.add(pnlTables, new GridBagConstraints(0, 2, 1, 1, 0.5, 0.5, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); pnlTables.setLayout(pnlMaltsLayout); { pnlMalt = new JPanel(); pnlTables.add(pnlMalt); BorderLayout pnlMaltLayout1 = new BorderLayout(); FlowLayout pnlMaltLayout = new FlowLayout(); pnlMalt.setBorder(BorderFactory.createTitledBorder(new LineBorder( new java.awt.Color(0, 0, 0), 1, false), "Fermentables", TitledBorder.LEADING, TitledBorder.TOP, new java.awt.Font("Dialog", 1, 12), new java.awt.Color(51, 51, 51))); pnlMalt.setLayout(pnlMaltLayout1); { jScrollPane1 = new JScrollPane(); pnlMalt.add(jScrollPane1, BorderLayout.CENTER); { tblMaltModel = new MaltTableModel(this); tblMalt = new JTable(){ public String getToolTipText(MouseEvent e) { String tip = null; java.awt.Point p = e.getPoint(); int rowIndex = rowAtPoint(p); tip = multiLineToolTip(40,tblMaltModel.getDescriptionAt(rowIndex)); return tip; } }; jScrollPane1.setViewportView(tblMalt); tblMalt.setModel(tblMaltModel); tblMalt.setAutoCreateColumnsFromModel(false); tblMalt.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { int i = tblMalt.getSelectedRow(); // descriptionTextArea.setText(myRecipe.getMaltDescription(i)); } }); TableColumn maltColumn = tblMalt.getColumnModel().getColumn(0); // set up malt list combo JComboBox maltComboBox = new JComboBox(); cmbMaltModel = new ComboModel(); maltComboBox.setModel(cmbMaltModel); maltColumn.setCellEditor(new DefaultCellEditor(maltComboBox)); maltComboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { Fermentable f = (Fermentable) cmbMaltModel .getSelectedItem(); int i = tblMalt.getSelectedRow(); if (myRecipe != null && i != -1) { Fermentable f2 = myRecipe.getFermentable(i); f2.setLov(f.getLov()); f2.setPppg(f.getPppg()); f2.setDescription(f.getDescription()); f2.setMashed(f.getMashed()); f2.setSteep(f.getSteep()); } } }); // set up malt units combo JComboBox maltUnitsComboBox = new JComboBox(); cmbMaltUnitsModel = new ComboModel(); maltUnitsComboBox.setModel(cmbMaltUnitsModel); maltColumn = tblMalt.getColumnModel().getColumn(2); maltColumn.setCellEditor(new DefaultCellEditor(maltUnitsComboBox)); maltUnitsComboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { String u = (String) cmbMaltUnitsModel.getSelectedItem(); int i = tblMalt.getSelectedRow(); if (myRecipe != null && i != -1) { Fermentable f2 = myRecipe.getFermentable(i); f2.setUnitsFull(u); myRecipe.calcMaltTotals(); displayRecipe(); } } }); } } { tblMaltTotalsModel = new DefaultTableModel(new String[][]{{""}}, new String[]{"Malt", "Amount", "Units", "Points", "Lov", "Cost/U", "%"}); tblMaltTotals = new JTable(); pnlMalt.add(tblMaltTotals, BorderLayout.SOUTH); tblMaltTotals.setModel(tblMaltTotalsModel); tblMaltTotals.getTableHeader().setEnabled(false); tblMaltTotals.setAutoCreateColumnsFromModel(false); } } { pnlMaltButtons = new JPanel(); pnlTables.add(pnlMaltButtons); FlowLayout pnlMaltButtonsLayout = new FlowLayout(); pnlMaltButtonsLayout.setAlignment(FlowLayout.LEFT); pnlMaltButtonsLayout.setVgap(0); pnlMaltButtons.setLayout(pnlMaltButtonsLayout); pnlMaltButtons.setPreferredSize(new java.awt.Dimension(390, 34)); { tlbMalt = new JToolBar(); pnlMaltButtons.add(tlbMalt); tlbMalt.setPreferredSize(new java.awt.Dimension(140, 20)); tlbMalt.setFloatable(false); { btnAddMalt = new JButton(); tlbMalt.add(btnAddMalt); btnAddMalt.setText("+"); btnAddMalt.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (myRecipe != null) { Fermentable f = new Fermentable(myRecipe.getMaltUnits()); myRecipe.addMalt(f); tblMalt.updateUI(); displayRecipe(); } } }); } { btnDelMalt = new JButton(); tlbMalt.add(btnDelMalt); btnDelMalt.setText("-"); btnDelMalt.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (myRecipe != null) { int i = tblMalt.getSelectedRow(); myRecipe.delMalt(i); tblMalt.updateUI(); displayRecipe(); } } }); } } } { pnlHops = new JPanel(); BorderLayout pnlHopsLayout = new BorderLayout(); pnlHops.setBorder(BorderFactory.createTitledBorder(new LineBorder( new java.awt.Color(0, 0, 0), 1, false), "Hops", TitledBorder.LEADING, TitledBorder.TOP, new java.awt.Font("Dialog", 1, 12), new java.awt.Color(51, 51, 51))); pnlHops.setLayout(pnlHopsLayout); pnlTables.add(pnlHops); { tblHopsTotalsModel = new DefaultTableModel(new String[][]{{""}}, new String[]{"1", "2","3","4","5","6","7","8","9"}); tblHopsTotals = new JTable(); pnlHops.add(tblHopsTotals, BorderLayout.SOUTH); tblHopsTotals.setModel(tblHopsTotalsModel); tblHopsTotals.setAutoCreateColumnsFromModel(false); } { jScrollPane2 = new JScrollPane(); pnlHops.add(jScrollPane2, BorderLayout.CENTER); { tblHopsModel = new HopsTableModel(this); tblHops = new JTable(); jScrollPane2.setViewportView(tblHops); tblHops.setModel(tblHopsModel); tblHops.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { int i = tblHops.getSelectedRow(); descriptionTextArea.setText(myRecipe.getHopDescription(i)); } }); TableColumn hopColumn = tblHops.getColumnModel().getColumn(0); JComboBox hopComboBox = new JComboBox(); cmbHopsModel = new ComboModel(); hopComboBox.setModel(cmbHopsModel); hopColumn.setCellEditor(new DefaultCellEditor(hopComboBox)); hopComboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { Hop h = (Hop) cmbHopsModel.getSelectedItem(); int i = tblHops.getSelectedRow(); if (myRecipe != null && i != -1) { Hop h2 = (Hop) myRecipe.getHop(i); h2.setAlpha(h.getAlpha()); h2.setDescription(h.getDescription()); } } }); // set up hop units combo JComboBox hopsUnitsComboBox = new JComboBox(); cmbHopsUnitsModel = new ComboModel(); hopsUnitsComboBox.setModel(cmbHopsUnitsModel); hopColumn = tblHops.getColumnModel().getColumn(4); hopColumn.setCellEditor(new DefaultCellEditor(hopsUnitsComboBox)); hopsUnitsComboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { String u = (String) cmbHopsUnitsModel.getSelectedItem(); int i = tblHops.getSelectedRow(); if (myRecipe != null && i != -1) { Hop h = (Hop) myRecipe.getHop(i); h.setUnitsFull(u); myRecipe.calcHopsTotals(); // tblHops.updateUI(); displayRecipe(); } } }); // set up hop type combo String [] forms = {"Leaf","Pellet","Plug"}; JComboBox hopsFormComboBox = new JComboBox(forms); hopColumn = tblHops.getColumnModel().getColumn(1); hopColumn.setCellEditor(new DefaultCellEditor(hopsFormComboBox)); // set up hop add combo String [] add = {"Boil","FWH","Dry", "Mash"}; JComboBox hopsAddComboBox = new JComboBox(add); hopColumn = tblHops.getColumnModel().getColumn(5); hopColumn.setCellEditor(new DefaultCellEditor(hopsAddComboBox)); } } } { pnlHopsButtons = new JPanel(); FlowLayout pnlHopsButtonsLayout = new FlowLayout(); pnlHopsButtonsLayout.setAlignment(FlowLayout.LEFT); pnlHopsButtonsLayout.setVgap(0); pnlHopsButtons.setLayout(pnlHopsButtonsLayout); pnlTables.add(pnlHopsButtons); pnlHopsButtons.setPreferredSize(new java.awt.Dimension(512, 16)); { tlbHops = new JToolBar(); pnlHopsButtons.add(tlbHops); tlbHops.setPreferredSize(new java.awt.Dimension(70, 19)); tlbHops.setFloatable(false); { btnAddHop = new JButton(); tlbHops.add(btnAddHop); btnAddHop.setText("+"); btnAddHop.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (myRecipe != null) { Hop h = new Hop(myRecipe.getHopUnits()); myRecipe.addHop(h); tblHops.updateUI(); displayRecipe(); } } }); } { btnDelHop = new JButton(); tlbHops.add(btnDelHop); btnDelHop.setText("-"); btnDelHop.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (myRecipe != null) { int i = tblHops.getSelectedRow(); myRecipe.delHop(i); tblHops.updateUI(); displayRecipe(); } } }); } } } } { descriptionPanel = new JPanel(); FlowLayout descriptionPanelLayout = new FlowLayout(); descriptionPanel.setLayout(descriptionPanelLayout); pnlMain.add(descriptionPanel, new GridBagConstraints( 1, 0, 1, 3, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.VERTICAL, new Insets(0, 0, 0, 0), 0, 0)); descriptionPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); { descriptionTextArea = new JTextArea(); descriptionPanel.add(descriptionTextArea); descriptionTextArea.setText("Description"); descriptionTextArea.setFont(new java.awt.Font("Dialog", 0, 10)); descriptionTextArea.setEditable(false); descriptionTextArea.setFocusable(false); descriptionTextArea.setLineWrap(true); descriptionTextArea.setWrapStyleWord(true); } } { statusPanel = new JPanel(); FlowLayout statusPanelLayout = new FlowLayout(); statusPanelLayout.setAlignment(FlowLayout.LEFT); statusPanel.setLayout(statusPanelLayout); pnlMain.add(statusPanel, new GridBagConstraints( 0, 3, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); statusPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); { fileNameLabel = new JLabel(); statusPanel.add(fileNameLabel); fileNameLabel.setText("File Name"); fileNameLabel.setFont(new java.awt.Font("Dialog",1,10)); } } } { jMenuBar1 = new JMenuBar(); setJMenuBar(jMenuBar1); { jMenu3 = new JMenu(); jMenuBar1.add(jMenu3); jMenu3.setText("File"); { newFileMenuItem = new JMenuItem(); jMenu3.add(newFileMenuItem); newFileMenuItem.setText("New"); newFileMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // This is just a test right now to see that // stuff is changed. myRecipe = new Recipe(); attachRecipeData(); displayRecipe(); } }); } { openFileMenuItem = new JMenuItem(); jMenu3.add(openFileMenuItem); openFileMenuItem.setText("Open"); openFileMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // Show open dialog; this method does // not return until the dialog is closed int returnVal = fileChooser.showOpenDialog(jMenuBar1); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); System.out.print("Opening: " + file.getName() + ".\n"); ImportXml imp = new ImportXml(file.toString()); myRecipe = imp.handler.getRecipe(); myRecipe.calcMaltTotals(); myRecipe.calcHopsTotals(); myRecipe.mash.calcMashSchedule(); attachRecipeData(); displayRecipe(); // show true file name fileName = file.getName(); fileNameLabel.setText(fileName); } else { System.out.print("Open command cancelled by user.\n"); } } }); } { saveMenuItem = new JMenuItem(); jMenu3.add(saveMenuItem); saveMenuItem.setText("Save"); } { saveAsMenuItem = new JMenuItem(); jMenu3.add(saveAsMenuItem); saveAsMenuItem.setText("Save As ..."); saveAsMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (DEBUG){ // This is just a test right now to see that // stuff is changed. System.out.print(myRecipe.toXML()); } // Show save dialog; this method does // not return until the dialog is closed int returnVal = fileChooser.showSaveDialog(jMenuBar1); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); //This is where a real application would save the file. try { FileWriter out = new FileWriter(file); out.write(myRecipe.toXML()); out.close(); } catch (Exception e){ // TODO: handle io exception } } else { System.out.print("Save command cancelled by user.\n"); } } }); } { exportMenu = new JMenu(); jMenu3.add(exportMenu); exportMenu.setText("Export"); { exportHTMLmenu = new JMenuItem(); exportMenu.add(exportHTMLmenu); exportHTMLmenu.setText("HTML"); exportHTMLmenu.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // Show save dialog; this method does // not return until the dialog is closed fileChooser.setSelectedFile(new File(myRecipe.getName()+".html")); int returnVal = fileChooser.showSaveDialog(jMenuBar1); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); //This is where a real application would save the file. try { saveAsHTML(file); } catch (Exception e){ // TODO: handle io exception } } else { System.out.print("Save command cancelled by user.\n"); } } }); exportTextMenuItem = new JMenuItem(); exportMenu.add(exportTextMenuItem); exportTextMenuItem.setText("Text"); exportTextMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // Show save dialog; this method does // not return until the dialog is closed fileChooser.setSelectedFile(new File(myRecipe.getName()+".txt")); int returnVal = fileChooser.showSaveDialog(jMenuBar1); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); //This is where a real application would save the file. try { FileWriter out = new FileWriter(file); out.write(myRecipe.toText()); out.close(); } catch (Exception e){ // TODO: handle io exception } } else { System.out.print("Export text command cancelled by user.\n"); } } }); } } { jSeparator2 = new JSeparator(); jMenu3.add(jSeparator2); } { exitMenuItem = new JMenuItem(); jMenu3.add(exitMenuItem); exitMenuItem.setText("Exit"); exitMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // exit program System.exit(0); } }); } } { jMenu4 = new JMenu(); jMenuBar1.add(jMenu4); jMenu4.setText("Edit"); { final JFrame owner = this; editPrefsMenuItem = new JMenuItem(); jMenu4.add(editPrefsMenuItem); editPrefsMenuItem.setText("Preferences..."); editPrefsMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { PreferencesDialog d = new PreferencesDialog(owner, preferences); d.setVisible(true); } }); } { jSeparator1 = new JSeparator(); jMenu4.add(jSeparator1); } { deleteMenuItem = new JMenuItem(); jMenu4.add(deleteMenuItem); deleteMenuItem.setText("Delete"); deleteMenuItem.setEnabled(false); } } { mnuView = new JMenu(); jMenuBar1.add(mnuView); mnuView.setText("View"); { mashManagerMenuItem = new JMenuItem(); mnuView.add(mashManagerMenuItem); mashManagerMenuItem.setText("Mash Manager..."); mashManagerMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { mashMgr = new MashManager(myRecipe); mashMgr.setVisible(true); } }); } } { jMenu5 = new JMenu(); jMenuBar1.add(jMenu5); jMenu5.setText("Help"); { helpMenuItem = new JMenuItem(); jMenu5.add(helpMenuItem); helpMenuItem.setText("Help"); } { aboutMenuItem = new JMenuItem(); jMenu5.add(aboutMenuItem); aboutMenuItem.setText("About..."); final JFrame owner = this; aboutMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { aboutDlg = new AboutDialog(owner); aboutDlg.setVisible(true); } }); } } } } catch (Exception e) { e.printStackTrace(); } }
1,116,828
private void initGUI() { try { this.setSize(520, 532); this.addWindowListener(new WindowAdapter() { public void windowClosed(WindowEvent evt) { System.exit(1); } }); { pnlMain = new JPanel(); GridBagLayout jPanel2Layout = new GridBagLayout(); jPanel2Layout.columnWeights = new double[] {0.1,0.1}; jPanel2Layout.columnWidths = new int[] {7,7}; jPanel2Layout.rowWeights = new double[] {0.1,0.1,0.9,0.1}; jPanel2Layout.rowHeights = new int[] {7,7,7,7}; pnlMain.setLayout(jPanel2Layout); this.getContentPane().add(pnlMain, BorderLayout.CENTER); { jPanel1 = new JPanel(); pnlMain.add(jPanel1, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); FlowLayout jPanel1Layout = new FlowLayout(); jPanel1Layout.setAlignment(FlowLayout.LEFT); jPanel1.setLayout(jPanel1Layout); { lblName = new JLabel(); jPanel1.add(lblName); lblName.setText("Name:"); } { txtName = new JTextField(); jPanel1.add(txtName); txtName.setText("Name"); txtName.setPreferredSize(new java.awt.Dimension(179, 20)); txtName.addActionListener(this); txtName.addFocusListener(this); } } { jTabbedPane1 = new JTabbedPane(); pnlMain.add(jTabbedPane1, new GridBagConstraints(0, 1, 1, 1, 0.1, 0.1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); { pnlDetails = new JPanel(); GridBagLayout pnlDetailsLayout = new GridBagLayout(); pnlDetailsLayout.columnWeights = new double[] {0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1}; pnlDetailsLayout.columnWidths = new int[] {7,7,7,7,7,7,7,7,7,7}; pnlDetailsLayout.rowWeights = new double[] {0.1,0.1,0.1,0.1,0.1,0.1,0.1}; pnlDetailsLayout.rowHeights = new int[] {7,7,7,7,7,7,7}; pnlDetails.setLayout(pnlDetailsLayout); jTabbedPane1.addTab("Details", null, pnlDetails, null); pnlDetails.setPreferredSize(new java.awt.Dimension(20, 16)); { lblBrewer = new JLabel(); pnlDetails.add(lblBrewer, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblBrewer.setText("Brewer:"); } { txtBrewer = new JTextField(); pnlDetails.add(txtBrewer, new GridBagConstraints( 1, 0, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); txtBrewer.addFocusListener(this); txtBrewer.addActionListener(this); txtBrewer.setText("Brewer"); } { lblDate = new JLabel(); pnlDetails.add(lblDate, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblDate.setText("Date:"); } { lblStyle = new JLabel(); pnlDetails.add(lblStyle, new GridBagConstraints( 0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblStyle.setText("Style:"); } { lblYeast = new JLabel(); pnlDetails.add(lblYeast, new GridBagConstraints( 0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblYeast.setText("Yeast:"); } { lblPreBoil = new JLabel(); pnlDetails.add(lblPreBoil, new GridBagConstraints( 0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblPreBoil.setText("Pre boil:"); } { lblPostBoil = new JLabel(); pnlDetails.add(lblPostBoil, new GridBagConstraints( 0, 5, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblPostBoil.setText("Post boil:"); } { lblEffic = new JLabel(); pnlDetails.add(lblEffic, new GridBagConstraints( 3, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblEffic.setText("Effic:"); } { lblAtten = new JLabel(); pnlDetails.add(lblAtten, new GridBagConstraints( 3, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblAtten.setText("Atten:"); } { lblOG = new JLabel(); pnlDetails.add(lblOG, new GridBagConstraints( 5, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblOG.setText("OG:"); } { lblFG = new JLabel(); pnlDetails.add(lblFG, new GridBagConstraints( 5, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblFG.setText("FG:"); } { lblIBU = new JLabel(); pnlDetails.add(lblIBU, new GridBagConstraints( 7, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblIBU.setText("IBU:"); } { lblAlc = new JLabel(); pnlDetails.add(lblAlc, new GridBagConstraints( 7, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblAlc.setText("%Alc:"); } { lblColour = new JLabel(); pnlDetails.add(lblColour, new GridBagConstraints( 7, 2, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblColour.setText("Colour:"); } { txtDate = new JFormattedTextField(); pnlDetails.add(txtDate, new GridBagConstraints( 1, 1, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); txtDate.setText("Date"); txtDate.addFocusListener(this); txtDate.addActionListener(this); } { cmbStyleModel = new ComboModel(); cmbStyle = new JComboBox(); pnlDetails.add(cmbStyle, new GridBagConstraints( 1, 2, 5, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); cmbStyle.setModel(cmbStyleModel); cmbStyle.setMaximumSize(new java.awt.Dimension(100, 32767)); cmbStyle.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { Style s = (Style) cmbStyleModel.getSelectedItem(); if (myRecipe != null && s != myRecipe.getStyleObj()) { myRecipe.setStyle(s); } descriptionTextArea.setText(s.getDescription()); cmbStyle.setToolTipText(multiLineToolTip(50,s.getDescription())); } }); } { txtPreBoil = new JFormattedTextField(); pnlDetails.add(txtPreBoil, new GridBagConstraints( 1, 4, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); txtPreBoil.setText("Pre Boil"); txtPreBoil.addFocusListener(this); txtPreBoil.addActionListener(this); } { postBoilText = new JFormattedTextField(); pnlDetails.add(postBoilText, new GridBagConstraints( 1, 5, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); postBoilText.setText("Post Boil"); postBoilText.addFocusListener(new FocusAdapter() { public void focusLost(FocusEvent evt) { myRecipe.setPostBoil(Double.parseDouble(postBoilText.getText() .toString())); displayRecipe(); } }); postBoilText.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { myRecipe.setPostBoil(Double.parseDouble(postBoilText.getText() .toString())); displayRecipe(); } }); } { lblComments = new JLabel(); pnlDetails.add(lblComments, new GridBagConstraints( 6, 3, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblComments.setText("Comments:"); } { SpinnerNumberModel spnEfficModel = new SpinnerNumberModel(75.0, 0.0, 100.0, 1.0); spnEffic = new JSpinner(); pnlDetails.add(spnEffic, new GridBagConstraints( 4, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); spnEffic.setModel(spnEfficModel); spnEffic.setMaximumSize(new java.awt.Dimension(70, 32767)); spnEffic.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent evt) { myRecipe.setEfficiency(Double.parseDouble(spnEffic.getValue() .toString())); displayRecipe(); } }); spnEffic.setEditor(new JSpinner.NumberEditor(spnEffic, "00.#")); spnEffic.getEditor().setPreferredSize(new java.awt.Dimension(28, 16)); } { SpinnerNumberModel spnAttenModel = new SpinnerNumberModel(75.0, 0.0, 100.0, 1.0); spnAtten = new JSpinner(); pnlDetails.add(spnAtten, new GridBagConstraints( 4, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); spnAtten.setModel(spnAttenModel); spnAtten.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent evt) { myRecipe.setAttenuation(Double.parseDouble(spnAtten.getValue() .toString())); displayRecipe(); } }); spnAtten.setEditor(new JSpinner.NumberEditor(spnAtten, "00.#")); } { SpinnerNumberModel spnOgModel = new SpinnerNumberModel(1.000, 0.900, 2.000, 0.001); spnOG = new JSpinner(); pnlDetails.add(spnOG, new GridBagConstraints( 6, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); spnOG.setModel(spnOgModel); spnOG.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent evt) { myRecipe.setEstOg(Double.parseDouble(spnOG.getValue() .toString())); displayRecipe(); } }); spnOG.setEditor(new JSpinner.NumberEditor(spnOG, "0.000")); spnOG.getEditor().setPreferredSize(new java.awt.Dimension(20, 16)); } { SpinnerNumberModel spnFgModel = new SpinnerNumberModel(1.000, 0.900, 2.000, 0.001); spnFG = new JSpinner(); pnlDetails.add(spnFG, new GridBagConstraints( 6, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); spnFG.setModel(spnFgModel); spnFG.setEditor(new JSpinner.NumberEditor(spnFG, "0.000")); spnFG.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent evt) { // set the new FG, and update alc: myRecipe.setEstFg(Double.parseDouble(spnFG.getValue() .toString())); displayRecipe(); } }); } { lblIBUvalue = new JLabel(); pnlDetails.add(lblIBUvalue, new GridBagConstraints( 8, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblIBUvalue.setText("IBUs"); } { lblColourValue = new JLabel(); pnlDetails.add(lblColourValue, new GridBagConstraints( 8, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblColourValue.setText("Colour"); } { lblAlcValue = new JLabel(); pnlDetails.add(lblAlcValue, new GridBagConstraints( 8, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblAlcValue.setText("Alc"); } { scpComments = new JScrollPane(); pnlDetails.add(scpComments, new GridBagConstraints( 6, 4, 3, 2, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); { txtComments = new JTextArea(); scpComments.setViewportView(txtComments); txtComments.setText("Comments"); txtComments.setWrapStyleWord(true); txtComments.setPreferredSize(new java.awt.Dimension(117, 42)); txtComments.addFocusListener(new FocusAdapter() { public void focusLost(FocusEvent evt) { if (!txtComments.getText().equals(myRecipe.getComments())) { myRecipe.setComments(txtComments.getText()); } } }); } } { cmbYeastModel = new ComboModel(); cmbYeast = new JComboBox(); pnlDetails.add(cmbYeast, new GridBagConstraints( 1, 3, 5, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); cmbYeast.setModel(cmbYeastModel); cmbYeast.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { Yeast y = (Yeast) cmbYeastModel.getSelectedItem(); if (myRecipe != null && y != myRecipe.getYeastObj()) { myRecipe.setYeast(y); } cmbYeast.setToolTipText(multiLineToolTip(40,y.getDescription())); } }); } { cmbSizeUnitsModel = new ComboModel(); cmbSizeUnits = new JComboBox(); pnlDetails.add(cmbSizeUnits, new GridBagConstraints( 2, 4, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); cmbSizeUnits.setModel(cmbSizeUnitsModel); cmbSizeUnits.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { String q = (String) cmbSizeUnits.getSelectedItem(); if (myRecipe != null && q != myRecipe.getVolUnits()) { myRecipe.setPostBoilVolUnits(q); displayRecipe(); } } }); } { lblSizeUnits = new JLabel(); pnlDetails.add(lblSizeUnits, new GridBagConstraints( 2, 5, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); lblSizeUnits.setText("Size Units"); } { boilTimeLable = new JLabel(); pnlDetails.add(boilTimeLable, new GridBagConstraints( 4, 4, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); boilTimeLable.setText("Boil Min:"); } { evapLabel = new JLabel(); pnlDetails.add(evapLabel, new GridBagConstraints( 4, 5, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); evapLabel.setText("Evap/hr:"); } { boilMinText = new JTextField(); pnlDetails.add(boilMinText, new GridBagConstraints( 5, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); boilMinText.setText("60"); boilMinText.addFocusListener(this); boilMinText.addActionListener(this); } { evapText = new JTextField(); pnlDetails.add(evapText, new GridBagConstraints( 5, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); evapText.setText("4"); evapText.addFocusListener(this); evapText.addActionListener(this); } } { pnlStyle = new JPanel(); FlowLayout pnlStyleLayout = new FlowLayout(); pnlStyle.setLayout(pnlStyleLayout); jTabbedPane1.addTab("Style", null, pnlStyle, null); { lblStyle2 = new JLabel(); pnlStyle.add(lblStyle2); lblStyle2.setText("Style:"); } { ComboBoxModel cmbStyle2Model = new DefaultComboBoxModel(new String[]{ "Item One", "Item Two"}); cmbStyle2 = new JComboBox(); pnlStyle.add(cmbStyle2); cmbStyle2.setModel(cmbStyle2Model); } { jPanel2 = new JPanel(); GridBagLayout jPanel2Layout1 = new GridBagLayout(); jPanel2Layout1.columnWeights = new double[]{0.1, 0.1, 0.1, 0.1}; jPanel2Layout1.columnWidths = new int[]{7, 7, 7, 7}; jPanel2Layout1.rowWeights = new double[]{0.1, 0.1, 0.1, 0.1, 0.1, 0.1}; jPanel2Layout1.rowHeights = new int[]{7, 7, 7, 7, 7, 7}; jPanel2.setPreferredSize(new java.awt.Dimension(179, 120)); jPanel2.setLayout(jPanel2Layout1); pnlStyle.add(jPanel2); jPanel2.setBorder(BorderFactory.createTitledBorder(new LineBorder( new java.awt.Color(0, 0, 0), 1, false), "Recipe Conformance:", TitledBorder.LEADING, TitledBorder.TOP, new java.awt.Font( "Dialog", 0, 12), new java.awt.Color(0, 0, 0))); { jLabel5 = new JLabel(); jPanel2.add(jLabel5, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel5.setText("OG:"); jLabel5.setBounds(74, 3, 60, 30); } { jLabel1 = new JLabel(); jPanel2.add(jLabel1, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); GridLayout jLabel1Layout = new GridLayout(1, 1); jLabel1.setLayout(jLabel1Layout); jLabel1.setText("Low:"); } { jLabel2 = new JLabel(); jPanel2.add(jLabel2, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel2.setText("Recipe:"); } { jLabel3 = new JLabel(); jPanel2.add(jLabel3, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel3.setText("High:"); } { jLabel4 = new JLabel(); jPanel2.add(jLabel4, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel4.setText("IBU:"); } { jLabel6 = new JLabel(); jPanel2.add(jLabel6, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel6.setText("Colour:"); } { jLabel7 = new JLabel(); jPanel2.add(jLabel7, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel7.setText("ABV:"); } } { jScrollPane3 = new JScrollPane(); pnlStyle.add(jScrollPane3); { txaStyles = new JTextArea(); jScrollPane3.setViewportView(txaStyles); txaStyles.setText("Matched Styles"); } } { sldMatch = new JSlider(); pnlStyle.add(sldMatch); } } { miscPanel = new MiscPanel(myRecipe); jTabbedPane1.addTab("Misc", null, miscPanel, null); } { notesPanel = new NotesPanel(); jTabbedPane1.addTab("Notes", null, notesPanel, null); } } { pnlTables = new JPanel(); BoxLayout pnlMaltsLayout = new BoxLayout(pnlTables, javax.swing.BoxLayout.Y_AXIS); pnlMain.add(pnlTables, new GridBagConstraints(0, 2, 1, 1, 0.5, 0.5, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); pnlTables.setLayout(pnlMaltsLayout); { pnlMalt = new JPanel(); pnlTables.add(pnlMalt); BorderLayout pnlMaltLayout1 = new BorderLayout(); FlowLayout pnlMaltLayout = new FlowLayout(); pnlMalt.setBorder(BorderFactory.createTitledBorder(new LineBorder( new java.awt.Color(0, 0, 0), 1, false), "Fermentables", TitledBorder.LEADING, TitledBorder.TOP, new java.awt.Font("Dialog", 1, 12), new java.awt.Color(51, 51, 51))); pnlMalt.setLayout(pnlMaltLayout1); { jScrollPane1 = new JScrollPane(); pnlMalt.add(jScrollPane1, BorderLayout.CENTER); { tblMaltModel = new MaltTableModel(this); tblMalt = new JTable(){ public String getToolTipText(MouseEvent e) { String tip = null; java.awt.Point p = e.getPoint(); int rowIndex = rowAtPoint(p); tip = multiLineToolTip(40,tblMaltModel.getDescriptionAt(rowIndex)); return tip; } }; jScrollPane1.setViewportView(tblMalt); tblMalt.setModel(tblMaltModel); tblMalt.setAutoCreateColumnsFromModel(false); tblMalt.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { int i = tblMalt.getSelectedRow(); // descriptionTextArea.setText(myRecipe.getMaltDescription(i)); } }); TableColumn maltColumn = tblMalt.getColumnModel().getColumn(0); // set up malt list combo JComboBox maltComboBox = new JComboBox(); cmbMaltModel = new ComboModel(); maltComboBox.setModel(cmbMaltModel); maltColumn.setCellEditor(new DefaultCellEditor(maltComboBox)); maltComboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { Fermentable f = (Fermentable) cmbMaltModel .getSelectedItem(); int i = tblMalt.getSelectedRow(); if (myRecipe != null && i != -1) { Fermentable f2 = myRecipe.getFermentable(i); f2.setLov(f.getLov()); f2.setPppg(f.getPppg()); f2.setDescription(f.getDescription()); f2.setMashed(f.getMashed()); f2.setSteep(f.getSteep()); } } }); // set up malt units combo JComboBox maltUnitsComboBox = new JComboBox(); cmbMaltUnitsModel = new ComboModel(); maltUnitsComboBox.setModel(cmbMaltUnitsModel); maltColumn = tblMalt.getColumnModel().getColumn(2); maltColumn.setCellEditor(new DefaultCellEditor(maltUnitsComboBox)); maltUnitsComboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { String u = (String) cmbMaltUnitsModel.getSelectedItem(); int i = tblMalt.getSelectedRow(); if (myRecipe != null && i != -1) { Fermentable f2 = myRecipe.getFermentable(i); f2.setUnitsFull(u); myRecipe.calcMaltTotals(); displayRecipe(); } } }); } } { tblMaltTotalsModel = new DefaultTableModel(new String[][]{{""}}, new String[]{"Malt", "Amount", "Units", "Points", "Lov", "Cost/U", "%"}); tblMaltTotals = new JTable(); pnlMalt.add(tblMaltTotals, BorderLayout.SOUTH); tblMaltTotals.setModel(tblMaltTotalsModel); tblMaltTotals.getTableHeader().setEnabled(false); tblMaltTotals.setAutoCreateColumnsFromModel(false); } } { pnlMaltButtons = new JPanel(); pnlTables.add(pnlMaltButtons); FlowLayout pnlMaltButtonsLayout = new FlowLayout(); pnlMaltButtonsLayout.setAlignment(FlowLayout.LEFT); pnlMaltButtonsLayout.setVgap(0); pnlMaltButtons.setLayout(pnlMaltButtonsLayout); pnlMaltButtons.setPreferredSize(new java.awt.Dimension(390, 34)); { tlbMalt = new JToolBar(); pnlMaltButtons.add(tlbMalt); tlbMalt.setPreferredSize(new java.awt.Dimension(140, 20)); tlbMalt.setFloatable(false); { btnAddMalt = new JButton(); tlbMalt.add(btnAddMalt); btnAddMalt.setText("+"); btnAddMalt.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (myRecipe != null) { Fermentable f = new Fermentable(myRecipe.getMaltUnits()); myRecipe.addMalt(f); tblMalt.updateUI(); displayRecipe(); } } }); } { btnDelMalt = new JButton(); tlbMalt.add(btnDelMalt); btnDelMalt.setText("-"); btnDelMalt.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (myRecipe != null) { int i = tblMalt.getSelectedRow(); myRecipe.delMalt(i); tblMalt.updateUI(); displayRecipe(); } } }); } } } { pnlHops = new JPanel(); BorderLayout pnlHopsLayout = new BorderLayout(); pnlHops.setBorder(BorderFactory.createTitledBorder(new LineBorder( new java.awt.Color(0, 0, 0), 1, false), "Hops", TitledBorder.LEADING, TitledBorder.TOP, new java.awt.Font("Dialog", 1, 12), new java.awt.Color(51, 51, 51))); pnlHops.setLayout(pnlHopsLayout); pnlTables.add(pnlHops); { tblHopsTotalsModel = new DefaultTableModel(new String[][]{{""}}, new String[]{"1", "2","3","4","5","6","7","8","9"}); tblHopsTotals = new JTable(); pnlHops.add(tblHopsTotals, BorderLayout.SOUTH); tblHopsTotals.setModel(tblHopsTotalsModel); tblHopsTotals.setAutoCreateColumnsFromModel(false); } { jScrollPane2 = new JScrollPane(); pnlHops.add(jScrollPane2, BorderLayout.CENTER); { tblHopsModel = new HopsTableModel(this); tblHops = new JTable(); jScrollPane2.setViewportView(tblHops); tblHops.setModel(tblHopsModel); tblHops.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { int i = tblHops.getSelectedRow(); descriptionTextArea.setText(myRecipe.getHopDescription(i)); } }); TableColumn hopColumn = tblHops.getColumnModel().getColumn(0); JComboBox hopComboBox = new JComboBox(); cmbHopsModel = new ComboModel(); hopComboBox.setModel(cmbHopsModel); hopColumn.setCellEditor(new DefaultCellEditor(hopComboBox)); hopComboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { Hop h = (Hop) cmbHopsModel.getSelectedItem(); int i = tblHops.getSelectedRow(); if (myRecipe != null && i != -1) { Hop h2 = (Hop) myRecipe.getHop(i); h2.setAlpha(h.getAlpha()); h2.setDescription(h.getDescription()); } } }); // set up hop units combo JComboBox hopsUnitsComboBox = new JComboBox(); cmbHopsUnitsModel = new ComboModel(); hopsUnitsComboBox.setModel(cmbHopsUnitsModel); hopColumn = tblHops.getColumnModel().getColumn(4); hopColumn.setCellEditor(new DefaultCellEditor(hopsUnitsComboBox)); hopsUnitsComboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { String u = (String) cmbHopsUnitsModel.getSelectedItem(); int i = tblHops.getSelectedRow(); if (myRecipe != null && i != -1) { Hop h = (Hop) myRecipe.getHop(i); h.setUnitsFull(u); myRecipe.calcHopsTotals(); // tblHops.updateUI(); displayRecipe(); } } }); // set up hop type combo String [] forms = {"Leaf","Pellet","Plug"}; JComboBox hopsFormComboBox = new JComboBox(forms); hopColumn = tblHops.getColumnModel().getColumn(1); hopColumn.setCellEditor(new DefaultCellEditor(hopsFormComboBox)); // set up hop add combo String [] add = {"Boil","FWH","Dry", "Mash"}; JComboBox hopsAddComboBox = new JComboBox(add); hopColumn = tblHops.getColumnModel().getColumn(5); hopColumn.setCellEditor(new DefaultCellEditor(hopsAddComboBox)); } } } { pnlHopsButtons = new JPanel(); FlowLayout pnlHopsButtonsLayout = new FlowLayout(); pnlHopsButtonsLayout.setAlignment(FlowLayout.LEFT); pnlHopsButtonsLayout.setVgap(0); pnlHopsButtons.setLayout(pnlHopsButtonsLayout); pnlTables.add(pnlHopsButtons); pnlHopsButtons.setPreferredSize(new java.awt.Dimension(512, 16)); { tlbHops = new JToolBar(); pnlHopsButtons.add(tlbHops); tlbHops.setPreferredSize(new java.awt.Dimension(70, 19)); tlbHops.setFloatable(false); { btnAddHop = new JButton(); tlbHops.add(btnAddHop); btnAddHop.setText("+"); btnAddHop.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (myRecipe != null) { Hop h = new Hop(myRecipe.getHopUnits()); myRecipe.addHop(h); tblHops.updateUI(); displayRecipe(); } } }); } { btnDelHop = new JButton(); tlbHops.add(btnDelHop); btnDelHop.setText("-"); btnDelHop.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (myRecipe != null) { int i = tblHops.getSelectedRow(); myRecipe.delHop(i); tblHops.updateUI(); displayRecipe(); } } }); } } } } { descriptionPanel = new JPanel(); FlowLayout descriptionPanelLayout = new FlowLayout(); descriptionPanel.setLayout(descriptionPanelLayout); pnlMain.add(descriptionPanel, new GridBagConstraints( 1, 0, 1, 3, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.VERTICAL, new Insets(0, 0, 0, 0), 0, 0)); descriptionPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); { descriptionTextArea = new JTextArea(); descriptionPanel.add(descriptionTextArea); descriptionTextArea.setText("Description"); descriptionTextArea.setFont(new java.awt.Font("Dialog", 0, 10)); descriptionTextArea.setEditable(false); descriptionTextArea.setFocusable(false); descriptionTextArea.setLineWrap(true); descriptionTextArea.setWrapStyleWord(true); } } { statusPanel = new JPanel(); FlowLayout statusPanelLayout = new FlowLayout(); statusPanelLayout.setAlignment(FlowLayout.LEFT); statusPanel.setLayout(statusPanelLayout); pnlMain.add(statusPanel, new GridBagConstraints( 0, 3, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); statusPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); { fileNameLabel = new JLabel(); statusPanel.add(fileNameLabel); fileNameLabel.setText("File Name"); fileNameLabel.setFont(new java.awt.Font("Dialog",1,10)); } } } { jMenuBar1 = new JMenuBar(); setJMenuBar(jMenuBar1); { jMenu3 = new JMenu(); jMenuBar1.add(jMenu3); jMenu3.setText("File"); { newFileMenuItem = new JMenuItem(); jMenu3.add(newFileMenuItem); newFileMenuItem.setText("New"); newFileMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // This is just a test right now to see that // stuff is changed. myRecipe = new Recipe(); attachRecipeData(); displayRecipe(); } }); } { openFileMenuItem = new JMenuItem(); jMenu3.add(openFileMenuItem); openFileMenuItem.setText("Open"); openFileMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // Show open dialog; this method does // not return until the dialog is closed int returnVal = fileChooser.showOpenDialog(jMenuBar1); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); System.out.print("Opening: " + file.getName() + ".\n"); ImportXml imp = new ImportXml(file.toString()); myRecipe = imp.handler.getRecipe(); myRecipe.calcMaltTotals(); myRecipe.calcHopsTotals(); myRecipe.mash.calcMashSchedule(); attachRecipeData(); displayRecipe(); // show true file name fileName = file.getName(); fileNameLabel.setText(fileName); } else { System.out.print("Open command cancelled by user.\n"); } } }); } { saveMenuItem = new JMenuItem(); jMenu3.add(saveMenuItem); saveMenuItem.setText("Save"); } { saveAsMenuItem = new JMenuItem(); jMenu3.add(saveAsMenuItem); saveAsMenuItem.setText("Save As ..."); saveAsMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (DEBUG){ // This is just a test right now to see that // stuff is changed. System.out.print(myRecipe.toXML()); } // Show save dialog; this method does // not return until the dialog is closed int returnVal = fileChooser.showSaveDialog(jMenuBar1); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); //This is where a real application would save the file. try { FileWriter out = new FileWriter(file); out.write(myRecipe.toXML()); out.close(); } catch (Exception e){ // TODO: handle io exception } } else { System.out.print("Save command cancelled by user.\n"); } } }); } { exportMenu = new JMenu(); jMenu3.add(exportMenu); exportMenu.setText("Export"); { exportHTMLmenu = new JMenuItem(); exportMenu.add(exportHTMLmenu); exportHTMLmenu.setText("HTML"); exportHTMLmenu.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // Show save dialog; this method does // not return until the dialog is closed fileChooser.setSelectedFile(new File(myRecipe.getName()+".html")); int returnVal = fileChooser.showSaveDialog(jMenuBar1); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); //This is where a real application would save the file. try { saveAsHTML(file); } catch (Exception e){ // TODO: handle io exception } } else { System.out.print("Save command cancelled by user.\n"); } } }); exportTextMenuItem = new JMenuItem(); exportMenu.add(exportTextMenuItem); exportTextMenuItem.setText("Text"); exportTextMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // Show save dialog; this method does // not return until the dialog is closed fileChooser.setSelectedFile(new File(myRecipe.getName()+".txt")); int returnVal = fileChooser.showSaveDialog(jMenuBar1); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); //This is where a real application would save the file. try { FileWriter out = new FileWriter(file); out.write(myRecipe.toText()); out.close(); } catch (Exception e){ // TODO: handle io exception } } else { System.out.print("Export text command cancelled by user.\n"); } } }); } } { jSeparator2 = new JSeparator(); jMenu3.add(jSeparator2); } { exitMenuItem = new JMenuItem(); jMenu3.add(exitMenuItem); exitMenuItem.setText("Exit"); exitMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // exit program System.exit(0); } }); } } { jMenu4 = new JMenu(); jMenuBar1.add(jMenu4); jMenu4.setText("Edit"); { final JFrame owner = this; editPrefsMenuItem = new JMenuItem(); jMenu4.add(editPrefsMenuItem); editPrefsMenuItem.setText("Preferences..."); editPrefsMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { PreferencesDialog d = new PreferencesDialog(owner, preferences); d.setVisible(true); } }); } { jSeparator1 = new JSeparator(); jMenu4.add(jSeparator1); } { deleteMenuItem = new JMenuItem(); jMenu4.add(deleteMenuItem); deleteMenuItem.setText("Delete"); deleteMenuItem.setEnabled(false); } } { mnuView = new JMenu(); jMenuBar1.add(mnuView); mnuView.setText("View"); { mashManagerMenuItem = new JMenuItem(); mnuView.add(mashManagerMenuItem); mashManagerMenuItem.setText("Mash Manager..."); mashManagerMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { mashMgr = new MashManager(myRecipe); mashMgr.setVisible(true); } }); } } { jMenu5 = new JMenu(); jMenuBar1.add(jMenu5); jMenu5.setText("Help"); { helpMenuItem = new JMenuItem(); jMenu5.add(helpMenuItem); helpMenuItem.setText("Help"); } { aboutMenuItem = new JMenuItem(); jMenu5.add(aboutMenuItem); aboutMenuItem.setText("About..."); final JFrame owner = this; aboutMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { aboutDlg = new AboutDialog(owner); aboutDlg.setVisible(true); } }); } } } } catch (Exception e) { e.printStackTrace(); } }
private void initGUI() { try { this.setSize(520, 532); this.addWindowListener(new WindowAdapter() { public void windowClosed(WindowEvent evt) { System.exit(1); } }); { pnlMain = new JPanel(); GridBagLayout jPanel2Layout = new GridBagLayout(); jPanel2Layout.columnWeights = new double[] {0.1,0.1}; jPanel2Layout.columnWidths = new int[] {7,7}; jPanel2Layout.rowWeights = new double[] {0.1,0.1,0.9,0.1}; jPanel2Layout.rowHeights = new int[] {7,7,7,7}; pnlMain.setLayout(jPanel2Layout); this.getContentPane().add(pnlMain, BorderLayout.CENTER); { jPanel1 = new JPanel(); pnlMain.add(jPanel1, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); FlowLayout jPanel1Layout = new FlowLayout(); jPanel1Layout.setAlignment(FlowLayout.LEFT); jPanel1.setLayout(jPanel1Layout); { lblName = new JLabel(); jPanel1.add(lblName); lblName.setText("Name:"); } { txtName = new JTextField(); jPanel1.add(txtName); txtName.setText("Name"); txtName.setPreferredSize(new java.awt.Dimension(179, 20)); txtName.addActionListener(this); txtName.addFocusListener(this); } } { jTabbedPane1 = new JTabbedPane(); pnlMain.add(jTabbedPane1, new GridBagConstraints(0, 1, 1, 1, 0.1, 0.1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); { pnlDetails = new JPanel(); GridBagLayout pnlDetailsLayout = new GridBagLayout(); pnlDetailsLayout.columnWeights = new double[] {0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1}; pnlDetailsLayout.columnWidths = new int[] {7,7,7,7,7,7,7,7,7,7}; pnlDetailsLayout.rowWeights = new double[] {0.1,0.1,0.1,0.1,0.1,0.1,0.1}; pnlDetailsLayout.rowHeights = new int[] {7,7,7,7,7,7,7}; pnlDetails.setLayout(pnlDetailsLayout); jTabbedPane1.addTab("Details", null, pnlDetails, null); pnlDetails.setPreferredSize(new java.awt.Dimension(20, 16)); { lblBrewer = new JLabel(); pnlDetails.add(lblBrewer, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblBrewer.setText("Brewer:"); } { txtBrewer = new JTextField(); pnlDetails.add(txtBrewer, new GridBagConstraints( 1, 0, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); txtBrewer.addFocusListener(this); txtBrewer.addActionListener(this); txtBrewer.setText("Brewer"); } { lblDate = new JLabel(); pnlDetails.add(lblDate, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblDate.setText("Date:"); } { lblStyle = new JLabel(); pnlDetails.add(lblStyle, new GridBagConstraints( 0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblStyle.setText("Style:"); } { lblYeast = new JLabel(); pnlDetails.add(lblYeast, new GridBagConstraints( 0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblYeast.setText("Yeast:"); } { lblPreBoil = new JLabel(); pnlDetails.add(lblPreBoil, new GridBagConstraints( 0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblPreBoil.setText("Pre boil:"); } { lblPostBoil = new JLabel(); pnlDetails.add(lblPostBoil, new GridBagConstraints( 0, 5, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblPostBoil.setText("Post boil:"); } { lblEffic = new JLabel(); pnlDetails.add(lblEffic, new GridBagConstraints( 3, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblEffic.setText("Effic:"); } { lblAtten = new JLabel(); pnlDetails.add(lblAtten, new GridBagConstraints( 3, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblAtten.setText("Atten:"); } { lblOG = new JLabel(); pnlDetails.add(lblOG, new GridBagConstraints( 5, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblOG.setText("OG:"); } { lblFG = new JLabel(); pnlDetails.add(lblFG, new GridBagConstraints( 5, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblFG.setText("FG:"); } { lblIBU = new JLabel(); pnlDetails.add(lblIBU, new GridBagConstraints( 7, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblIBU.setText("IBU:"); } { lblAlc = new JLabel(); pnlDetails.add(lblAlc, new GridBagConstraints( 7, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblAlc.setText("%Alc:"); } { lblColour = new JLabel(); pnlDetails.add(lblColour, new GridBagConstraints( 7, 2, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblColour.setText("Colour:"); } { txtDate = new JFormattedTextField(); pnlDetails.add(txtDate, new GridBagConstraints( 1, 1, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); txtDate.setText("Date"); txtDate.addFocusListener(this); txtDate.addActionListener(this); } { cmbStyleModel = new ComboModel(); cmbStyle = new JComboBox(); pnlDetails.add(cmbStyle, new GridBagConstraints( 1, 2, 5, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); cmbStyle.setModel(cmbStyleModel); cmbStyle.setMaximumSize(new java.awt.Dimension(100, 32767)); cmbStyle.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { Style s = (Style) cmbStyleModel.getSelectedItem(); if (myRecipe != null && s != myRecipe.getStyleObj()) { myRecipe.setStyle(s); } descriptionTextArea.setText(s.getDescription()); cmbStyle.setToolTipText(multiLineToolTip(50,s.getDescription())); } }); } { txtPreBoil = new JFormattedTextField(); pnlDetails.add(txtPreBoil, new GridBagConstraints( 1, 4, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); txtPreBoil.setText("Pre Boil"); txtPreBoil.addFocusListener(this); txtPreBoil.addActionListener(this); } { postBoilText = new JFormattedTextField(); pnlDetails.add(postBoilText, new GridBagConstraints( 1, 5, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); postBoilText.setText("Post Boil"); postBoilText.addFocusListener(new FocusAdapter() { public void focusLost(FocusEvent evt) { myRecipe.setPostBoil(Double.parseDouble(postBoilText.getText() .toString())); displayRecipe(); } }); postBoilText.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { myRecipe.setPostBoil(Double.parseDouble(postBoilText.getText() .toString())); displayRecipe(); } }); } { lblComments = new JLabel(); pnlDetails.add(lblComments, new GridBagConstraints( 6, 3, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblComments.setText("Comments:"); } { SpinnerNumberModel spnEfficModel = new SpinnerNumberModel(75.0, 0.0, 100.0, 1.0); spnEffic = new JSpinner(); pnlDetails.add(spnEffic, new GridBagConstraints( 4, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); spnEffic.setModel(spnEfficModel); spnEffic.setMaximumSize(new java.awt.Dimension(70, 32767)); spnEffic.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent evt) { myRecipe.setEfficiency(Double.parseDouble(spnEffic.getValue() .toString())); displayRecipe(); } }); spnEffic.setEditor(new JSpinner.NumberEditor(spnEffic, "00.#")); spnEffic.getEditor().setPreferredSize(new java.awt.Dimension(28, 16)); } { SpinnerNumberModel spnAttenModel = new SpinnerNumberModel(75.0, 0.0, 100.0, 1.0); spnAtten = new JSpinner(); pnlDetails.add(spnAtten, new GridBagConstraints( 4, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); spnAtten.setModel(spnAttenModel); spnAtten.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent evt) { myRecipe.setAttenuation(Double.parseDouble(spnAtten.getValue() .toString())); displayRecipe(); } }); spnAtten.setEditor(new JSpinner.NumberEditor(spnAtten, "00.#")); } { SpinnerNumberModel spnOgModel = new SpinnerNumberModel(1.000, 0.900, 2.000, 0.001); spnOG = new JSpinner(); pnlDetails.add(spnOG, new GridBagConstraints( 6, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); spnOG.setModel(spnOgModel); spnOG.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent evt) { myRecipe.setEstOg(Double.parseDouble(spnOG.getValue() .toString())); displayRecipe(); } }); spnOG.setEditor(new JSpinner.NumberEditor(spnOG, "0.000")); spnOG.getEditor().setPreferredSize(new java.awt.Dimension(20, 16)); } { SpinnerNumberModel spnFgModel = new SpinnerNumberModel(1.000, 0.900, 2.000, 0.001); spnFG = new JSpinner(); pnlDetails.add(spnFG, new GridBagConstraints( 6, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); spnFG.setModel(spnFgModel); spnFG.setEditor(new JSpinner.NumberEditor(spnFG, "0.000")); spnFG.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent evt) { // set the new FG, and update alc: myRecipe.setEstFg(Double.parseDouble(spnFG.getValue() .toString())); displayRecipe(); } }); } { lblIBUvalue = new JLabel(); pnlDetails.add(lblIBUvalue, new GridBagConstraints( 8, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblIBUvalue.setText("IBUs"); } { lblColourValue = new JLabel(); pnlDetails.add(lblColourValue, new GridBagConstraints( 8, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblColourValue.setText("Colour"); } { lblAlcValue = new JLabel(); pnlDetails.add(lblAlcValue, new GridBagConstraints( 8, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblAlcValue.setText("Alc"); } { scpComments = new JScrollPane(); pnlDetails.add(scpComments, new GridBagConstraints( 6, 4, 3, 2, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); { txtComments = new JTextArea(); scpComments.setViewportView(txtComments); txtComments.setText("Comments"); txtComments.setWrapStyleWord(true); txtComments.setPreferredSize(new java.awt.Dimension(117, 42)); txtComments.addFocusListener(new FocusAdapter() { public void focusLost(FocusEvent evt) { if (!txtComments.getText().equals(myRecipe.getComments())) { myRecipe.setComments(txtComments.getText()); } } }); } } { cmbYeastModel = new ComboModel(); cmbYeast = new JComboBox(); pnlDetails.add(cmbYeast, new GridBagConstraints( 1, 3, 5, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); cmbYeast.setModel(cmbYeastModel); cmbYeast.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { Yeast y = (Yeast) cmbYeastModel.getSelectedItem(); if (myRecipe != null && y != myRecipe.getYeastObj()) { myRecipe.setYeast(y); } cmbYeast.setToolTipText(multiLineToolTip(40,y.getDescription())); } }); } { cmbSizeUnitsModel = new ComboModel(); cmbSizeUnits = new JComboBox(); pnlDetails.add(cmbSizeUnits, new GridBagConstraints( 2, 4, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); cmbSizeUnits.setModel(cmbSizeUnitsModel); cmbSizeUnits.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { String q = (String) cmbSizeUnits.getSelectedItem(); if (myRecipe != null && q != myRecipe.getVolUnits()) { myRecipe.setPostBoilVolUnits(q); displayRecipe(); } } }); } { lblSizeUnits = new JLabel(); pnlDetails.add(lblSizeUnits, new GridBagConstraints( 2, 5, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); lblSizeUnits.setText("Size Units"); } { boilTimeLable = new JLabel(); pnlDetails.add(boilTimeLable, new GridBagConstraints( 4, 4, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); boilTimeLable.setText("Boil Min:"); } { evapLabel = new JLabel(); pnlDetails.add(evapLabel, new GridBagConstraints( 4, 5, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); evapLabel.setText("Evap/hr:"); } { boilMinText = new JTextField(); pnlDetails.add(boilMinText, new GridBagConstraints( 5, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); boilMinText.setText("60"); boilMinText.addFocusListener(this); boilMinText.addActionListener(this); } { evapText = new JTextField(); pnlDetails.add(evapText, new GridBagConstraints( 5, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); evapText.setText("4"); evapText.addFocusListener(this); evapText.addActionListener(this); } } { pnlStyle = new JPanel(); FlowLayout pnlStyleLayout = new FlowLayout(); pnlStyle.setLayout(pnlStyleLayout); jTabbedPane1.addTab("Style", null, pnlStyle, null); { lblStyle2 = new JLabel(); pnlStyle.add(lblStyle2); lblStyle2.setText("Style:"); } { ComboBoxModel cmbStyle2Model = new DefaultComboBoxModel(new String[]{ "Item One", "Item Two"}); cmbStyle2 = new JComboBox(); pnlStyle.add(cmbStyle2, new GridBagConstraints( 1, 2, 5, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); cmbStyle2.setModel(cmbStyle2Model); } { jPanel2 = new JPanel(); GridBagLayout jPanel2Layout1 = new GridBagLayout(); jPanel2Layout1.columnWeights = new double[]{0.1, 0.1, 0.1, 0.1}; jPanel2Layout1.columnWidths = new int[]{7, 7, 7, 7}; jPanel2Layout1.rowWeights = new double[]{0.1, 0.1, 0.1, 0.1, 0.1, 0.1}; jPanel2Layout1.rowHeights = new int[]{7, 7, 7, 7, 7, 7}; jPanel2.setPreferredSize(new java.awt.Dimension(179, 120)); jPanel2.setLayout(jPanel2Layout1); pnlStyle.add(jPanel2); jPanel2.setBorder(BorderFactory.createTitledBorder(new LineBorder( new java.awt.Color(0, 0, 0), 1, false), "Recipe Conformance:", TitledBorder.LEADING, TitledBorder.TOP, new java.awt.Font( "Dialog", 0, 12), new java.awt.Color(0, 0, 0))); { jLabel5 = new JLabel(); jPanel2.add(jLabel5, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel5.setText("OG:"); jLabel5.setBounds(74, 3, 60, 30); } { jLabel1 = new JLabel(); jPanel2.add(jLabel1, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); GridLayout jLabel1Layout = new GridLayout(1, 1); jLabel1.setLayout(jLabel1Layout); jLabel1.setText("Low:"); } { jLabel2 = new JLabel(); jPanel2.add(jLabel2, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel2.setText("Recipe:"); } { jLabel3 = new JLabel(); jPanel2.add(jLabel3, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel3.setText("High:"); } { jLabel4 = new JLabel(); jPanel2.add(jLabel4, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel4.setText("IBU:"); } { jLabel6 = new JLabel(); jPanel2.add(jLabel6, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel6.setText("Colour:"); } { jLabel7 = new JLabel(); jPanel2.add(jLabel7, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel7.setText("ABV:"); } } { jScrollPane3 = new JScrollPane(); pnlStyle.add(jScrollPane3); { txaStyles = new JTextArea(); jScrollPane3.setViewportView(txaStyles); txaStyles.setText("Matched Styles"); } } { sldMatch = new JSlider(); pnlStyle.add(sldMatch); } } { miscPanel = new MiscPanel(myRecipe); jTabbedPane1.addTab("Misc", null, miscPanel, null); } { notesPanel = new NotesPanel(); jTabbedPane1.addTab("Notes", null, notesPanel, null); } } { pnlTables = new JPanel(); BoxLayout pnlMaltsLayout = new BoxLayout(pnlTables, javax.swing.BoxLayout.Y_AXIS); pnlMain.add(pnlTables, new GridBagConstraints(0, 2, 1, 1, 0.5, 0.5, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); pnlTables.setLayout(pnlMaltsLayout); { pnlMalt = new JPanel(); pnlTables.add(pnlMalt); BorderLayout pnlMaltLayout1 = new BorderLayout(); FlowLayout pnlMaltLayout = new FlowLayout(); pnlMalt.setBorder(BorderFactory.createTitledBorder(new LineBorder( new java.awt.Color(0, 0, 0), 1, false), "Fermentables", TitledBorder.LEADING, TitledBorder.TOP, new java.awt.Font("Dialog", 1, 12), new java.awt.Color(51, 51, 51))); pnlMalt.setLayout(pnlMaltLayout1); { jScrollPane1 = new JScrollPane(); pnlMalt.add(jScrollPane1, BorderLayout.CENTER); { tblMaltModel = new MaltTableModel(this); tblMalt = new JTable(){ public String getToolTipText(MouseEvent e) { String tip = null; java.awt.Point p = e.getPoint(); int rowIndex = rowAtPoint(p); tip = multiLineToolTip(40,tblMaltModel.getDescriptionAt(rowIndex)); return tip; } }; jScrollPane1.setViewportView(tblMalt); tblMalt.setModel(tblMaltModel); tblMalt.setAutoCreateColumnsFromModel(false); tblMalt.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { int i = tblMalt.getSelectedRow(); // descriptionTextArea.setText(myRecipe.getMaltDescription(i)); } }); TableColumn maltColumn = tblMalt.getColumnModel().getColumn(0); // set up malt list combo JComboBox maltComboBox = new JComboBox(); cmbMaltModel = new ComboModel(); maltComboBox.setModel(cmbMaltModel); maltColumn.setCellEditor(new DefaultCellEditor(maltComboBox)); maltComboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { Fermentable f = (Fermentable) cmbMaltModel .getSelectedItem(); int i = tblMalt.getSelectedRow(); if (myRecipe != null && i != -1) { Fermentable f2 = myRecipe.getFermentable(i); f2.setLov(f.getLov()); f2.setPppg(f.getPppg()); f2.setDescription(f.getDescription()); f2.setMashed(f.getMashed()); f2.setSteep(f.getSteep()); } } }); // set up malt units combo JComboBox maltUnitsComboBox = new JComboBox(); cmbMaltUnitsModel = new ComboModel(); maltUnitsComboBox.setModel(cmbMaltUnitsModel); maltColumn = tblMalt.getColumnModel().getColumn(2); maltColumn.setCellEditor(new DefaultCellEditor(maltUnitsComboBox)); maltUnitsComboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { String u = (String) cmbMaltUnitsModel.getSelectedItem(); int i = tblMalt.getSelectedRow(); if (myRecipe != null && i != -1) { Fermentable f2 = myRecipe.getFermentable(i); f2.setUnitsFull(u); myRecipe.calcMaltTotals(); displayRecipe(); } } }); } } { tblMaltTotalsModel = new DefaultTableModel(new String[][]{{""}}, new String[]{"Malt", "Amount", "Units", "Points", "Lov", "Cost/U", "%"}); tblMaltTotals = new JTable(); pnlMalt.add(tblMaltTotals, BorderLayout.SOUTH); tblMaltTotals.setModel(tblMaltTotalsModel); tblMaltTotals.getTableHeader().setEnabled(false); tblMaltTotals.setAutoCreateColumnsFromModel(false); } } { pnlMaltButtons = new JPanel(); pnlTables.add(pnlMaltButtons); FlowLayout pnlMaltButtonsLayout = new FlowLayout(); pnlMaltButtonsLayout.setAlignment(FlowLayout.LEFT); pnlMaltButtonsLayout.setVgap(0); pnlMaltButtons.setLayout(pnlMaltButtonsLayout); pnlMaltButtons.setPreferredSize(new java.awt.Dimension(390, 34)); { tlbMalt = new JToolBar(); pnlMaltButtons.add(tlbMalt); tlbMalt.setPreferredSize(new java.awt.Dimension(140, 20)); tlbMalt.setFloatable(false); { btnAddMalt = new JButton(); tlbMalt.add(btnAddMalt); btnAddMalt.setText("+"); btnAddMalt.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (myRecipe != null) { Fermentable f = new Fermentable(myRecipe.getMaltUnits()); myRecipe.addMalt(f); tblMalt.updateUI(); displayRecipe(); } } }); } { btnDelMalt = new JButton(); tlbMalt.add(btnDelMalt); btnDelMalt.setText("-"); btnDelMalt.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (myRecipe != null) { int i = tblMalt.getSelectedRow(); myRecipe.delMalt(i); tblMalt.updateUI(); displayRecipe(); } } }); } } } { pnlHops = new JPanel(); BorderLayout pnlHopsLayout = new BorderLayout(); pnlHops.setBorder(BorderFactory.createTitledBorder(new LineBorder( new java.awt.Color(0, 0, 0), 1, false), "Hops", TitledBorder.LEADING, TitledBorder.TOP, new java.awt.Font("Dialog", 1, 12), new java.awt.Color(51, 51, 51))); pnlHops.setLayout(pnlHopsLayout); pnlTables.add(pnlHops); { tblHopsTotalsModel = new DefaultTableModel(new String[][]{{""}}, new String[]{"1", "2","3","4","5","6","7","8","9"}); tblHopsTotals = new JTable(); pnlHops.add(tblHopsTotals, BorderLayout.SOUTH); tblHopsTotals.setModel(tblHopsTotalsModel); tblHopsTotals.setAutoCreateColumnsFromModel(false); } { jScrollPane2 = new JScrollPane(); pnlHops.add(jScrollPane2, BorderLayout.CENTER); { tblHopsModel = new HopsTableModel(this); tblHops = new JTable(); jScrollPane2.setViewportView(tblHops); tblHops.setModel(tblHopsModel); tblHops.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { int i = tblHops.getSelectedRow(); descriptionTextArea.setText(myRecipe.getHopDescription(i)); } }); TableColumn hopColumn = tblHops.getColumnModel().getColumn(0); JComboBox hopComboBox = new JComboBox(); cmbHopsModel = new ComboModel(); hopComboBox.setModel(cmbHopsModel); hopColumn.setCellEditor(new DefaultCellEditor(hopComboBox)); hopComboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { Hop h = (Hop) cmbHopsModel.getSelectedItem(); int i = tblHops.getSelectedRow(); if (myRecipe != null && i != -1) { Hop h2 = (Hop) myRecipe.getHop(i); h2.setAlpha(h.getAlpha()); h2.setDescription(h.getDescription()); } } }); // set up hop units combo JComboBox hopsUnitsComboBox = new JComboBox(); cmbHopsUnitsModel = new ComboModel(); hopsUnitsComboBox.setModel(cmbHopsUnitsModel); hopColumn = tblHops.getColumnModel().getColumn(4); hopColumn.setCellEditor(new DefaultCellEditor(hopsUnitsComboBox)); hopsUnitsComboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { String u = (String) cmbHopsUnitsModel.getSelectedItem(); int i = tblHops.getSelectedRow(); if (myRecipe != null && i != -1) { Hop h = (Hop) myRecipe.getHop(i); h.setUnitsFull(u); myRecipe.calcHopsTotals(); // tblHops.updateUI(); displayRecipe(); } } }); // set up hop type combo String [] forms = {"Leaf","Pellet","Plug"}; JComboBox hopsFormComboBox = new JComboBox(forms); hopColumn = tblHops.getColumnModel().getColumn(1); hopColumn.setCellEditor(new DefaultCellEditor(hopsFormComboBox)); // set up hop add combo String [] add = {"Boil","FWH","Dry", "Mash"}; JComboBox hopsAddComboBox = new JComboBox(add); hopColumn = tblHops.getColumnModel().getColumn(5); hopColumn.setCellEditor(new DefaultCellEditor(hopsAddComboBox)); } } } { pnlHopsButtons = new JPanel(); FlowLayout pnlHopsButtonsLayout = new FlowLayout(); pnlHopsButtonsLayout.setAlignment(FlowLayout.LEFT); pnlHopsButtonsLayout.setVgap(0); pnlHopsButtons.setLayout(pnlHopsButtonsLayout); pnlTables.add(pnlHopsButtons); pnlHopsButtons.setPreferredSize(new java.awt.Dimension(512, 16)); { tlbHops = new JToolBar(); pnlHopsButtons.add(tlbHops); tlbHops.setPreferredSize(new java.awt.Dimension(70, 19)); tlbHops.setFloatable(false); { btnAddHop = new JButton(); tlbHops.add(btnAddHop); btnAddHop.setText("+"); btnAddHop.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (myRecipe != null) { Hop h = new Hop(myRecipe.getHopUnits()); myRecipe.addHop(h); tblHops.updateUI(); displayRecipe(); } } }); } { btnDelHop = new JButton(); tlbHops.add(btnDelHop); btnDelHop.setText("-"); btnDelHop.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (myRecipe != null) { int i = tblHops.getSelectedRow(); myRecipe.delHop(i); tblHops.updateUI(); displayRecipe(); } } }); } } } } { descriptionPanel = new JPanel(); FlowLayout descriptionPanelLayout = new FlowLayout(); descriptionPanel.setLayout(descriptionPanelLayout); pnlMain.add(descriptionPanel, new GridBagConstraints( 1, 0, 1, 3, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.VERTICAL, new Insets(0, 0, 0, 0), 0, 0)); descriptionPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); { descriptionTextArea = new JTextArea(); descriptionPanel.add(descriptionTextArea); descriptionTextArea.setText("Description"); descriptionTextArea.setFont(new java.awt.Font("Dialog", 0, 10)); descriptionTextArea.setEditable(false); descriptionTextArea.setFocusable(false); descriptionTextArea.setLineWrap(true); descriptionTextArea.setWrapStyleWord(true); } } { statusPanel = new JPanel(); FlowLayout statusPanelLayout = new FlowLayout(); statusPanelLayout.setAlignment(FlowLayout.LEFT); statusPanel.setLayout(statusPanelLayout); pnlMain.add(statusPanel, new GridBagConstraints( 0, 3, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); statusPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); { fileNameLabel = new JLabel(); statusPanel.add(fileNameLabel); fileNameLabel.setText("File Name"); fileNameLabel.setFont(new java.awt.Font("Dialog",1,10)); } } } { jMenuBar1 = new JMenuBar(); setJMenuBar(jMenuBar1); { jMenu3 = new JMenu(); jMenuBar1.add(jMenu3); jMenu3.setText("File"); { newFileMenuItem = new JMenuItem(); jMenu3.add(newFileMenuItem); newFileMenuItem.setText("New"); newFileMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // This is just a test right now to see that // stuff is changed. myRecipe = new Recipe(); attachRecipeData(); displayRecipe(); } }); } { openFileMenuItem = new JMenuItem(); jMenu3.add(openFileMenuItem); openFileMenuItem.setText("Open"); openFileMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // Show open dialog; this method does // not return until the dialog is closed int returnVal = fileChooser.showOpenDialog(jMenuBar1); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); System.out.print("Opening: " + file.getName() + ".\n"); ImportXml imp = new ImportXml(file.toString()); myRecipe = imp.handler.getRecipe(); myRecipe.calcMaltTotals(); myRecipe.calcHopsTotals(); myRecipe.mash.calcMashSchedule(); attachRecipeData(); displayRecipe(); // show true file name fileName = file.getName(); fileNameLabel.setText(fileName); } else { System.out.print("Open command cancelled by user.\n"); } } }); } { saveMenuItem = new JMenuItem(); jMenu3.add(saveMenuItem); saveMenuItem.setText("Save"); } { saveAsMenuItem = new JMenuItem(); jMenu3.add(saveAsMenuItem); saveAsMenuItem.setText("Save As ..."); saveAsMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (DEBUG){ // This is just a test right now to see that // stuff is changed. System.out.print(myRecipe.toXML()); } // Show save dialog; this method does // not return until the dialog is closed int returnVal = fileChooser.showSaveDialog(jMenuBar1); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); //This is where a real application would save the file. try { FileWriter out = new FileWriter(file); out.write(myRecipe.toXML()); out.close(); } catch (Exception e){ // TODO: handle io exception } } else { System.out.print("Save command cancelled by user.\n"); } } }); } { exportMenu = new JMenu(); jMenu3.add(exportMenu); exportMenu.setText("Export"); { exportHTMLmenu = new JMenuItem(); exportMenu.add(exportHTMLmenu); exportHTMLmenu.setText("HTML"); exportHTMLmenu.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // Show save dialog; this method does // not return until the dialog is closed fileChooser.setSelectedFile(new File(myRecipe.getName()+".html")); int returnVal = fileChooser.showSaveDialog(jMenuBar1); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); //This is where a real application would save the file. try { saveAsHTML(file); } catch (Exception e){ // TODO: handle io exception } } else { System.out.print("Save command cancelled by user.\n"); } } }); exportTextMenuItem = new JMenuItem(); exportMenu.add(exportTextMenuItem); exportTextMenuItem.setText("Text"); exportTextMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // Show save dialog; this method does // not return until the dialog is closed fileChooser.setSelectedFile(new File(myRecipe.getName()+".txt")); int returnVal = fileChooser.showSaveDialog(jMenuBar1); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); //This is where a real application would save the file. try { FileWriter out = new FileWriter(file); out.write(myRecipe.toText()); out.close(); } catch (Exception e){ // TODO: handle io exception } } else { System.out.print("Export text command cancelled by user.\n"); } } }); } } { jSeparator2 = new JSeparator(); jMenu3.add(jSeparator2); } { exitMenuItem = new JMenuItem(); jMenu3.add(exitMenuItem); exitMenuItem.setText("Exit"); exitMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // exit program System.exit(0); } }); } } { jMenu4 = new JMenu(); jMenuBar1.add(jMenu4); jMenu4.setText("Edit"); { final JFrame owner = this; editPrefsMenuItem = new JMenuItem(); jMenu4.add(editPrefsMenuItem); editPrefsMenuItem.setText("Preferences..."); editPrefsMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { PreferencesDialog d = new PreferencesDialog(owner, preferences); d.setVisible(true); } }); } { jSeparator1 = new JSeparator(); jMenu4.add(jSeparator1); } { deleteMenuItem = new JMenuItem(); jMenu4.add(deleteMenuItem); deleteMenuItem.setText("Delete"); deleteMenuItem.setEnabled(false); } } { mnuView = new JMenu(); jMenuBar1.add(mnuView); mnuView.setText("View"); { mashManagerMenuItem = new JMenuItem(); mnuView.add(mashManagerMenuItem); mashManagerMenuItem.setText("Mash Manager..."); mashManagerMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { mashMgr = new MashManager(myRecipe); mashMgr.setVisible(true); } }); } } { jMenu5 = new JMenu(); jMenuBar1.add(jMenu5); jMenu5.setText("Help"); { helpMenuItem = new JMenuItem(); jMenu5.add(helpMenuItem); helpMenuItem.setText("Help"); } { aboutMenuItem = new JMenuItem(); jMenu5.add(aboutMenuItem); aboutMenuItem.setText("About..."); final JFrame owner = this; aboutMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { aboutDlg = new AboutDialog(owner); aboutDlg.setVisible(true); } }); } } } } catch (Exception e) { e.printStackTrace(); } }
1,116,829
public void actionPerformed(ActionEvent evt) { String u = (String) cmbMaltUnitsModel.getSelectedItem(); int i = tblMalt.getSelectedRow(); if (myRecipe != null && i != -1) { Fermentable f2 = myRecipe.getFermentable(i); f2.setUnitsFull(u); myRecipe.calcMaltTotals(); displayRecipe(); } }
public void actionPerformed(ActionEvent evt) { Fermentable f = (Fermentable) cmbMaltModel .getSelectedItem(); int i = tblMalt.getSelectedRow(); if (myRecipe != null && i != -1) { Fermentable f2 = myRecipe.getFermentable(i); f2.setUnitsFull(u); myRecipe.calcMaltTotals(); displayRecipe(); } }
1,116,831
public void actionPerformed(ActionEvent evt) { String u = (String) cmbMaltUnitsModel.getSelectedItem(); int i = tblMalt.getSelectedRow(); if (myRecipe != null && i != -1) { Fermentable f2 = myRecipe.getFermentable(i); f2.setUnitsFull(u); myRecipe.calcMaltTotals(); displayRecipe(); } }
public void actionPerformed(ActionEvent evt) { String u = (String) cmbMaltUnitsModel.getSelectedItem(); int i = tblMalt.getSelectedRow(); if (myRecipe != null && i != -1) { Fermentable f2 = myRecipe.getFermentable(i); f2.setUnitsFull(u); myRecipe.calcMaltTotals(); displayRecipe(); } }
1,116,832
public void actionPerformed(ActionEvent evt) { if (myRecipe != null) { Fermentable f = new Fermentable(myRecipe.getMaltUnits()); myRecipe.addMalt(f); tblMalt.updateUI(); displayRecipe(); } }
public void actionPerformed(ActionEvent evt) { if (myRecipe != null) { Fermentable f = new Fermentable(myRecipe.getMaltUnits()); myRecipe.addMalt(f); tblMalt.updateUI(); displayRecipe(); } }
1,116,833
public void actionPerformed(ActionEvent evt) { if (myRecipe != null) { int i = tblMalt.getSelectedRow(); myRecipe.delMalt(i); tblMalt.updateUI(); displayRecipe(); } }
public void actionPerformed(ActionEvent evt) { if (myRecipe != null) { int i = tblMalt.getSelectedRow(); myRecipe.delMalt(i); tblMalt.updateUI(); displayRecipe(); } }
1,116,834
public void actionPerformed(ActionEvent evt) { String u = (String) cmbHopsUnitsModel.getSelectedItem(); int i = tblHops.getSelectedRow(); if (myRecipe != null && i != -1) { Hop h = (Hop) myRecipe.getHop(i); h.setUnitsFull(u); myRecipe.calcHopsTotals(); // tblHops.updateUI(); displayRecipe(); } }
public void actionPerformed(ActionEvent evt) { Hop h = (Hop) cmbHopsModel.getSelectedItem(); int i = tblHops.getSelectedRow(); if (myRecipe != null && i != -1) { Hop h = (Hop) myRecipe.getHop(i); h.setUnitsFull(u); myRecipe.calcHopsTotals(); // tblHops.updateUI(); displayRecipe(); } }
1,116,835
public void actionPerformed(ActionEvent evt) { String u = (String) cmbHopsUnitsModel.getSelectedItem(); int i = tblHops.getSelectedRow(); if (myRecipe != null && i != -1) { Hop h = (Hop) myRecipe.getHop(i); h.setUnitsFull(u); myRecipe.calcHopsTotals(); // tblHops.updateUI(); displayRecipe(); } }
public void actionPerformed(ActionEvent evt) { String u = (String) cmbHopsUnitsModel.getSelectedItem(); int i = tblHops.getSelectedRow(); if (myRecipe != null && i != -1) { Hop h = (Hop) myRecipe.getHop(i); h.setUnitsFull(u); myRecipe.calcHopsTotals(); // tblHops.updateUI(); displayRecipe(); } }
1,116,836
public void actionPerformed(ActionEvent evt) { if (myRecipe != null) { Hop h = new Hop(myRecipe.getHopUnits()); myRecipe.addHop(h); tblHops.updateUI(); displayRecipe(); } }
public void actionPerformed(ActionEvent evt) { if (myRecipe != null) { Hop h = new Hop(myRecipe.getHopUnits()); myRecipe.addHop(h); tblHops.updateUI(); displayRecipe(); } }
1,116,837
public void actionPerformed(ActionEvent evt) { if (myRecipe != null) { Hop h = new Hop(myRecipe.getHopUnits()); myRecipe.addHop(h); tblHops.updateUI(); displayRecipe(); } }
public void actionPerformed(ActionEvent evt) { if (myRecipe != null) { Hop h = new Hop(myRecipe.getHopUnits()); myRecipe.addHop(h); tblHops.updateUI(); displayRecipe();
1,116,838
public void actionPerformed(ActionEvent evt) { if (myRecipe != null) { int i = tblHops.getSelectedRow(); myRecipe.delHop(i); tblHops.updateUI(); displayRecipe(); } }
public void actionPerformed(ActionEvent evt) { if (myRecipe != null) { int i = tblHops.getSelectedRow(); myRecipe.delHop(i); tblHops.updateUI(); displayRecipe(); } }
1,116,839
public void actionPerformed(ActionEvent evt) { // This is just a test right now to see that // stuff is changed. myRecipe = new Recipe(); attachRecipeData(); displayRecipe(); }
public void actionPerformed(ActionEvent evt) { // This is just a test right now to see that // stuff is changed. myRecipe = new Recipe(); attachRecipeData(); displayRecipe(); }
1,116,840
public void actionPerformed(ActionEvent evt) { // Show open dialog; this method does // not return until the dialog is closed int returnVal = fileChooser.showOpenDialog(jMenuBar1); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); System.out.print("Opening: " + file.getName() + ".\n"); ImportXml imp = new ImportXml(file.toString()); myRecipe = imp.handler.getRecipe(); myRecipe.calcMaltTotals(); myRecipe.calcHopsTotals(); myRecipe.mash.calcMashSchedule(); attachRecipeData(); displayRecipe(); // show true file name fileName = file.getName(); fileNameLabel.setText(fileName); } else { System.out.print("Open command cancelled by user.\n"); } }
public void actionPerformed(ActionEvent evt) { // Show open dialog; this method does // not return until the dialog is closed int returnVal = fileChooser.showOpenDialog(jMenuBar1); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); System.out.print("Opening: " + file.getName() + ".\n"); ImportXml imp = new ImportXml(file.toString()); myRecipe = imp.handler.getRecipe(); myRecipe.calcMaltTotals(); myRecipe.calcHopsTotals(); myRecipe.mash.calcMashSchedule(); attachRecipeData(); displayRecipe(); // show true file name fileName = file.getName(); fileNameLabel.setText(fileName); } else { System.out.print("Open command cancelled by user.\n"); } }
1,116,841
public void actionPerformed(ActionEvent evt) { if (DEBUG){ // This is just a test right now to see that // stuff is changed. System.out.print(myRecipe.toXML()); } // Show save dialog; this method does // not return until the dialog is closed int returnVal = fileChooser.showSaveDialog(jMenuBar1); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); //This is where a real application would save the file. try { FileWriter out = new FileWriter(file); out.write(myRecipe.toXML()); out.close(); } catch (Exception e){ // TODO: handle io exception } } else { System.out.print("Save command cancelled by user.\n"); } }
public void actionPerformed(ActionEvent evt) { if (DEBUG){ // This is just a test right now to see that // stuff is changed. System.out.print(myRecipe.toXML()); } // Show save dialog; this method does // not return until the dialog is closed int returnVal = fileChooser.showSaveDialog(jMenuBar1); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); //This is where a real application would save the file. try { FileWriter out = new FileWriter(file); out.write(myRecipe.toXML()); out.close(); } catch (Exception e){ // TODO: handle io exception } } else { System.out.print("Save command cancelled by user.\n"); } }
1,116,842
public void actionPerformed(ActionEvent evt) { if (DEBUG){ // This is just a test right now to see that // stuff is changed. System.out.print(myRecipe.toXML()); } // Show save dialog; this method does // not return until the dialog is closed int returnVal = fileChooser.showSaveDialog(jMenuBar1); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); //This is where a real application would save the file. try { FileWriter out = new FileWriter(file); out.write(myRecipe.toXML()); out.close(); } catch (Exception e){ // TODO: handle io exception } } else { System.out.print("Save command cancelled by user.\n"); } }
public void actionPerformed(ActionEvent evt) { if (DEBUG){ // This is just a test right now to see that // stuff is changed. System.out.print(myRecipe.toXML()); } // Show save dialog; this method does // not return until the dialog is closed int returnVal = fileChooser.showSaveDialog(jMenuBar1); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); //This is where a real application would save the file. try { FileWriter out = new FileWriter(file); out.write(myRecipe.toXML()); out.close(); } catch (Exception e){ // TODO: handle io exception } } else { System.out.print("Save command cancelled by user.\n"); } }
1,116,843
public void actionPerformed(ActionEvent evt) { // Show save dialog; this method does // not return until the dialog is closed fileChooser.setSelectedFile(new File(myRecipe.getName()+".html")); int returnVal = fileChooser.showSaveDialog(jMenuBar1); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); //This is where a real application would save the file. try { saveAsHTML(file); } catch (Exception e){ // TODO: handle io exception } } else { System.out.print("Save command cancelled by user.\n"); } }
public void actionPerformed(ActionEvent evt) { // Show save dialog; this method does // not return until the dialog is closed fileChooser.setSelectedFile(new File(myRecipe.getName()+".html")); int returnVal = fileChooser.showSaveDialog(jMenuBar1); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); //This is where a real application would save the file. try { saveAsHTML(file); } catch (Exception e){ // TODO: handle io exception } } else { System.out.print("Save command cancelled by user.\n"); } }
1,116,844
public void actionPerformed(ActionEvent evt) { // Show save dialog; this method does // not return until the dialog is closed fileChooser.setSelectedFile(new File(myRecipe.getName()+".txt")); int returnVal = fileChooser.showSaveDialog(jMenuBar1); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); //This is where a real application would save the file. try { FileWriter out = new FileWriter(file); out.write(myRecipe.toText()); out.close(); } catch (Exception e){ // TODO: handle io exception } } else { System.out.print("Export text command cancelled by user.\n"); } }
public void actionPerformed(ActionEvent evt) { // Show save dialog; this method does // not return until the dialog is closed fileChooser.setSelectedFile(new File(myRecipe.getName()+".html")); int returnVal = fileChooser.showSaveDialog(jMenuBar1); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); //This is where a real application would save the file. try { FileWriter out = new FileWriter(file); out.write(myRecipe.toText()); out.close(); } catch (Exception e){ // TODO: handle io exception } } else { System.out.print("Export text command cancelled by user.\n"); } }
1,116,845
public void actionPerformed(ActionEvent evt) { // Show save dialog; this method does // not return until the dialog is closed fileChooser.setSelectedFile(new File(myRecipe.getName()+".txt")); int returnVal = fileChooser.showSaveDialog(jMenuBar1); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); //This is where a real application would save the file. try { FileWriter out = new FileWriter(file); out.write(myRecipe.toText()); out.close(); } catch (Exception e){ // TODO: handle io exception } } else { System.out.print("Export text command cancelled by user.\n"); } }
public void actionPerformed(ActionEvent evt) { // Show save dialog; this method does // not return until the dialog is closed fileChooser.setSelectedFile(new File(myRecipe.getName()+".txt")); int returnVal = fileChooser.showSaveDialog(jMenuBar1); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); //This is where a real application would save the file. try { FileWriter out = new FileWriter(file); out.write(myRecipe.toText()); out.close(); } catch (Exception e){ // TODO: handle io exception } } else { System.out.print("Export text command cancelled by user.\n"); } }
1,116,846
public void actionPerformed(ActionEvent evt) { // Show save dialog; this method does // not return until the dialog is closed fileChooser.setSelectedFile(new File(myRecipe.getName()+".txt")); int returnVal = fileChooser.showSaveDialog(jMenuBar1); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); //This is where a real application would save the file. try { FileWriter out = new FileWriter(file); out.write(myRecipe.toText()); out.close(); } catch (Exception e){ // TODO: handle io exception } } else { System.out.print("Export text command cancelled by user.\n"); } }
public void actionPerformed(ActionEvent evt) { // Show save dialog; this method does // not return until the dialog is closed fileChooser.setSelectedFile(new File(myRecipe.getName()+".txt")); int returnVal = fileChooser.showSaveDialog(jMenuBar1); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); //This is where a real application would save the file. try { FileWriter out = new FileWriter(file); out.write(myRecipe.toText()); out.close(); } catch (Exception e){ // TODO: handle io exception } } else { System.out.print("Save command cancelled by user.\n"); } }
1,116,847