From: Dan B. <dan...@us...> - 2011-05-11 15:57:29
|
Update of /cvsroot/jmri/jmri/jmrit/operations/trains In directory vz-cvs-3.sog:/tmp/cvs-serv11707/src/jmri/jmrit/operations/trains Modified Files: TrainPrintUtilities.java TrainCommon.java Log Message: Operations enhancement, user can now specify local car message format and color Index: TrainPrintUtilities.java =================================================================== RCS file: /cvsroot/jmri/jmri/jmrit/operations/trains/TrainPrintUtilities.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** TrainPrintUtilities.java 6 Apr 2011 19:21:39 -0000 1.13 --- TrainPrintUtilities.java 11 May 2011 15:57:27 -0000 1.14 *************** *** 112,115 **** --- 112,119 ---- c = Setup.getDropColor(); } + else if(!Setup.getLocalPrefix().equals("") && line.startsWith(Setup.getLocalPrefix())){ + //log.debug("found a drop line"); + c = Setup.getLocalColor(); + } else if(!line.startsWith(TrainCommon.TAB)){ c = null; Index: TrainCommon.java =================================================================== RCS file: /cvsroot/jmri/jmri/jmrit/operations/trains/TrainCommon.java,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** TrainCommon.java 10 May 2011 21:59:40 -0000 1.32 --- TrainCommon.java 11 May 2011 15:57:27 -0000 1.33 *************** *** 36,39 **** --- 36,41 ---- private static final String LENGTHABV = Setup.LENGTHABV; protected static final String TAB = " "; + private static final boolean pickup = true; + private static final boolean local = true; EngineManager engineManager = EngineManager.instance(); *************** *** 59,63 **** String[] format = Setup.getPickupEngineMessageFormat(); for (int i=0; i<format.length; i++){ ! buf.append(getEngineAttribute(engine, format[i], true)); } addLine(file, buf.toString()); --- 61,65 ---- String[] format = Setup.getPickupEngineMessageFormat(); for (int i=0; i<format.length; i++){ ! buf.append(getEngineAttribute(engine, format[i], pickup)); } addLine(file, buf.toString()); *************** *** 68,72 **** String[] format = Setup.getDropEngineMessageFormat(); for (int i=0; i<format.length; i++){ ! buf.append(getEngineAttribute(engine, format[i], false)); } addLine(file, buf.toString()); --- 70,74 ---- String[] format = Setup.getDropEngineMessageFormat(); for (int i=0; i<format.length; i++){ ! buf.append(getEngineAttribute(engine, format[i], !pickup)); } addLine(file, buf.toString()); *************** *** 75,81 **** protected void pickupCar(PrintWriter file, Car car){ StringBuffer buf = new StringBuffer(Setup.getPickupCarPrefix()); String[] format = Setup.getPickupCarMessageFormat(); for (int i=0; i<format.length; i++){ ! String s = getCarAttribute(car, format[i], true); if (buf.length()+s.length()>lineLength()){ addLine(file, buf.toString()); --- 77,85 ---- protected void pickupCar(PrintWriter file, Car car){ StringBuffer buf = new StringBuffer(Setup.getPickupCarPrefix()); + if (car.getRouteLocation().equals(car.getRouteDestination())) + return; // print nothing local move, see dropCar String[] format = Setup.getPickupCarMessageFormat(); for (int i=0; i<format.length; i++){ ! String s = getCarAttribute(car, format[i], pickup, !local); if (buf.length()+s.length()>lineLength()){ addLine(file, buf.toString()); *************** *** 90,95 **** StringBuffer buf = new StringBuffer(Setup.getDropCarPrefix()); String[] format = Setup.getDropCarMessageFormat(); for (int i=0; i<format.length; i++){ ! String s = getCarAttribute(car, format[i], false); if (buf.length()+s.length()>lineLength()){ addLine(file, buf.toString()); --- 94,106 ---- StringBuffer buf = new StringBuffer(Setup.getDropCarPrefix()); String[] format = Setup.getDropCarMessageFormat(); + // local move? + boolean local = false; + if (car.getRouteLocation().equals(car.getRouteDestination())){ + buf = new StringBuffer(Setup.getLocalPrefix()); + format = Setup.getLocalMessageFormat(); + local = true; + } for (int i=0; i<format.length; i++){ ! String s = getCarAttribute(car, format[i], !pickup, local); if (buf.length()+s.length()>lineLength()){ addLine(file, buf.toString()); *************** *** 160,164 **** String[] format = Setup.getMissingCarMessageFormat(); for (int i=0; i<format.length; i++){ ! buf.append(getCarAttribute(car, format[i], false)); } addLine(file, buf.toString()); --- 171,175 ---- String[] format = Setup.getMissingCarMessageFormat(); for (int i=0; i<format.length; i++){ ! buf.append(getCarAttribute(car, format[i], false, false)); } addLine(file, buf.toString()); *************** *** 170,177 **** if (attribute.equals(Setup.MODEL)) return " "+ engine.getModel(); ! return getRollingStockAttribute(engine, attribute, pickup); } ! protected String getCarAttribute(Car car, String attribute, boolean pickup){ if (attribute.equals(Setup.LOAD)) return (car.isCaboose() || car.isPassenger())? tabString("", CarLoads.instance().getCurMaxNameLength()+1) --- 181,188 ---- if (attribute.equals(Setup.MODEL)) return " "+ engine.getModel(); ! return getRollingStockAttribute(engine, attribute, pickup, false); } ! protected String getCarAttribute(Car car, String attribute, boolean pickup, boolean local){ if (attribute.equals(Setup.LOAD)) return (car.isCaboose() || car.isPassenger())? tabString("", CarLoads.instance().getCurMaxNameLength()+1) *************** *** 183,190 **** else if (attribute.equals(Setup.PICKUP_COMMENT)) return " "+CarLoads.instance().getPickupComment(car.getType(), car.getLoad()); ! return getRollingStockAttribute(car, attribute, pickup); } ! protected String getRollingStockAttribute(RollingStock rs, String attribute, boolean pickup){ if (attribute.equals(Setup.NUMBER)) return " "+tabString(splitString(rs.getNumber()), Control.MAX_LEN_STRING_ROAD_NUMBER-4); --- 194,201 ---- else if (attribute.equals(Setup.PICKUP_COMMENT)) return " "+CarLoads.instance().getPickupComment(car.getType(), car.getLoad()); ! return getRollingStockAttribute(car, attribute, pickup, local); } ! protected String getRollingStockAttribute(RollingStock rs, String attribute, boolean pickup, boolean local){ if (attribute.equals(Setup.NUMBER)) return " "+tabString(splitString(rs.getNumber()), Control.MAX_LEN_STRING_ROAD_NUMBER-4); *************** *** 199,205 **** else if (attribute.equals(Setup.COLOR)) return " "+tabString(rs.getColor(), CarColors.instance().getCurMaxNameLength()); ! else if (attribute.equals(Setup.LOCATION) && pickup) return " "+rb.getString("from")+ " "+splitString(rs.getTrackName()); ! else if (attribute.equals(Setup.LOCATION) && !pickup) return " "+rb.getString("from")+ " "+splitString(rs.getLocationName()); else if (attribute.equals(Setup.DESTINATION) && pickup){ --- 210,216 ---- else if (attribute.equals(Setup.COLOR)) return " "+tabString(rs.getColor(), CarColors.instance().getCurMaxNameLength()); ! else if (attribute.equals(Setup.LOCATION) && (pickup || local)) return " "+rb.getString("from")+ " "+splitString(rs.getTrackName()); ! else if (attribute.equals(Setup.LOCATION) && !pickup && !local) return " "+rb.getString("from")+ " "+splitString(rs.getLocationName()); else if (attribute.equals(Setup.DESTINATION) && pickup){ |