예제 #1
0
  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;
  }
예제 #2
0
파일: Frame.java 프로젝트: rakyll/plantuml
  public void drawU(UGraphic ug, Area area, Context2D context) {
    final Dimension2D dimensionToUse = area.getDimensionToUse();
    final HtmlColor lineColor = rose.getHtmlColor(skinParam, ColorParam.packageBorder);
    ug.getParam().setColor(lineColor);
    ug.getParam().setBackcolor(null);
    ug.getParam().setStroke(new UStroke(1.4));
    ug.draw(0, 0, new URectangle(dimensionToUse.getWidth(), dimensionToUse.getHeight()));
    ug.getParam().setStroke(new UStroke());

    final TextBlock textBlock = createTextBloc();
    textBlock.drawU(ug, 2, 2);

    final Dimension2D textDim = getTextDim(ug.getStringBounder());
    final double x = textDim.getWidth() + 6;
    final double y = textDim.getHeight() + 6;
    final UPolygon poly = new UPolygon();
    poly.addPoint(x, 0);
    poly.addPoint(x, y - 6);
    poly.addPoint(x - 6, y);
    poly.addPoint(0, y);
    poly.addPoint(0, 0);
    ug.getParam().setColor(lineColor);
    ug.getParam().setStroke(new UStroke(1.4));
    ug.draw(0, 0, poly);
    ug.getParam().setStroke(new UStroke());
  }
예제 #3
0
  @Override
  public void draw(Graphics2D g2d) {
    final Dimension2D dimTotal = getDimension(StringBounderUtils.asStringBounder(g2d));

    // Shape ellipse = new Ellipse2D.Double(0, 0, dimTotal.getWidth(),
    // dimTotal.getHeight());
    final GeneralPath ellipse = new GeneralPath();
    final double h = dimTotal.getHeight();
    final double w = dimTotal.getWidth();
    ellipse.append(new QuadCurve2D.Double(0, h / 2, 0, 0, w / 2, 0), true);
    ellipse.append(new QuadCurve2D.Double(w / 2, 0, w, 0, w, h / 2), true);
    ellipse.append(new QuadCurve2D.Double(w, h / 2, w, h, w / 2, h), true);
    ellipse.append(new QuadCurve2D.Double(w / 2, h, 0, h, 0, h / 2), true);
    g2d.setColor(getYellow());
    g2d.fill(ellipse);

    g2d.setColor(getRed());
    g2d.draw(ellipse);

    final Dimension2D nameDim = name.calculateDimension(StringBounderUtils.asStringBounder(g2d));
    final double posx = (w - nameDim.getWidth()) / 2;
    final double posy = (h - nameDim.getHeight()) / 2;
    final Shape rect = new Rectangle2D.Double(posx, posy, nameDim.getWidth(), nameDim.getHeight());
    // g2d.draw(rect);

    g2d.setColor(Color.BLACK);
    name.drawTOBEREMOVED(g2d, posx, posy);
  }
예제 #4
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);
  }
예제 #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));
  }
예제 #6
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;
 }
예제 #7
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());
 }
예제 #8
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)));
 }
예제 #9
0
 public void drawU(UGraphic ug, int zIndex, Dimension2D dimToUse) {
   if (zIndex != 0) {
     return;
   }
   final Dimension2D dim = getPreferredDimension(ug.getStringBounder(), 0, 0);
   ug = ug.apply(new UStroke(stroke));
   ug.apply(new UChangeBackColor(HtmlColorSet.getInstance().getColorIfValid("#EEEEEE")))
       .apply(new UTranslate(stroke, stroke))
       .draw(new URectangle(dim.getWidth() - 2 * stroke, dim.getHeight() - 2 * stroke, 10, 10));
   final Dimension2D dimPureText = getPureTextDimension(ug.getStringBounder());
   drawText(ug, (dim.getWidth() - dimPureText.getWidth()) / 2, stroke + marginY);
 }
예제 #10
0
  public Dimension2D getDimension(StringBounder stringBounder) {
    if (dimension == null) {
      dimension = getDimensionSlow(stringBounder);

      if (name != null) {
        final Dimension2D dimName = name.calculateDimension(stringBounder);
        final double widthName = dimName.getWidth();
        if (widthName > dimension.getWidth()) {
          dimension = new Dimension2DDouble(widthName, dimension.getHeight());
        }
      }
    }
    return dimension;
  }
예제 #11
0
 private FtileGeometry calculateDimensionAlone(StringBounder stringBounder) {
   final Dimension2D dimLabel = label.calculateDimension(stringBounder);
   final Dimension2D dim;
   if (dimLabel.getWidth() == 0 || dimLabel.getHeight() == 0) {
     dim = new Dimension2DDouble(Diamond.diamondHalfSize * 2, Diamond.diamondHalfSize * 2);
   } else {
     dim =
         Dimension2DDouble.delta(
             Dimension2DDouble.atLeast(
                 dimLabel, Diamond.diamondHalfSize * 2, Diamond.diamondHalfSize * 2),
             Diamond.diamondHalfSize * 2,
             0);
   }
   return new FtileGeometry(dim, dim.getWidth() / 2, 0, dim.getHeight());
 }
예제 #12
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();
    }
  }
예제 #13
0
 public void drawLineInternal(
     final UGraphic ug, Stencil stencil, double y, UStroke defaultStroke) {
   stencil = addSkip(stencil);
   final UStroke strokeToUse = style == '\0' ? defaultStroke : getStroke();
   final UGraphic ugStroke = ug.apply(strokeToUse);
   if (title == null) {
     drawHLine(stencil, y, ugStroke);
     return;
   }
   final Dimension2D dimTitle = title.calculateDimension(ug.getStringBounder());
   drawHLine(firstHalf(stencil, dimTitle.getWidth()), y, ugStroke);
   final double startingX = stencil.getStartingX(ug.getStringBounder(), y);
   final double endingX = stencil.getEndingX(ug.getStringBounder(), y);
   drawTitleInternal(ug, startingX, endingX, y, false);
   drawHLine(secondHalf(stencil, dimTitle.getWidth()), y, ugStroke);
 }
  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)
            + "\"");
  }
예제 #15
0
파일: Foo2.java 프로젝트: mar9000/plantuml
 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);
 }
예제 #16
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)));
  }
예제 #17
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;
 }
 @Override
 protected void drawInternalU(UGraphic ug, Dimension2D dimensionToUse) {
   stroke(ug, 2, 2);
   ug.getParam().setColor(groupBorder);
   ug.draw(0, 1, new ULine(dimensionToUse.getWidth(), 0));
   ug.getParam().setStroke(new UStroke());
   getTextBlock().drawU(ug, getMarginX1(), getMarginY());
 }
예제 #19
0
파일: Foo2.java 프로젝트: mar9000/plantuml
 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()));
   }
 }
예제 #20
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()));
  }
예제 #21
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;
 }
예제 #22
0
 private double getHTitle(Dimension2D dimTitle) {
   final double htitle;
   if (dimTitle.getWidth() == 0) {
     htitle = 10;
   } else {
     htitle = dimTitle.getHeight() + marginTitleY1 + marginTitleY2;
   }
   return htitle;
 }
예제 #23
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());
 }
예제 #24
0
 @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);
 }
예제 #25
0
파일: ElementLine.java 프로젝트: grze/euml
 public void drawU(UGraphic ug, double x, double y, int zIndex, Dimension2D dimToUse) {
   if (zIndex != 0) {
     return;
   }
   final HtmlColor old = ug.getParam().getColor();
   ug.getParam().setColor(HtmlColorUtils.getColorIfValid("#AAAAAA"));
   ug.draw(x, y, new ULine(dimToUse.getWidth(), 0));
   ug.getParam().setColor(old);
 }
예제 #26
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);
 }
예제 #27
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);
  }
예제 #29
0
파일: Foo2.java 프로젝트: mar9000/plantuml
 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;
 }