コード例 #1
0
ファイル: PrimitiveMacro.java プロジェクト: simon-zz/FidoCadJ
  /**
   * Each graphic primitive should call the appropriate exporting method of the export interface
   * specified.
   *
   * @param exp the export interface that should be used.
   * @param cs the actual coordinate mapping.
   * @throws IOException if a problem occurs, such as it is impossible to write on the output file.
   */
  public void export(ExportInterface exp, MapCoordinates cs) throws IOException {
    if (alreadyExported) return;

    // Call the macro interface, to see if the macro should be expanded

    if (exp.exportMacro(
        cs.mapX(virtualPoint[0].x, virtualPoint[0].y),
        cs.mapY(virtualPoint[0].x, virtualPoint[0].y),
        m,
        o * 90,
        macroName,
        macroDesc,
        name,
        cs.mapX(virtualPoint[1].x, virtualPoint[1].y),
        cs.mapY(virtualPoint[1].x, virtualPoint[1].y),
        value,
        cs.mapX(virtualPoint[2].x, virtualPoint[2].y),
        cs.mapY(virtualPoint[2].x, virtualPoint[2].y),
        macroFont,
        (int) (cs.mapYr(getMacroFontSize(), getMacroFontSize()) - cs.mapYr(0, 0)),
        library)) {
      alreadyExported = true;
      return;
    }
    /* in the macro primitive, the virtual point represents
    the position of the reference point of the macro to be drawn. */

    int x1 = virtualPoint[0].x;
    int y1 = virtualPoint[0].y;

    MapCoordinates macroCoord = new MapCoordinates();

    macroCoord.setXMagnitude(cs.getXMagnitude());
    macroCoord.setYMagnitude(cs.getYMagnitude());

    macroCoord.setXCenter(cs.mapXr(x1, y1));
    macroCoord.setYCenter(cs.mapYr(x1, y1));

    macroCoord.setOrientation((o + cs.getOrientation()) % 4);
    macroCoord.mirror = m ^ cs.mirror;
    macroCoord.isMacro = true;

    macro.setDrawOnlyLayer(drawOnlyLayer);

    if (getSelected()) new SelectionActions(macro).setSelectionAll(true);

    macro.setDrawOnlyPads(drawOnlyPads);
    new Export(macro).exportDrawing(exp, false, exportInvisible, macroCoord);
    exportText(exp, cs, drawOnlyLayer);
  }