Macro recording
()
| 446 | |
| 447 | /** Macro recording */ |
| 448 | private void record() { |
| 449 | if (Recorder.scriptMode()) |
| 450 | Recorder.recordCall("//plot = IJ.getImage().getProperty(Plot.PROPERTY_KEY);"); |
| 451 | String plotDot = Recorder.scriptMode() ? "plot." : "Plot."; |
| 452 | |
| 453 | if (dialogType == SET_RANGE || dialogType == X_AXIS) |
| 454 | Recorder.recordString(plotDot+(Recorder.scriptMode() ? "setAxisXLog(" : "setLogScaleX(")+plot.hasFlag(Plot.X_LOG_NUMBERS)+");\n"); |
| 455 | if (dialogType == SET_RANGE || dialogType == Y_AXIS) |
| 456 | Recorder.recordString(plotDot+(Recorder.scriptMode() ? "setAxisYLog(" : "setLogScaleY(")+plot.hasFlag(Plot.Y_LOG_NUMBERS)+");\n"); |
| 457 | if (dialogType == SET_RANGE || dialogType == X_AXIS || dialogType == Y_AXIS) { |
| 458 | double[] currentMinMax = plot.getLimits(); |
| 459 | int xDigits = plot.logXAxis ? -2 : Plot.getDigits(currentMinMax[0], currentMinMax[1], 0.005*Math.abs(currentMinMax[1]-currentMinMax[0]), 6, 0); |
| 460 | int yDigits = plot.logYAxis ? -2 : Plot.getDigits(currentMinMax[2], currentMinMax[3], 0.005*Math.abs(currentMinMax[3]-currentMinMax[2]), 6, 0); |
| 461 | Recorder.recordString(plotDot+"setLimits("+IJ.d2s(currentMinMax[0],xDigits)+","+IJ.d2s(currentMinMax[1],xDigits)+ |
| 462 | ","+IJ.d2s(currentMinMax[2],yDigits)+","+IJ.d2s(currentMinMax[3],yDigits)+");\n"); |
| 463 | } |
| 464 | if (dialogType == AXIS_OPTIONS || dialogType == X_AXIS || dialogType == Y_AXIS) { |
| 465 | int flags = plot.getFlags(); |
| 466 | String xAxisLabel = Recorder.fixString(plot.getLabel('x')); |
| 467 | String yAxisLabel = Recorder.fixString(plot.getLabel('y')); |
| 468 | Font labelFont = plot.getFont('x'); |
| 469 | Font numberFont = plot.getFont('f'); |
| 470 | if (labelFont != null) { |
| 471 | if (Recorder.scriptMode()) |
| 472 | Recorder.recordString("plot.setAxisLabelFont("+(labelFont.isBold() ? "Font.BOLD," : "Font.PLAIN,")+IJ.d2s(labelFont.getSize2D(),1)+");\n"); |
| 473 | else |
| 474 | Recorder.recordString("Plot.setAxisLabelSize("+IJ.d2s(labelFont.getSize2D(),1)+", \""+(labelFont.isBold() ? "bold" : "plain")+"\");\n"); |
| 475 | } |
| 476 | if (numberFont != null) |
| 477 | Recorder.recordString(plotDot+(Recorder.scriptMode() ? "setFont(-1, " : "setFontSize(")+IJ.d2s(numberFont.getSize2D(),1)+");\n"); |
| 478 | Recorder.recordString(plotDot+"setXYLabels(\""+xAxisLabel+"\", \""+yAxisLabel+"\");\n"); |
| 479 | Recorder.recordString(plotDot+"setFormatFlags("+(Recorder.scriptMode() ? "0x"+Integer.toHexString(flags) : '\"'+Integer.toString(flags,2)+'\"')+ ");\n"); |
| 480 | } |
| 481 | if (dialogType == LEGEND) { |
| 482 | String labels = Recorder.fixString(plot.getDataLabels()); |
| 483 | int lFlags = plot.getObjectFlags('l'); |
| 484 | if (Recorder.scriptMode()) { |
| 485 | Recorder.recordCall("plot.setColor(Color.black);"); |
| 486 | Recorder.recordCall("plot.setLineWidth(1);"); |
| 487 | Recorder.recordCall("plot.addLegend(\""+labels+"\", 0x"+Integer.toHexString(lFlags)+");"); |
| 488 | } else { |
| 489 | String options = LEGEND_POSITIONS[legendPosNumber]; |
| 490 | if (getFlag(lFlags, Plot.LEGEND_BOTTOM_UP)) options+=" Bottom-To-Top"; |
| 491 | if (getFlag(lFlags, Plot.LEGEND_TRANSPARENT)) options+=" Transparent"; |
| 492 | Recorder.recordString("Plot.addLegend(\""+labels+"\", \""+options+"\");\n"); |
| 493 | } |
| 494 | } |
| 495 | |
| 496 | if (Recorder.scriptMode()) |
| 497 | Recorder.recordCall("plot.update();"); |
| 498 | } |
| 499 | |
| 500 | /** The dialog for "Make High Resolution Plot"; it has no preview*/ |
| 501 | private void doHighResolutionDialog(Frame parent) { |
no test coverage detected