Esempio n. 1
0
 public Dimension2D calculateDimension(StringBounder stringBounder) {
   final Dimension2D cell = getMaxCellDimension(stringBounder);
   final MinMax longitudes = distribution.getMinMaxLongitudes();
   final double width = (longitudes.getDiff() + 2) * cell.getWidth() / 2;
   final double height = cell.getHeight() * distribution.getNbLayers();
   return new Dimension2DDouble(width, height);
 }
Esempio n. 2
0
 private Point2D getTextBlockPosition(StringBounder stringBounder) {
   final Point2D pt1 = worm.get(0);
   final Point2D pt2 = worm.get(1);
   final Dimension2D dim = textBlock.calculateDimension(stringBounder);
   final double y = (pt1.getY() + pt2.getY()) / 2 - dim.getHeight() / 2;
   return new Point2D.Double(Math.max(pt1.getX(), pt2.getX()) + 4, y);
 }
Esempio n. 3
0
 public void drawU(UGraphic ug) {
   for (GTile tile : tiles) {
     tile.drawU(ug);
     final Dimension2D dim = tile.calculateDimension(ug.getStringBounder());
     ug = ug.apply(new UTranslate(0, dim.getHeight() + space));
   }
 }
Esempio n. 4
0
  public final void drawU(UGraphic ug) {
    final UEllipse circle = new UEllipse(SIZE, SIZE);
    if (getSkinParam().shadowing()) {
      circle.setDeltaShadow(4);
    }
    ug =
        ug.apply(
                new UChangeBackColor(
                    SkinParamUtils.getColor(
                        getSkinParam(), ColorParam.classBackground, getStereo())))
            .apply(
                new UChangeColor(
                    SkinParamUtils.getColor(getSkinParam(), ColorParam.classBorder, getStereo())));
    if (url != null) {
      ug.startUrl(url);
    }
    ug.apply(new UStroke(1.5)).draw(circle);

    final Dimension2D dimDesc = desc.calculateDimension(ug.getStringBounder());
    final double widthDesc = dimDesc.getWidth();
    // final double totalWidth = Math.max(widthDesc, SIZE);

    final double x = SIZE / 2 - widthDesc / 2;
    final double y = SIZE;
    desc.drawU(ug.apply(new UTranslate(x, y)));
    if (url != null) {
      ug.closeAction();
    }
  }
Esempio n. 5
0
  private void drawFolder(
      UGraphic ug, double width, double height, Dimension2D dimTitle, boolean shadowing) {

    final double wtitle;
    if (dimTitle.getWidth() == 0) {
      wtitle = Math.max(30, width / 4);
    } else {
      wtitle = dimTitle.getWidth() + marginTitleX1 + marginTitleX2;
    }
    final double htitle = getHTitle(dimTitle);

    final UPolygon shape = new UPolygon();
    shape.addPoint(0, 0);
    shape.addPoint(wtitle, 0);

    shape.addPoint(wtitle + marginTitleX3, htitle);
    shape.addPoint(width, htitle);
    shape.addPoint(width, height);
    shape.addPoint(0, height);
    shape.addPoint(0, 0);
    if (shadowing) {
      shape.setDeltaShadow(3.0);
    }
    ug.draw(shape);
    ug.apply(new UTranslate(0, htitle)).draw(new ULine(wtitle + marginTitleX3, 0));
  }
Esempio n. 6
0
  public void drawU(UGraphic ug) {

    final double suppY1 = north.calculateDimension(ug.getStringBounder()).getHeight();
    ug = ug.apply(new UTranslate(0, suppY1));
    ug.apply(new UChangeColor(borderColor))
        .apply(getThickness())
        .apply(new UChangeBackColor(backColor))
        .draw(Diamond.asPolygon(skinParam().shadowing()));
    // final Dimension2D dimNorth = north.calculateDimension(ug.getStringBounder());
    north.drawU(ug.apply(new UTranslate(Diamond.diamondHalfSize * 1.5, -suppY1)));

    // final Dimension2D dimSouth = south.calculateDimension(ug.getStringBounder());
    south.drawU(
        ug.apply(new UTranslate(Diamond.diamondHalfSize * 1.5, 2 * Diamond.diamondHalfSize)));
    // south.drawU(ug.apply(new UTranslate(-(dimSouth.getWidth() - 2 * Diamond.diamondHalfSize) / 2,
    // 2 * Diamond.diamondHalfSize)));

    final Dimension2D dimWeat1 = west1.calculateDimension(ug.getStringBounder());
    west1.drawU(
        ug.apply(
            new UTranslate(-dimWeat1.getWidth(), -dimWeat1.getHeight() + Diamond.diamondHalfSize)));

    final Dimension2D dimEast1 = east1.calculateDimension(ug.getStringBounder());
    east1.drawU(
        ug.apply(
            new UTranslate(
                Diamond.diamondHalfSize * 2, -dimEast1.getHeight() + Diamond.diamondHalfSize)));
  }
Esempio n. 7
0
  private ImageData writeImageMjpeg(OutputStream os) throws IOException {

    final LimitFinder limitFinder = new LimitFinder(TextBlockUtils.getDummyStringBounder(), true);
    udrawable.drawU(limitFinder);
    final Dimension2D dim =
        new Dimension2DDouble(
            limitFinder.getMaxX() + 1 + margin1 + margin2,
            limitFinder.getMaxY() + 1 + margin1 + margin2);

    final File f = new File("c:/tmp.avi");

    final int nbframe = 100;

    final MJPEGGenerator m =
        new MJPEGGenerator(
            f, getAviImage(null).getWidth(null), getAviImage(null).getHeight(null), 12.0, nbframe);
    for (int i = 0; i < nbframe; i++) {
      // AffineTransform at = AffineTransform.getRotateInstance(1.0);
      AffineTransform at =
          AffineTransform.getTranslateInstance(dim.getWidth() / 2, dim.getHeight() / 2);
      at.rotate(90.0 * Math.PI / 180.0 * i / 100);
      at.translate(-dim.getWidth() / 2, -dim.getHeight() / 2);
      // final AffineTransform at = AffineTransform.getTranslateInstance(i, 0);
      // final ImageIcon ii = new ImageIcon(getAviImage(at));
      // m.addImage(ii.getImage());
      throw new UnsupportedOperationException();
    }
    m.finishAVI();

    FileUtils.copyToStream(f, os);

    return new ImageDataSimple(dim);
  }
  public Map<TextBlock, Point2D> getPositions(double width, double height) {
    final Dimension2D first = getDimensions().values().iterator().next();

    double maxWidthButFirst = getMaxWidth(butFirst());
    double sumHeightButFirst = getSumHeight(butFirst());

    final double space = (width - first.getWidth() - maxWidthButFirst) / 3;

    final Map<TextBlock, Point2D> result = new LinkedHashMap<TextBlock, Point2D>();
    // double x = space * 2;

    final Iterator<Map.Entry<TextBlock, Dimension2D>> it = getDimensions().entrySet().iterator();
    final Map.Entry<TextBlock, Dimension2D> ent = it.next();
    double y = (height - ent.getValue().getHeight()) / 2;
    result.put(ent.getKey(), new Point2D.Double(space, y));

    // x += ent.getValue().getWidth() + space;

    y = (height - sumHeightButFirst) / 2;
    while (it.hasNext()) {
      final Map.Entry<TextBlock, Dimension2D> ent2 = it.next();
      final TextBlock textBlock = ent2.getKey();
      final Dimension2D dim = getDimensions().get(textBlock);
      final double x = 2 * space + first.getWidth() + (maxWidthButFirst - dim.getWidth()) / 2;
      result.put(textBlock, new Point2D.Double(x, y));
      y += ent2.getValue().getHeight();
    }
    return result;
  }
  public static void displayImageInfo(ImageInfo info) {

    ImageSize size = info.getSize();

    Dimension2D dPt = size.getDimensionPt();
    Dimension dPx = size.getDimensionPx();

    log.debug(
        info.getOriginalURI()
            + " "
            + info.getMimeType()
            + " "
            + Math.round(dPx.getWidth())
            + "x"
            + Math.round(dPx.getHeight()));

    log.debug(
        "Resolution:"
            + Math.round(size.getDpiHorizontal())
            + "x"
            + Math.round(size.getDpiVertical()));
    log.debug(
        "Print size: "
            + Math.round(dPt.getWidth() / 72)
            + "\" x"
            + Math.round(dPt.getHeight() / 72)
            + "\"");
  }
  /**
   * Creates an object based on the description.
   *
   * @return The object.
   */
  public Object createObject() {
    final Dimension2D dim = new FloatDimension();

    final float width = getFloatParameter("width");
    final float height = getFloatParameter("height");
    dim.setSize(width, height);
    return dim;
  }
Esempio n. 11
0
  @Override
  public Dimension2D calculateDimension(StringBounder stringBounder) {
    final double widthNum = getNumberWithAndMargin(stringBounder);
    final double heightNum = numText.calculateDimension(stringBounder).getHeight();

    final Dimension2D dim = super.calculateDimension(stringBounder);
    return new Dimension2DDouble(dim.getWidth() + widthNum, Math.max(heightNum, dim.getHeight()));
  }
Esempio n. 12
0
 public void drawU(UGraphic ug) {
   final StringBounder stringBounder = ug.getStringBounder();
   final Dimension2D cell = getMaxCellDimension(stringBounder);
   for (Layer layer : distribution.getLayers()) {
     drawLayer(ug, layer, cell.getWidth(), cell.getHeight());
     ug = ug.apply(new UTranslate(0, cell.getHeight()));
   }
 }
Esempio n. 13
0
 public double getHeight(StringBounder stringBounder) {
   double height = 0;
   for (Item it : project.getValidItems()) {
     final Dimension2D dim = stringBounder.calculateDimension(font, it.getCode());
     height += dim.getHeight();
   }
   return height;
 }
Esempio n. 14
0
 public double getWidth(StringBounder stringBounder) {
   double width = 0;
   for (Item it : project.getValidItems()) {
     final Dimension2D dim = stringBounder.calculateDimension(font, it.getCode());
     width = Math.max(width, dim.getWidth());
   }
   return width;
 }
Esempio n. 15
0
 @Override
 protected void drawBackgroundInternalU(UGraphic ug, Area area) {
   final Dimension2D dimensionToUse = area.getDimensionToUse();
   ug = symbolContext.apply(ug);
   ug.draw(new URectangle(dimensionToUse.getWidth(), dimensionToUse.getHeight()));
   final double xpos = (dimensionToUse.getWidth() - getPureTextWidth(ug.getStringBounder())) / 2;
   getTextBlock().drawU(ug.apply(new UTranslate(xpos, 0)));
 }
Esempio n. 16
0
 private void drawText(double x, double y, UText text) {
   final Dimension2D dim =
       stringBounder.calculateDimension(text.getFontConfiguration().getFont(), text.getText());
   y -= dim.getHeight() - 1.5;
   addPoint(x, y);
   addPoint(x, y + dim.getHeight());
   addPoint(x + dim.getWidth(), y);
   addPoint(x + dim.getWidth(), y + dim.getHeight());
 }
Esempio n. 17
0
 @Override
 public boolean equals(Object obj) {
   if (obj == this) return true;
   if (obj instanceof Dimension2D) {
     Dimension2D d = (Dimension2D) obj;
     return d.getWidth() == getWidth() && d.getHeight() == getHeight();
   }
   return false;
 }
 @Override
 public void draw(ColorMapper colorMapper, Graphics2D g2d) {
   final Dimension2D dim = textBlock.calculateDimension(StringBounderUtils.asStringBounder(g2d));
   final int width = (int) dim.getWidth();
   final int height = (int) dim.getHeight();
   g2d.setColor(Color.BLACK);
   g2d.drawRect(0, 0, width, height);
   //		textBlock.drawTOBEREMOVED(colorMapper, g2d, 0, 0);
 }
Esempio n. 19
0
 public void drawU(UGraphic ug, double x, double y, int zIndex, Dimension2D dimToUse) {
   if (background != null) {
     final Dimension2D dim = getPreferredDimension(ug.getStringBounder(), x, y);
     ug.getParam().setBackcolor(background);
     ug.draw(x, y, new URectangle(dim.getWidth(), dim.getHeight()));
     ug.getParam().setBackcolor(null);
   }
   block.drawU(ug, x, y);
 }
Esempio n. 20
0
 private double getHTitle(Dimension2D dimTitle) {
   final double htitle;
   if (dimTitle.getWidth() == 0) {
     htitle = 10;
   } else {
     htitle = dimTitle.getHeight() + marginTitleY1 + marginTitleY2;
   }
   return htitle;
 }
Esempio n. 21
0
  public void draw(
      UShape ushape, double x, double y, ColorMapper mapper, UParam param, SvgGraphics svg) {

    final UClip clip = clipContainer.getClip();
    if (clip != null && clip.isInside(x, y) == false) {
      return;
    }

    final UText shape = (UText) ushape;
    final FontConfiguration fontConfiguration = shape.getFontConfiguration();
    final UFont font = fontConfiguration.getFont();
    String fontWeight = null;
    if (fontConfiguration.containsStyle(FontStyle.BOLD) || font.isBold()) {
      fontWeight = "bold";
    }
    String fontStyle = null;
    if (fontConfiguration.containsStyle(FontStyle.ITALIC) || font.isItalic()) {
      fontStyle = "italic";
    }
    String textDecoration = null;
    if (fontConfiguration.containsStyle(FontStyle.UNDERLINE)) {
      textDecoration = "underline";
    } else if (fontConfiguration.containsStyle(FontStyle.STRIKE)) {
      textDecoration = "line-through";
    }

    String backColor = null;
    if (fontConfiguration.containsStyle(FontStyle.BACKCOLOR)) {
      backColor =
          StringUtils.getAsHtml(mapper.getMappedColor(fontConfiguration.getExtendedColor()));
    }

    svg.setFillColor(StringUtils.getAsHtml(mapper.getMappedColor(fontConfiguration.getColor())));
    String text = shape.getText();
    if (text.startsWith(" ")) {
      final double space = stringBounder.calculateDimension(font, " ").getWidth();
      while (text.startsWith(" ")) {
        x += space;
        text = text.substring(1);
      }
    }
    text = StringUtils.trin(text);
    final Dimension2D dim = stringBounder.calculateDimension(font, text);
    svg.text(
        text,
        x,
        y,
        font.getFamily(UFontContext.SVG),
        font.getSize(),
        fontWeight,
        fontStyle,
        textDecoration,
        dim.getWidth(),
        fontConfiguration.getAttributes(),
        backColor);
  }
  public void drawU(UGraphic ug) {
    final StringBounder stringBounder = ug.getStringBounder();
    final Component comp = getComponent(stringBounder);
    final Dimension2D dim = comp.getPreferredDimension(stringBounder);
    final Area area = new Area(dim.getWidth(), dim.getHeight());
    tile.drawU(ug);
    final Real p = getNotePosition(stringBounder);

    comp.drawU(ug.apply(new UTranslate(p.getCurrentValue(), 0)), area, (Context2D) ug);
  }
Esempio n. 23
0
 private void drawLayer(UGraphic ug, Layer layer, double w, double h) {
   for (IEntity ent : layer.entities()) {
     final IEntityImage image = computeImage((ILeaf) ent);
     final int longitude = layer.getLongitude(ent);
     final Dimension2D dimImage = image.calculateDimension(ug.getStringBounder());
     final double diffx = w - dimImage.getWidth();
     final double diffy = h - dimImage.getHeight();
     image.drawU(ug.apply(new UTranslate(w * longitude / 2 + diffx / 2, diffy / 2)));
   }
 }
 private double getScale(FileFormatOption fileFormatOption, final Dimension2D dim) {
   final double scale;
   final Scale diagScale = diagram.getScale();
   if (diagScale == null) {
     scale = diagram.getDpiFactor(fileFormatOption);
   } else {
     scale = diagScale.getScale(dim.getWidth(), dim.getHeight());
   }
   return scale;
 }
Esempio n. 25
0
 public Dimension2D evaluate(Dimension2D v0, Dimension2D v1, float fraction) {
   double w = v0.getWidth() + ((v1.getWidth() - v0.getWidth()) * fraction);
   double h = v0.getHeight() + ((v1.getHeight() - v0.getHeight()) * fraction);
   Dimension2D value = (Dimension2D) v0.clone();
   value.setSize(w, h);
   return value;
 }
Esempio n. 26
0
 public double getPosition(StringBounder stringBounder, Item item) {
   double pos = 0;
   for (Item it : project.getValidItems()) {
     if (it == item) {
       return pos;
     }
     final Dimension2D dim = stringBounder.calculateDimension(font, it.getCode());
     pos += dim.getHeight();
   }
   throw new IllegalArgumentException();
 }
Esempio n. 27
0
 private void manage(UGraphic ug, double x, double y, int n, String last, double pendingX) {
   final double width = n * dayWidth - pendingX;
   ug.apply(new UTranslate(x + pendingX, y)).draw(new URectangle(width, getHeight()));
   final TextBlock b =
       Display.create(last)
           .create(fontConfig, HorizontalAlignment.LEFT, new SpriteContainerEmpty());
   final Dimension2D dimText = b.calculateDimension(ug.getStringBounder());
   final double diffX = width - dimText.getWidth();
   final double diffY = getHeight() - dimText.getHeight();
   b.drawU(ug.apply(new UTranslate((x + pendingX + diffX / 2), (y + diffY / 2))));
 }
Esempio n. 28
0
 public Dimension2D calculateDimension(StringBounder stringBounder) {
   final Dimension2D rect = stringBounder.calculateDimension(fontConfiguration.getFont(), text);
   Log.debug("g2d=" + rect);
   Log.debug("Size for " + text + " is " + rect);
   double h = rect.getHeight();
   if (h < 10) {
     h = 10;
   }
   final double width = text.indexOf('\t') == -1 ? rect.getWidth() : getWidth(stringBounder);
   return new Dimension2DDouble(width, h);
 }
Esempio n. 29
0
 private void manage(UGraphic ug, double x, double y, int n, String last, double pendingX) {
   final double width = n * dayWidth - pendingX;
   ug.draw(x + pendingX, y, new URectangle(width, getHeight()));
   final TextBlock b =
       TextBlockUtils.create(
           Arrays.asList(last), fontConfig, HorizontalAlignement.LEFT, new SpriteContainerEmpty());
   final Dimension2D dimText = b.calculateDimension(ug.getStringBounder());
   final double diffX = width - dimText.getWidth();
   final double diffY = getHeight() - dimText.getHeight();
   b.drawU(ug, x + pendingX + diffX / 2, y + diffY / 2);
 }
Esempio n. 30
0
 public FtileGeometry calculateDimension(StringBounder stringBounder) {
   final Dimension2D diamond = calculateDimensionAlone(stringBounder);
   final Dimension2D north = this.north.calculateDimension(stringBounder);
   final double height = diamond.getHeight() + north.getHeight();
   final double left = diamond.getWidth() / 2;
   final double width = north.getWidth() > left ? left + north.getWidth() : diamond.getWidth();
   return new FtileGeometry(width, height, left, 0, diamond.getHeight());
 }