Beispiel #1
0
  /**
   * Parse and store the tokenized version of the macro.
   *
   * @layerV the array containing the layer description to be inherited.
   */
  private void macroStore(Vector<LayerDesc> layerV) {
    macro.setLibrary(library); // Inherit the library
    macro.setLayers(layerV); // Inherit the layers
    changed = true;

    if (macroDesc != null) {
      ParserActions pa = new ParserActions(macro);
      pa.parseString(new StringBuffer(macroDesc));
      // Recursive call
    }
  }
Beispiel #2
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);
  }
Beispiel #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());
    }
  }
Beispiel #4
0
 /**
  * Get the maximum index of the layers contained in the macro.
  *
  * @return the maximum index of layers contained in the macro.
  */
 public int getMaxLayer() {
   return macro.getMaxLayer();
 }
Beispiel #5
0
 /**
  * Set the layer vector.
  *
  * @param layerV the layer vector.
  */
 public void setLayers(Vector<LayerDesc> layerV) {
   macro.setLayers(layerV);
 }
Beispiel #6
0
 /**
  * Specifies that the current primitive has been modified or not. If it is true, during the redraw
  * all parameters should be calulated from scratch.
  *
  * @param c the value of the parameter.
  */
 public void setChanged(boolean c) {
   super.setChanged(c);
   macro.setChanged(c);
 }
Beispiel #7
0
 /**
  * Returns true if the macro contains the specified layer. This is a calculation done at the
  * DrawingModel level.
  *
  * @param l the layer to be checked.
  * @return true if the layer is contained in the drawing and therefore should be drawn.
  */
 public boolean containsLayer(int l) {
   return macro.containsLayer(l);
 }