java.awt.geom.Dimension2D#setSize ( )源码实例Demo

下面列出了java.awt.geom.Dimension2D#setSize ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: ramus   文件: Table.java
public void applyComlumnsSize(QBounds tableBound, Diagram diagram) {
    double width = getMinWidth();
    double w = width / columns.length;
    double x = tableBound.getLocation().getX();
    for (TableColumn tableColumn : columns) {
        QBounds bounds = (QBounds) diagram.getBounds(tableColumn);
        Dimension2D size = bounds.getSize();
        size.setSize(w, size.getHeight());
        bounds.setLocation(new Point2D.Double(x, getColumnYLocation(
                tableBound, size)));
        tableColumn.setWidth(w);
        x += w;
    }
}
 
源代码2 项目: ramus   文件: Table.java
public void applyComlumnsSize(QBounds tableBound, QBounds[] bounds) {
    double width = getMinWidth();
    double w = width / columns.length;
    double x = tableBound.getLocation().getX();
    for (int i = 0; i < columns.length; i++) {
        TableColumn tableColumn = columns[i];
        Dimension2D size = bounds[i].getSize();
        size.setSize(w, size.getHeight());
        bounds[i].setLocation(new Point2D.Double(x, getColumnYLocation(
                tableBound, size)));
        tableColumn.setWidth(w);
        x += w;
    }
}
 
/**
 * Creates an object based on the description.
 *
 * @return The object.
 */
public Object createObject() {
    final Dimension2D dim = new Dimension();

    final float width = getFloatParameter("width");
    final float height = getFloatParameter("height");
    dim.setSize(width, height);
    return dim;
}
 
/**
 * 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;
}
 
@Override
@Nonnull
public Dimension2D calcBlockSize(@Nonnull final MindMapPanelConfig cfg, @Nullable final Dimension2D size, final boolean childrenOnly) {
  final Dimension2D result = size == null ? new Dimension() : size;

  final double scaledVInset = cfg.getScale() * cfg.getOtherLevelVerticalInset();
  final double scaledHInset = cfg.getScale() * cfg.getOtherLevelHorizontalInset();

  double width = childrenOnly ? 0.0d : this.bounds.getWidth();
  double height = childrenOnly ? 0.0d : this.bounds.getHeight();

  if (this.hasChildren()) {
    if (!this.isCollapsed()) {
      width += childrenOnly ? 0.0d : scaledHInset;

      final double baseWidth = childrenOnly ? 0.0d : width;
      double childrenHeight = 0.0d;

      boolean notFirstChiild = false;

      for (final Topic t : this.model.getChildren()) {
        if (notFirstChiild) {
          childrenHeight += scaledVInset;
        } else {
          notFirstChiild = true;
        }
        ((AbstractElement) assertNotNull(t.getPayload())).calcBlockSize(cfg, result, false);
        width = Math.max(baseWidth + result.getWidth(), width);
        childrenHeight += result.getHeight();
      }

      height = Math.max(height, childrenHeight);
    } else if (!childrenOnly) {
      width += cfg.getCollapsatorSize() * cfg.getScale();
    }
  }
  result.setSize(width, height);

  return result;
}
 
源代码6 项目: netbeans-mmd-plugin   文件: MindMapPanel.java
@Nullable
public static Dimension2D calculateSizeOfMapInPixels(@Nonnull final MindMap model, @Nullable final Graphics2D graphicsContext, @Nonnull final MindMapPanelConfig cfg, final boolean expandAll, @Nonnull final RenderQuality quality) {
  final MindMap workMap = new MindMap(model);
  workMap.resetPayload();

  Graphics2D g = graphicsContext;

  if (g == null) {
    BufferedImage img = new BufferedImage(32, 32, cfg.isDrawBackground() ? BufferedImage.TYPE_INT_RGB : BufferedImage.TYPE_INT_ARGB);
    g = img.createGraphics();
  }
  final MMGraphics gfx = new MMGraphics2DWrapper(g);

  quality.prepare(g);

  Dimension2D blockSize = null;
  try {

    if (calculateElementSizes(gfx, workMap, cfg)) {
      if (expandAll) {
        final AbstractElement root = assertNotNull((AbstractElement) assertNotNull(workMap.getRoot()).getPayload());
        root.collapseOrExpandAllChildren(false);
        calculateElementSizes(gfx, workMap, cfg);
      }
      blockSize = assertNotNull(layoutModelElements(workMap, cfg));
      final double paperMargin = cfg.getPaperMargins() * cfg.getScale();
      blockSize.setSize(blockSize.getWidth() + paperMargin * 2, blockSize.getHeight() + paperMargin * 2);
    }
  } finally {
    gfx.dispose();
  }
  return blockSize;
}
 
/**
 * Creates an object based on the description.
 *
 * @return The object.
 */
public Object createObject() {
  final Dimension2D dim = new Dimension();

  final float width = getFloatParameter( "width" );
  final float height = getFloatParameter( "height" );
  dim.setSize( width, height );
  return dim;
}
 
/**
 * 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;
}
 
源代码9 项目: netbeans-mmd-plugin   文件: ElementRoot.java
@Override
@Nonnull
public Dimension2D calcBlockSize(@Nonnull final MindMapPanelConfig cfg, @Nonnull final Dimension2D size, final boolean childrenOnly) {
  final double insetV = cfg.getScale() * cfg.getFirstLevelVerticalInset();
  final double insetH = cfg.getScale() * cfg.getFirstLevelHorizontalInset();

  final Dimension2D result = size;

  double leftWidth = 0.0d;
  double leftHeight = 0.0d;
  double rightWidth = 0.0d;
  double rightHeight = 0.0d;

  boolean nonfirstOnLeft = false;
  boolean nonfirstOnRight = false;

  for (final Topic t : this.model.getChildren()) {
    final ElementLevelFirst w = assertNotNull((ElementLevelFirst) t.getPayload());

    w.calcBlockSize(cfg, result, false);

    if (w.isLeftDirection()) {
      leftWidth = Math.max(leftWidth, result.getWidth());
      leftHeight += result.getHeight();
      if (nonfirstOnLeft) {
        leftHeight += insetV;
      } else {
        nonfirstOnLeft = true;
      }
    } else {
      rightWidth = Math.max(rightWidth, result.getWidth());
      rightHeight += result.getHeight();
      if (nonfirstOnRight) {
        rightHeight += insetV;
      } else {
        nonfirstOnRight = true;
      }
    }
  }

  if (!childrenOnly) {
    leftWidth += nonfirstOnLeft ? insetH : 0.0d;
    rightWidth += nonfirstOnRight ? insetH : 0.0d;
  }

  this.leftBlockSize.setSize(leftWidth, leftHeight);
  this.rightBlockSize.setSize(rightWidth, rightHeight);

  if (childrenOnly) {
    result.setSize(leftWidth + rightWidth, Math.max(leftHeight, rightHeight));
  } else {
    result.setSize(leftWidth + rightWidth + this.bounds.getWidth(), Math.max(this.bounds.getHeight(), Math.max(leftHeight, rightHeight)));
  }

  return result;
}
 
源代码10 项目: mil-sym-java   文件: SinglePointServer.java
/**
 * @param SymbolInfo
 *            - same string you'd send to singlePointServer.handle()
 *            example:
 *            “SFGPUCDMH-*****?LineColor=0x000000&FillColor=0xFFFFFF
 *            &size=35”
 * @param center
 *            - pixel location that represents where the image should be
 *            centered.
 * @param bounds
 *            - Minimum Bounding Rectangle of the core symbol
 * @author Spinelli
 */
public void getSinglePointDimensions(String SymbolInfo, Point2D center, Rectangle2D bounds, Dimension2D iconExtent) 
              {
                  initRenderer();
                  try 
                  {

                      // prepare implement IPointConversion or use our basic point
                      Map<String,String> params = JavaRendererUtilities.createParameterMapFromURL(SymbolInfo);

                      // check if plugin renderer was requested
                      String renderer = params.get(MilStdAttributes.Renderer);
                      if(renderer==null || renderer.equals(""))
                      {
                          renderer=SinglePoint2525Renderer.RENDERER_ID;
                      }
                      if(plugins.hasRenderer(renderer)==false)
                      {
                          //if renderer id doesn't exist or is no good, set to default plugin.
                          renderer=SinglePoint2525Renderer.RENDERER_ID;
                      }

                      String pluginSymbolID = null;

                      ISinglePointInfo spi = null;
                      if (renderer != null && plugins != null && plugins.hasRenderer(renderer)) {
                          int questionIndex = SymbolInfo.indexOf('?');
                          if (questionIndex == -1)
                                  pluginSymbolID = SymbolInfo;
                          else
                                  pluginSymbolID = SymbolInfo.substring(0, questionIndex);
                          // try to render with plugin
                          // System.out.println(symbol.getSymbolID());
                          // System.out.println("plugin " + renderer + ": " +
                          // pluginSymbolID);
                          spi = plugins.render(renderer, pluginSymbolID, params);
                      }

                      ImageInfo iInfo;

                      if (spi != null && spi.getImage() != null) 
                      { // if plugin render success, 
                          //create image info with result
                          iInfo = new ImageInfo(spi.getImage(), 0, 0, (int) spi.getSymbolCenterPoint().getX(), (int) spi
                                          .getSymbolCenterPoint().getY(), spi.getSymbolBounds());

                          center.setLocation(iInfo.getSymbolCenterPoint());
                          bounds.setFrame(iInfo.getSymbolBounds());
                          if (iconExtent != null)
                              iconExtent.setSize(iInfo.getImage().getWidth(), iInfo.getImage().getHeight());
                      } 

                  } catch (Exception exc) {
                          System.out.println(exc.getMessage());
                  }
          }