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

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

源代码1 项目: hop   文件: SwingUniversalImageSvg.java
public static void render( Graphics2D gc, GraphicsNode svgGraphicsNode, Dimension2D svgGraphicsSize, int centerX,
                           int centerY, int width, int height, double angleRadians ) {
  double scaleX = width / svgGraphicsSize.getWidth();
  double scaleY = height / svgGraphicsSize.getHeight();

  AffineTransform affineTransform = new AffineTransform();
  if ( centerX != 0 || centerY != 0 ) {
    affineTransform.translate( centerX, centerY );
  }
  affineTransform.scale( scaleX, scaleY );
  if ( angleRadians != 0 ) {
    affineTransform.rotate( angleRadians );
  }
  affineTransform.translate( -svgGraphicsSize.getWidth() / 2, -svgGraphicsSize.getHeight() / 2 );

  svgGraphicsNode.setTransform( affineTransform );

  svgGraphicsNode.paint( gc );
}
 
源代码2 项目: orson-charts   文件: ViewPoint3D.java
private double coverage(Dimension2D d, Dimension2D target) {
    double wpercent = d.getWidth() / target.getWidth();
    double hpercent = d.getHeight() / target.getHeight();
    if (wpercent <= 1.0 && hpercent <= 1.0) {
        return Math.max(wpercent, hpercent);
    } else {
        if (wpercent >= 1.0) {
            if (hpercent >= 1.0) {
                return Math.max(wpercent, hpercent);
            } else {
                return wpercent;
            }
        } else {
            return hpercent;  // don't think it will matter
        }
    }
}
 
源代码3 项目: jdk8u60   文件: CImage.java
/** @return A MultiResolution image created from nsImagePtr, or null. */
private Image toImage() {
    if (ptr == 0) return null;

    final Dimension2D size = nativeGetNSImageSize(ptr);
    final int w = (int)size.getWidth();
    final int h = (int)size.getHeight();

    Dimension2D[] sizes
            = nativeGetNSImageRepresentationSizes(ptr,
                    size.getWidth(), size.getHeight());

    return sizes == null || sizes.length < 2 ?
            new MultiResolutionCachedImage(w, h, (width, height)
                    -> toImage(w, h, width, height))
            : new MultiResolutionCachedImage(w, h, sizes, (width, height)
                    -> toImage(w, h, width, height));
}
 
源代码4 项目: jdk8u-jdk   文件: CImage.java
/** @return A MultiResolution image created from nsImagePtr, or null. */
private Image toImage() {
    if (ptr == 0) return null;

    final Dimension2D size = nativeGetNSImageSize(ptr);
    final int w = (int)size.getWidth();
    final int h = (int)size.getHeight();

    Dimension2D[] sizes
            = nativeGetNSImageRepresentationSizes(ptr,
                    size.getWidth(), size.getHeight());

    return sizes == null || sizes.length < 2 ?
            new MultiResolutionCachedImage(w, h, (width, height)
                    -> toImage(w, h, width, height))
            : new MultiResolutionCachedImage(w, h, sizes, (width, height)
                    -> toImage(w, h, width, height));
}
 
源代码5 项目: jasperreports   文件: AbstractShapeCustomizer.java
/**
 * Builds an ellipse shape.
 * 
 * @return the ellipse or null if its size is not specified
 */
protected Shape buildEllipse()
{
	Ellipse2D ellipse = null;
	Dimension2D size = getSize();
	if (size != null)
	{
		Point offset = getOffset(size);
		ellipse = 
			new Ellipse2D.Float(
				-offset.getX(), 
				-offset.getY(), 
				(float)size.getWidth(), 
				(float)size.getHeight()
				);
	}
	return ellipse;
}
 
源代码6 项目: hottub   文件: CImage.java
/** @return A MultiResolution image created from nsImagePtr, or null. */
private Image toImage() {
    if (ptr == 0) return null;

    final Dimension2D size = nativeGetNSImageSize(ptr);
    final int w = (int)size.getWidth();
    final int h = (int)size.getHeight();

    Dimension2D[] sizes
            = nativeGetNSImageRepresentationSizes(ptr,
                    size.getWidth(), size.getHeight());

    return sizes == null || sizes.length < 2 ?
            new MultiResolutionCachedImage(w, h, (width, height)
                    -> toImage(w, h, width, height))
            : new MultiResolutionCachedImage(w, h, sizes, (width, height)
                    -> toImage(w, h, width, height));
}
 
源代码7 项目: Pixelitor   文件: TransformBoxAssert.java
public TransformBoxAssert rotSizeIs(double w, double h) {
    isNotNull();

    Dimension2D size = actual.getRotatedImSize();
    double width = size.getWidth();
    if (Math.abs(width - w) > DOUBLE_TOLERANCE) {
        throw new AssertionError(format("Expected width %.2f, found %.2f", w, width));
    }

    double height = size.getHeight();
    if (Math.abs(height - h) > DOUBLE_TOLERANCE) {
        throw new AssertionError(format("Expected height %.2f, found %.2f", h, height));
    }

    return this;
}
 
源代码8 项目: orson-charts   文件: VerticalFlowElement.java
/**
 * Returns info for as many elements as we can fit into one column.
 * 
 * @param first  the index of the first element.
 * @param g2  the graphics target.
 * @param bounds  the bounds.
 * 
 * @return A list of elements and dimensions. 
 */
private List<ElementInfo> columnOfElements(int first, 
        Graphics2D g2, Rectangle2D bounds) {
    List<ElementInfo> result = new ArrayList<>();
    int index = first;
    boolean full = false;
    double h = getInsets().top + getInsets().bottom;
    while (index < this.elements.size() && !full) {
        TableElement element = this.elements.get(index);
        Dimension2D dim = element.preferredSize(g2, bounds);
        if (h + dim.getHeight() <= bounds.getHeight() || index == first) {
            result.add(new ElementInfo(element, dim));
            h += dim.getHeight() + this.vgap;
            index++;
        } else {
            full = true;
        }
    }
    return result;
}
 
源代码9 项目: openjdk-jdk8u-backup   文件: CImage.java
/** @return A MultiResolution image created from nsImagePtr, or null. */
private Image toImage() {
    if (ptr == 0) {
        return null;
    }

    AtomicReference<Dimension2D> sizeRef = new AtomicReference<>();
    execute(ptr -> {
        sizeRef.set(nativeGetNSImageSize(ptr));
    });
    final Dimension2D size = sizeRef.get();
    if (size == null) {
        return null;
    }
    final int w = (int)size.getWidth();
    final int h = (int)size.getHeight();
    AtomicReference<Dimension2D[]> repRef = new AtomicReference<>();
    execute(ptr -> {
        repRef.set(nativeGetNSImageRepresentationSizes(ptr, size.getWidth(),
                                                       size.getHeight()));
    });
    Dimension2D[] sizes = repRef.get();

    return sizes == null || sizes.length < 2 ?
            new MultiResolutionCachedImage(w, h, (width, height)
                    -> toImage(w, h, width, height))
            : new MultiResolutionCachedImage(w, h, sizes, (width, height)
                    -> toImage(w, h, width, height));
}
 
源代码10 项目: pentaho-reporting   文件: ElementFactory.java
/**
 * Defines the top-right border-radius for this element. If the border radius has a non-zero width and height, the
 * element's border will have a rounded top-right corner.
 *
 * @param borderRadius
 *          the defined border-radius for the top-right corner of this element or null, if this property should be
 *          undefined.
 */
public void setBorderTopRightRadius( final Dimension2D borderRadius ) {
  if ( borderRadius == null ) {
    this.borderTopRightRadiusWidth = null;
    this.borderTopRightRadiusHeight = null;
  } else {
    this.borderTopRightRadiusWidth = new Float( borderRadius.getWidth() );
    this.borderTopRightRadiusHeight = new Float( borderRadius.getHeight() );
  }
}
 
源代码11 项目: openjdk-jdk9   文件: CImage.java
/** @return A MultiResolution image created from nsImagePtr, or null. */
private Image toImage() {
    if (ptr == 0) {
        return null;
    }

    AtomicReference<Dimension2D> sizeRef = new AtomicReference<>();
    execute(ptr -> {
        sizeRef.set(nativeGetNSImageSize(ptr));
    });
    final Dimension2D size = sizeRef.get();
    if (size == null) {
        return null;
    }
    final int w = (int)size.getWidth();
    final int h = (int)size.getHeight();
    AtomicReference<Dimension2D[]> repRef = new AtomicReference<>();
    execute(ptr -> {
        repRef.set(nativeGetNSImageRepresentationSizes(ptr, size.getWidth(),
                                                       size.getHeight()));
    });
    Dimension2D[] sizes = repRef.get();

    return sizes == null || sizes.length < 2 ?
            new MultiResolutionCachedImage(w, h, (width, height)
                    -> toImage(w, h, width, height))
            : new MultiResolutionCachedImage(w, h, sizes, (width, height)
                    -> toImage(w, h, width, height));
}
 
/**
 * Sets the parameters of this description object to match the supplied object.
 *
 * @param o  the object (should be an instance of <code>Dimension2D</code>).
 *
 * @throws ObjectFactoryException if the object is not an instance of <code>Point2D</code>.
 */
public void setParameterFromObject(final Object o) throws ObjectFactoryException {
    if (!(o instanceof Dimension2D)) {
        throw new ObjectFactoryException("The given object is no java.awt.geom.Dimension2D.");
    }

    final Dimension2D dim = (Dimension2D) o;
    final float width = (float) dim.getWidth();
    final float height = (float) dim.getHeight();

    setParameter("width", new Float(width));
    setParameter("height", new Float(height));
}
 
/**
 * Sets the parameters of this description object to match the supplied object.
 *
 * @param o
 *          the object (should be an instance of <code>Dimension2D</code>).
 * @throws ObjectFactoryException
 *           if the object is not an instance of <code>Point2D</code>.
 */
public void setParameterFromObject( final Object o ) throws ObjectFactoryException {
  if ( !( o instanceof Dimension2D ) ) {
    throw new ObjectFactoryException( "The given object is no java.awt.geom.Dimension2D." );
  }

  final Dimension2D dim = (Dimension2D) o;
  final float width = (float) dim.getWidth();
  final float height = (float) dim.getHeight();

  setParameter( "width", new Float( width ) );
  setParameter( "height", new Float( height ) );
}
 
源代码14 项目: SproutLife   文件: BoardRenderer.java
public void setBounds(Dimension2D d) {
    this.bounds = new Rectangle2D.Double(-20,-20,d.getWidth(),d.getHeight());
}
 
@Override
public void alignElementAndChildren(@Nonnull final MindMapPanelConfig cfg, final boolean leftSide, final double leftX, final double topY) {
  super.alignElementAndChildren(cfg, leftSide, leftX, topY);

  final double horzInset = cfg.getOtherLevelHorizontalInset() * cfg.getScale();

  double childrenX;

  final double COLLAPSATORSIZE = cfg.getCollapsatorSize() * cfg.getScale();
  final double COLLAPSATORDISTANCE = cfg.getCollapsatorSize() * 0.1d * cfg.getScale();

  final double collapsatorX;

  if (leftSide) {
    childrenX = leftX + this.blockSize.getWidth() - this.bounds.getWidth();
    this.moveTo(childrenX, topY + (this.blockSize.getHeight() - this.bounds.getHeight()) / 2);
    childrenX -= horzInset;
    collapsatorX = -COLLAPSATORSIZE - COLLAPSATORDISTANCE;
  } else {
    childrenX = leftX;
    this.moveTo(childrenX, topY + (this.blockSize.getHeight() - this.bounds.getHeight()) / 2);
    childrenX += this.bounds.getWidth() + horzInset;
    collapsatorX = this.bounds.getWidth() + COLLAPSATORDISTANCE;
  }

  this.collapsatorZone.setRect(collapsatorX, (this.bounds.getHeight() - COLLAPSATORSIZE) / 2, COLLAPSATORSIZE, COLLAPSATORSIZE);

  if (!this.isCollapsed()) {
    final double vertInset = cfg.getOtherLevelVerticalInset() * cfg.getScale();

    final Dimension2D childBlockSize = calcBlockSize(cfg, null, true);
    double currentY = topY + (this.blockSize.getHeight() - childBlockSize.getHeight()) / 2.0d;

    boolean notFirstChild = false;

    for (final Topic t : this.model.getChildren()) {
      if (notFirstChild) {
        currentY += vertInset;
      } else {
        notFirstChild = true;
      }
      final AbstractElement w = (AbstractElement) assertNotNull(t.getPayload());
      w.alignElementAndChildren(cfg, leftSide, leftSide ? childrenX - w.getBlockSize().getWidth() : childrenX, currentY);
      currentY += w.getBlockSize().getHeight();
    }
  }
}
 
源代码16 项目: jasperreports   文件: JRXlsExporter.java
private InternalImageProcessorResult processImageRetainShape(DataRenderable renderer) throws JRException
{
	float normalWidth = availableImageWidth;
	float normalHeight = availableImageHeight;
	
	DimensionRenderable dimensionRenderer = imageRenderersCache.getDimensionRenderable((Renderable)renderer);
	Dimension2D dimension = dimensionRenderer == null ? null :  dimensionRenderer.getDimension(jasperReportsContext);
	if (dimension != null)
	{
		normalWidth = (int) dimension.getWidth();
		normalHeight = (int) dimension.getHeight();
	}
	
	float ratioX = 1f;
	float ratioY = 1f;

	int imageWidth = 0;
	int imageHeight = 0;
	
	int topOffset = 0;
	int leftOffset = 0;
	int bottomOffset = 0;
	int rightOffset = 0;

	short angle = 0;
	
	switch (imageElement.getRotation())
	{
		case LEFT:
			ratioX = availableImageWidth / normalHeight;
			ratioY = availableImageHeight / normalWidth;
			ratioX = ratioX < ratioY ? ratioX : ratioY;
			ratioY = ratioX;
			imageWidth = (int)(normalHeight * ratioX);
			imageHeight = (int)(normalWidth * ratioY);
			topOffset = (int) ((1f - ImageUtil.getXAlignFactor(imageElement)) * (availableImageHeight - imageHeight));
			leftOffset = (int) (ImageUtil.getYAlignFactor(imageElement) * (availableImageWidth - imageWidth));
			bottomOffset = (int) (ImageUtil.getXAlignFactor(imageElement) * (availableImageHeight - imageHeight));
			rightOffset = (int) ((1f - ImageUtil.getYAlignFactor(imageElement)) * (availableImageWidth - imageWidth));
			angle = -90;
			break;
		case RIGHT:
			ratioX = availableImageWidth / normalHeight;
			ratioY = availableImageHeight / normalWidth;
			ratioX = ratioX < ratioY ? ratioX : ratioY;
			ratioY = ratioX;
			imageWidth = (int)(normalHeight * ratioX);
			imageHeight = (int)(normalWidth * ratioY);
			topOffset = (int) (ImageUtil.getXAlignFactor(imageElement) * (availableImageHeight - imageHeight));
			leftOffset = (int) ((1f - ImageUtil.getYAlignFactor(imageElement)) * (availableImageWidth - imageWidth));
			bottomOffset = (int) ((1f - ImageUtil.getXAlignFactor(imageElement)) * (availableImageHeight - imageHeight));
			rightOffset = (int) (ImageUtil.getYAlignFactor(imageElement) * (availableImageWidth - imageWidth));
			angle = 90;
			break;
		case UPSIDE_DOWN:
			ratioX = availableImageWidth / normalWidth;
			ratioY = availableImageHeight / normalHeight;
			ratioX = ratioX < ratioY ? ratioX : ratioY;
			ratioY = ratioX;
			imageWidth = (int)(normalWidth * ratioX);
			imageHeight = (int)(normalHeight * ratioY);
			topOffset = (int) ((1f - ImageUtil.getYAlignFactor(imageElement)) * (availableImageHeight - imageHeight));
			leftOffset = (int) ((1f - ImageUtil.getXAlignFactor(imageElement)) * (availableImageWidth - imageWidth));
			bottomOffset = (int) (ImageUtil.getYAlignFactor(imageElement) * (availableImageHeight - imageHeight));
			rightOffset = (int) (ImageUtil.getXAlignFactor(imageElement) * (availableImageWidth - imageWidth));
			angle = 180;
			break;
		case NONE:
		default:
			ratioX = availableImageWidth / normalWidth;
			ratioY = availableImageHeight / normalHeight;
			ratioX = ratioX < ratioY ? ratioX : ratioY;
			ratioY = ratioX;
			imageWidth = (int)(normalWidth * ratioX);
			imageHeight = (int)(normalHeight * ratioY);
			topOffset = (int) (ImageUtil.getYAlignFactor(imageElement) * (availableImageHeight - imageHeight));
			leftOffset = (int) (ImageUtil.getXAlignFactor(imageElement) * (availableImageWidth - imageWidth));
			bottomOffset = (int) ((1f - ImageUtil.getYAlignFactor(imageElement)) * (availableImageHeight - imageHeight));
			rightOffset = (int) ((1f - ImageUtil.getXAlignFactor(imageElement)) * (availableImageWidth - imageWidth));
			angle = 0;
			break;
	}
	
	return 
		new InternalImageProcessorResult(
			renderer.getData(jasperReportsContext), 
			topOffset, 
			leftOffset, 
			bottomOffset, 
			rightOffset,
			angle
			);
}
 
源代码17 项目: jasperreports   文件: JRXlsMetadataExporter.java
private InternalImageProcessorResult processImageRetainShape(DataRenderable renderer) throws JRException
{
	float normalWidth = availableImageWidth;
	float normalHeight = availableImageHeight;

	DimensionRenderable dimensionRenderer = imageRenderersCache.getDimensionRenderable((Renderable)renderer);
	Dimension2D dimension = dimensionRenderer == null ? null :  dimensionRenderer.getDimension(jasperReportsContext);
	if (dimension != null) {
		normalWidth = (int) dimension.getWidth();
		normalHeight = (int) dimension.getHeight();
	}

	float ratioX = 1f;
	float ratioY = 1f;

	int imageWidth = 0;
	int imageHeight = 0;
	
	int topOffset = 0;
	int leftOffset = 0;
	int bottomOffset = 0;
	int rightOffset = 0;

	short angle = 0;
	
	switch (imageElement.getRotation())
	{
		case LEFT:
			ratioX = availableImageWidth / normalHeight;
			ratioY = availableImageHeight / normalWidth;
			ratioX = ratioX < ratioY ? ratioX : ratioY;
			ratioY = ratioX;
			imageWidth = (int)(normalHeight * ratioX);
			imageHeight = (int)(normalWidth * ratioY);
			topOffset = (int) ((1f - ImageUtil.getXAlignFactor(imageElement)) * (availableImageHeight - imageHeight));
			leftOffset = (int) (ImageUtil.getYAlignFactor(imageElement) * (availableImageWidth - imageWidth));
			bottomOffset = (int) (ImageUtil.getXAlignFactor(imageElement) * (availableImageHeight - imageHeight));
			rightOffset = (int) ((1f - ImageUtil.getYAlignFactor(imageElement)) * (availableImageWidth - imageWidth));
			angle = -90;
			break;
		case RIGHT:
			ratioX = availableImageWidth / normalHeight;
			ratioY = availableImageHeight / normalWidth;
			ratioX = ratioX < ratioY ? ratioX : ratioY;
			ratioY = ratioX;
			imageWidth = (int)(normalHeight * ratioX);
			imageHeight = (int)(normalWidth * ratioY);
			topOffset = (int) (ImageUtil.getXAlignFactor(imageElement) * (availableImageHeight - imageHeight));
			leftOffset = (int) ((1f - ImageUtil.getYAlignFactor(imageElement)) * (availableImageWidth - imageWidth));
			bottomOffset = (int) ((1f - ImageUtil.getXAlignFactor(imageElement)) * (availableImageHeight - imageHeight));
			rightOffset = (int) (ImageUtil.getYAlignFactor(imageElement) * (availableImageWidth - imageWidth));
			angle = 90;
			break;
		case UPSIDE_DOWN:
			ratioX = availableImageWidth / normalWidth;
			ratioY = availableImageHeight / normalHeight;
			ratioX = ratioX < ratioY ? ratioX : ratioY;
			ratioY = ratioX;
			imageWidth = (int)(normalWidth * ratioX);
			imageHeight = (int)(normalHeight * ratioY);
			topOffset = (int) ((1f - ImageUtil.getYAlignFactor(imageElement)) * (availableImageHeight - imageHeight));
			leftOffset = (int) ((1f - ImageUtil.getXAlignFactor(imageElement)) * (availableImageWidth - imageWidth));
			bottomOffset = (int) (ImageUtil.getYAlignFactor(imageElement) * (availableImageHeight - imageHeight));
			rightOffset = (int) (ImageUtil.getXAlignFactor(imageElement) * (availableImageWidth - imageWidth));
			angle = 180;
			break;
		case NONE:
		default:
			ratioX = availableImageWidth / normalWidth;
			ratioY = availableImageHeight / normalHeight;
			ratioX = ratioX < ratioY ? ratioX : ratioY;
			ratioY = ratioX;
			imageWidth = (int)(normalWidth * ratioX);
			imageHeight = (int)(normalHeight * ratioY);
			topOffset = (int) (ImageUtil.getYAlignFactor(imageElement) * (availableImageHeight - imageHeight));
			leftOffset = (int) (ImageUtil.getXAlignFactor(imageElement) * (availableImageWidth - imageWidth));
			bottomOffset = (int) ((1f - ImageUtil.getYAlignFactor(imageElement)) * (availableImageHeight - imageHeight));
			rightOffset = (int) ((1f - ImageUtil.getXAlignFactor(imageElement)) * (availableImageWidth - imageWidth));
			angle = 0;
			break;
	}
	
	return 
		new InternalImageProcessorResult(
			renderer.getData(jasperReportsContext), 
			topOffset, 
			leftOffset, 
			bottomOffset, 
			rightOffset,
			angle
			);
}
 
@Override
public byte[] getData(JasperReportsContext jasperReportsContext) throws JRException
{
	Dimension2D dimension = getDimension(jasperReportsContext);
	
	if (dimension == null)
	{
		throw 
			new JRException(
				EXCEPTION_MESSAGE_KEY_DIMENSION_NULL_NOT_ALLOWED, 
				(Object[])null
				);
	}

	int dpi = getImageDataDPI(jasperReportsContext);
	double scale = dpi/72d;
	
	BufferedImage bi =
		new BufferedImage(
			(int) (scale * dimension.getWidth()),
			(int) (scale * dimension.getHeight()),
			BufferedImage.TYPE_INT_ARGB // always produce PNGs with transparency
			);

	Graphics2D g = createGraphics(bi);
	try
	{
		g.scale(scale, scale);
		Color backcolor = getBackcolor();
		if (backcolor != null)
		{
			g.setColor(backcolor);
			g.fillRect(0, 0, (int)dimension.getWidth(), (int)dimension.getHeight());
		}
		render(jasperReportsContext, g, new Rectangle((int)dimension.getWidth(), (int)dimension.getHeight()));
	}
	finally
	{
		g.dispose();
	}
	
	return JRImageLoader.getInstance(jasperReportsContext).loadBytesFromAwtImage(bi, ImageTypeEnum.PNG); // always produce PNGs with transparency
}
 
源代码19 项目: orson-charts   文件: Fit2D.java
/**
 * Fits a rectangle of the specified dimension to the target rectangle,
 * aligning and scaling according to the attributes of this instance.
 * 
 * @param srcDim  the dimensions of the source rectangle ({@code null}
 *     not permitted).
 * @param target  the target rectangle ({@code null} not permitted).
 * 
 * @return The bounds of the fitted rectangle (never {@code null}). 
 */
public Rectangle2D fit(Dimension2D srcDim, Rectangle2D target) {
    Rectangle2D result = new Rectangle2D.Double();
    if (this.scale == Scale2D.SCALE_BOTH) {
        result.setFrame(target);
        return result;
    }
    double width = srcDim.getWidth();
    if (this.scale == Scale2D.SCALE_HORIZONTAL) {
        width = target.getWidth();
        if (!this.anchor.getRefPt().isHorizontalCenter()) {
            width -= 2 * this.anchor.getOffset().getDX();
        }
    }
    double height = srcDim.getHeight();
    if (this.scale == Scale2D.SCALE_VERTICAL) {
        height = target.getHeight();
        if (!this.anchor.getRefPt().isVerticalCenter()) {
            height -= 2 * this.anchor.getOffset().getDY();
        }
    }
    Point2D pt = this.anchor.getAnchorPoint(target);
    double x = Double.NaN; 
    if (this.anchor.getRefPt().isLeft()) {
        x = pt.getX();
    } else if (this.anchor.getRefPt().isHorizontalCenter()) {
        x = target.getCenterX() - width / 2;
    } else if (this.anchor.getRefPt().isRight()) {
        x = pt.getX() - width;
    }
    double y = Double.NaN;
    if (this.anchor.getRefPt().isTop()) {
        y = pt.getY();
    } else if (this.anchor.getRefPt().isVerticalCenter()) {
        y = target.getCenterY() - height / 2;
    } else if (this.anchor.getRefPt().isBottom()) {
        y = pt.getY() - height;
    }
    result.setRect(x, y, width, height);
    return result;
}
 
源代码20 项目: mil-sym-java   文件: SECWebRenderer.java
/**
 * Given a symbol code meant for a single point symbol, returns the
 * anchor point at which to display that image based off the image returned
 * from the URL of the SinglePointServer.
 *
 * @param symbolID - the 15 character symbolID of a single point MilStd2525
 * symbol.
 * @return A pixel coordinate of the format "anchorX,anchorY,SymbolBoundsX,
 * SymbolBoundsY,SymbolBoundsWidth,SymbolBoundsHeight,IconWidth,IconHeight".
 * Anchor, represents the center point of the core symbol within the image.
 * The image should be centered on this point.
 * Symbol bounds represents the bounding rectangle of the core symbol within
 * the image.
 * IconWidth/Height represents the height and width of the image in its
 * entirety.
 * Returns an empty string if an error occurs.
 */
public String getSinglePointInfo(String symbolID)
{
    String info = "";
    Point2D anchor = new Point2D.Double();
    Rectangle2D symbolBounds = new Rectangle2D.Double();
    Dimension2D iconSize = new Dimension();
    sps.getSinglePointDimensions(symbolID, anchor, symbolBounds, iconSize);
    info = anchor.getX() + "," + anchor.getY() + "," +
            symbolBounds.getX() + "," + symbolBounds.getY() + "," +
            symbolBounds.getWidth() + "," + symbolBounds.getHeight() + "," + 
            iconSize.getWidth() + "," + iconSize.getHeight();
    return info;
}