예제 #1
0
  /**
   * 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);
  }
예제 #2
0
  /** Save in a stack the current coordinate state. */
  public void push() {
    MapCoordinates m = new MapCoordinates();
    m.xCenter = xCenter;
    m.yCenter = yCenter;
    m.xMagnitude = xMagnitude;
    m.yMagnitude = yMagnitude;
    m.orientation = orientation;
    m.mirror = mirror;
    m.isMacro = isMacro;
    m.snapActive = snapActive;
    m.xMin = xMin;
    m.xMax = xMax;
    m.yMin = yMin;
    m.yMax = yMax;

    m.xGridStep = xGridStep;
    m.yGridStep = yGridStep;
    stack.push(m);
  }
예제 #3
0
  /**
   * Draw the macro contents.
   *
   * @param g the graphic context.
   * @param coordSys the coordinate system.
   * @param layerV the vector containing all layers.
   */
  private void drawMacroContents(GraphicsInterface g, MapCoordinates coordSys, Vector layerV) {
    /* in the macro primitive, the the virtual point represents
    the position of the reference point of the macro to be drawn. */
    if (changed) {
      changed = false;
      x1 = virtualPoint[0].x;
      y1 = virtualPoint[0].y;

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

      macroCoord.setXCenter(coordSys.mapXr(x1, y1));
      macroCoord.setYCenter(coordSys.mapYr(x1, y1));
      macroCoord.setOrientation((o + coordSys.getOrientation()) % 4);
      macroCoord.mirror = m ^ coordSys.mirror;
      macroCoord.isMacro = true;
      macroCoord.resetMinMax();

      macro.setChanged(true);
    }

    if (getSelected()) {
      new SelectionActions(macro).setSelectionAll(true);
      selected = true;
    } else if (selected) {
      new SelectionActions(macro).setSelectionAll(false);
      selected = false;
    }

    macro.setDrawOnlyLayer(drawOnlyLayer);
    macro.setDrawOnlyPads(drawOnlyPads);

    drawingAgent = new Drawing(macro);
    drawingAgent.draw(g, macroCoord);

    if (macroCoord.getXMax() > macroCoord.getXMin()
        && macroCoord.getYMax() > macroCoord.getYMin()) {
      coordSys.trackPoint(macroCoord.getXMax(), macroCoord.getYMax());
      coordSys.trackPoint(macroCoord.getXMin(), macroCoord.getYMin());
    }
  }