📄 plot.java
字号:
} /** * Draw the axes and the accumulated points. */ public void paint(Graphics graphics) { if (_debug > 7) System.out.println("Plot: paint"); drawPlot(graphics,true); } /** Parse pxgraph style command line arguments. * This method exists only for backward compatibility with the X11 pxgraph * program. * @return The number of arguments read. * @exception ptplot.CmdLineArgException if there is a problem parsing * the command line arguments passed in. */ public int parseArgs(String args[]) throws CmdLineArgException { int i = 0, j, argsread = 0; // If we see both -nl and -bar, assume we do an impulse plot. boolean sawbararg = false; // Saw -bar arg. boolean sawnlarg = false; // Saw -nl arg. int savedmarks = 0; // Save _marks in case we have -P -bar -nl. String arg; String unsupportedOptions[] = { "-bd", "-brb", "-bw", "-gw", "-lw", "-zg", "-zw" }; String unsupportedFlags[] = { "-bb" }; // Default URL to be opened String dataurl = ""; String title = "A plot"; while (i < args.length && (args[i].startsWith("-") || args[i].startsWith("=")) ) { arg = args[i++]; if (_debug > 2) System.out.print("Plot: arg = " + arg + "\n"); if (arg.startsWith("-")) { // Search for unsupported options that take arguments boolean badarg = false; for(j = 0; j < unsupportedOptions.length; j++) { if (arg.equals(unsupportedOptions[j])) { System.err.println("pxgraph: " + arg + " is not yet supported"); i++; badarg = true; } } if (badarg) continue; // Search for unsupported boolean flags for(j = 0; j < unsupportedFlags.length; j++) { if (arg.equals(unsupportedFlags[j])) { System.err.println("pxgraph: " + arg + " is not yet supported"); badarg = true; } } if (badarg) continue; if (arg.equals("-bg")) { setBackground(getColorByName(args[i++])); continue; } else if (arg.equals("-brw")) { // -brw <width> BarWidth Bars: // We default the baroffset to 0 here if the value does // not include a comma. if (arg.indexOf(",") == -1) { if (!_parseLine("Bars: " + args[i++]+",0")) { throw new CmdLineArgException("Failed to parse `"+ arg+"'"); } } else { if (!_parseLine("Bars: " + args[i++])) { throw new CmdLineArgException("Failed to parse `"+ arg+"'"); } } continue; } else if (arg.equals("-lf")) { // -lf <labelfont> setLabelFont(args[i++]); continue; } else if (arg.equals("-lx")) { // -lx <xl,xh> XLowLimit, XHighLimit XRange: if (!_parseLine("XRange: " + args[i++])) { throw new CmdLineArgException("Failed to parse `"+arg+"'"); } continue; } else if (arg.equals("-ly")) { // -ly <yl,yh> YLowLimit, YHighLimit YRange: if (!_parseLine("YRange: " + args[i++])) { throw new CmdLineArgException("Failed to parse `"+arg+"'"); } continue; } else if (arg.equals("-t")) { // -t <title> TitleText "An X Graph" title = args[i++]; continue; } else if (arg.equals("-tf")) { // -tf <titlefont> setTitleFont(args[i++]); continue; } else if (arg.equals("-x")) { // -x <unitName> XUnitText XLabel: setXLabel(args[i++]); continue; } else if (arg.equals("-y")) { // -y <unitName> YUnitText YLabel: setYLabel(args[i++]); continue; } else if (arg.equals("-bar")) { //-bar BarGraph Bars: on Marks: none Lines: off // If we saw the -nl arg, then assume impulses sawbararg = true; if (sawnlarg) { setImpulses(true); } else { setBars(true); // Save _marks in case we did -P -bar -nl. savedmarks = _marks; setMarksStyle("none"); } setConnected(false); continue; } else if (arg.equals("-binary")) { setBinary(true); _endian = NATIVE_ENDIAN; continue; } else if (arg.equals("-bigendian")) { setBinary(true); _endian = BIG_ENDIAN; continue; } else if (arg.equals("-littleendian")) { setBinary(true); _endian = LITTLE_ENDIAN; continue; } else if (arg.equals("-db")) { _debug = 6; continue; } else if (arg.equals("-debug")) { // -debug is not in the original X11 pxgraph. _debug = (int)Integer.valueOf(args[i++]).intValue(); continue; } else if (arg.equals("-fg")) { setForeground(getColorByName(args[i++])); continue; } else if (arg.equals("-help")) { // -help is not in the original X11 pxgraph. //_help(); continue; } else if (arg.equals("-impulses")) { // -impulses is not in the original X11 pxgraph. setImpulses(true); setConnected(false); continue; } else if (arg.equals("-lnx")) { setXLog(true); continue; } else if (arg.equals("-lny")) { setYLog(true); continue; } else if (arg.equals("-m")) { // -m Markers Marks: various setMarksStyle("various"); continue; } else if (arg.equals("-M")) { // -M StyleMarkers Marks: various setMarksStyle("various"); continue; } else if (arg.equals("-nl")) { // -nl NoLines Lines: off // If we saw the -bar arg, then assume impulses sawnlarg = true; if (sawbararg) { // Restore the _marks in case we did -P -bar -nl _marks = savedmarks; setBars(false); setImpulses(true); } setConnected(false); continue; } else if (arg.equals("-o")) { // -o <output filename> // _outputFile = args[i++]; i++; continue; } else if (arg.equals("-p")) { // -p PixelMarkers Marks: points setMarksStyle("points"); continue; } else if (arg.equals("-P")) { // -P LargePixel Marks: dots\n setMarksStyle("dots"); continue; } else if (arg.equals("-print")) { // -print is not in the original X11 pxgraph. continue; } else if (arg.equals("-rv")) { setBackground(getColorByName("black")); setForeground(getColorByName("white")); continue; } else if (arg.equals("-test")) { // -test is not in the original X11 pxgraph. //_test = true; continue; } else if (arg.equals("-tk")) { setGrid(false); continue; } else if (arg.equals("-v") || arg.equals("-version")) { // -version is not in the original X11 pxgraph. //_version(); continue; } else if (arg.equals("-m")) { } if (arg.length() > 1 && arg.charAt(0) == '-') { // Process '-<digit> <datasetname>' try { Integer datasetnumberint = new Integer(arg.substring(1)); int datasetnumber = datasetnumberint.intValue(); if (datasetnumber >= 0 && datasetnumber <= getMaxDataSets()) { if (_debug > 8) System.out.println("Plot: parseArgs: "+ "calling addLegend "+ datasetnumber+" "+args[i]); addLegend(datasetnumber, args[i++]); continue; } } catch (NumberFormatException e) {} } } else { if (arg.startsWith("=")) { // Process =WxH+X+Y _width = (int)Integer.valueOf(arg.substring(1, arg.indexOf('x'))).intValue(); int plusIndex = arg.indexOf('+'); int minusIndex = arg.indexOf('-'); if (plusIndex != -1 || minusIndex != -1) { // =WxH+X+Y, =WxH-X+Y, =WxH-X-Y, =WxH+X-Y if ( plusIndex != -1 && minusIndex != -1) { // =WxH-X+Y or =WxH+X-Y int index = minusIndex; if (plusIndex < minusIndex) { index = plusIndex; } _height = Integer.valueOf(arg.substring( arg.indexOf('x')+1, index)).intValue(); } else { if (plusIndex != -1) { // =WxH+X+Y _height = Integer.valueOf(arg.substring( arg.indexOf('x')+1, plusIndex)).intValue(); } else { // =WxH-X-Y _height = Integer.valueOf(arg.substring( arg.indexOf('x')+1, minusIndex)).intValue(); } } } else { if (arg.length() > arg.indexOf('x')) { // =WxH _height = Integer.valueOf(arg.substring( arg.indexOf('x')+1, arg.length())).intValue(); } } // FIXME: it is unclear what X and Y in =WxH+X+Y mean // in a non-toplevel window, so we don't process // those here. See Pxgraph.java for how to process // X and Y for a toplevel window. continue; } } // If we got to here, then we failed to parse the arg throw new CmdLineArgException("Failed to parse `" + arg + "'"); } if (i < args.length) { dataurl=args[i]; } argsread = i++; // Now we've parsed the parameters, so we call parent class methods. setDataurl(dataurl); // Set the dataurl in PlotBox setTitle(title); if (_debug > 9) System.out.println("Plot: parseArgs: resize()"+_width+" "+_height); resize(_width,_height); if (_debug > 0) { System.err.println("Plot: dataurl = " + dataurl); System.err.println("Plot: title= " + title); } if (_debug > 3) System.out.println("Plot: argsread = "+ argsread + " args.length = "+args.length); // Copy the file names into the _dataurls Vector for use later. _dataurls = new Vector(); for(i = argsread+1; i < args.length; i++) { if (_debug > 3) System.out.println("Plot: saving "+args[i]);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -