/** * Creates an AWT-Dimension2D object from the given strict sizes. * * @param width * the width in micro points. * @param height * the height in micro points. * @return the created dimension object. */ public static Dimension2D createAWTDimension( final long width, final long height ) { return new FloatDimension( (float) ( width / CORRECTION_FACTOR ), (float) ( height / CORRECTION_FACTOR ) ); }
/** * Returns a string representation of the object. In general, the <code>toString</code> method returns a string that * "textually represents" this object. The result should be a concise but informative representation that is easy for * a person to read. * <p/> * * @return a string representation of the object. */ public String toString() { return getClass().getName() + ":={width=" + getWidth() + ", height=" + getHeight() + '}'; }
/** * Sets the size of this <code>Dimension</code> object to the specified width and height. This method is included for * completeness, to parallel the {@link java.awt.Component#getSize() getSize} method of {@link java.awt.Component}. * * @param width the new width for the <code>Dimension</code> object * @param height the new height for the <code>Dimension</code> object */ public void setSize( final double width, final double height ) { setHeight( (float) height ); setWidth( (float) width ); }
/** * Returns the defined top-left 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-left corner. * * @return the defined border-radius for the top-left corner of this element or null, if this property is undefined. */ public Dimension2D getBorderTopLeftRadius() { if ( borderTopLeftRadiusWidth == null || borderTopLeftRadiusHeight == null ) { return null; } return new FloatDimension( borderTopLeftRadiusWidth.floatValue(), borderTopLeftRadiusHeight.floatValue() ); }
/** * Sets the size of this <code>Dimension</code> object to the specified width and height. This method is included * for completeness, to parallel the {@link java.awt.Component#getSize() getSize} method of {@link * java.awt.Component}. * * @param width the new width for the <code>Dimension</code> object * @param height the new height for the <code>Dimension</code> object */ public void setSize(final double width, final double height) { setHeight((float) height); setWidth((float) width); }
/** * Returns a string representation of the object. In general, the <code>toString</code> method returns a string that * "textually represents" this object. The result should be a concise but informative representation that is easy * for a person to read. * <p/> * * @return a string representation of the object. */ public String toString() { return getClass().getName() + ":={width=" + getWidth() + ", height=" + getHeight() + '}'; }
/** * Returns the defined 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. * * @return the defined border-radius for the top-right corner of this element or null, if this property is undefined. */ public Dimension2D getBorderTopRightRadius() { if ( borderTopRightRadiusWidth == null || borderTopRightRadiusHeight == null ) { return null; } return new FloatDimension( borderTopRightRadiusWidth.floatValue(), borderTopRightRadiusHeight.floatValue() ); }
/** * Returns the defined global border-radius for this element. If the border radius has a non-zero width and height, * the element's border will have rounded corners. This property is a short-hand property for all other border-radius * properties. * * @return the defined border-radius for all corners of this element or null, if no global default is defined here. */ public Dimension2D getBorderRadius() { if ( borderRadiusWidth == null || borderRadiusHeight == null ) { return null; } return new FloatDimension( borderRadiusWidth.floatValue(), borderRadiusHeight.floatValue() ); }
/** * Returns the defined bottom-left border-radius for this element. If the border radius has a non-zero width and * height, the element's border will have a rounded bottom-left corner. * * @return the defined border-radius for the bottom-left corner of this element or null, if this property is * undefined. */ public Dimension2D getBorderBottomLeftRadius() { if ( borderBottomLeftRadiusWidth == null || borderBottomLeftRadiusHeight == null ) { return null; } return new FloatDimension( borderBottomLeftRadiusWidth.floatValue(), borderBottomLeftRadiusHeight.floatValue() ); }
/** * Returns the defined bottom-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 bottom-right corner. * * @return the defined border-radius for the bottom-right corner of this element or null, if this property is * undefined. */ public Dimension2D getBorderBottomRightRadius() { if ( borderBottomRightRadiusWidth == null || borderBottomRightRadiusHeight == null ) { return null; } return new FloatDimension( borderBottomRightRadiusWidth.floatValue(), borderBottomRightRadiusHeight.floatValue() ); }
/** * Returns the element's maximum size. * * @return the element's maximum size. * @see ElementFactory#getMinimumWidth() * @see ElementFactory#getMinimumHeight() */ public Dimension2D getMaximumSize() { if ( maximumWidth == null && maximumHeight == null ) { return null; } if ( maximumWidth == null ) { return new FloatDimension( 0, maximumHeight.floatValue() ); } if ( maximumHeight == null ) { return new FloatDimension( maximumWidth.floatValue(), 0 ); } return new FloatDimension( maximumWidth.floatValue(), maximumHeight.floatValue() ); }
/** * Returns the element's preferred size. * * @return the element's preferred size. * @see ElementFactory#getWidth() * @see ElementFactory#getHeight() */ public Dimension2D getPreferredSize() { if ( width == null && height == null ) { return null; } if ( width == null ) { return new FloatDimension( 0, height.floatValue() ); } if ( height == null ) { return new FloatDimension( width.floatValue(), 0 ); } return new FloatDimension( width.floatValue(), height.floatValue() ); }
/** * Returns the element's minimum size. * * @return the element's minimum size. * @see ElementFactory#getMinimumWidth() * @see ElementFactory#getMinimumHeight() */ public Dimension2D getMinimumSize() { if ( minimumWidth == null && minimumHeight == null ) { return null; } if ( minimumWidth == null ) { return new FloatDimension( 0, minimumHeight.floatValue() ); } if ( minimumHeight == null ) { return new FloatDimension( minimumWidth.floatValue(), 0 ); } return new FloatDimension( minimumWidth.floatValue(), minimumHeight.floatValue() ); }
/** * Reads the object from the object input stream. This read the width and height and constructs a new FloatDimension * object. * * @param in the object input stream from where to read the serialized data. * @return the generated object. * @throws IOException if reading the stream failed. * @throws ClassNotFoundException if serialized object class cannot be found. */ public Object readObject( final ObjectInputStream in ) throws IOException, ClassNotFoundException { final double w = in.readDouble(); final double h = in.readDouble(); return new FloatDimension( (float) w, (float) h ); }
/** * 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; }
/** * Resizes a shape, so that the shape has the given width and height, but the origin of the shape does not change. * <p/> * Unlike the AffineTransform, this method tries to preserve the Shape's Type. * * @param s * the shape * @param width * the new width * @param height * the new height * @return the resized shape. */ public static Shape resizeShape( final Shape s, final float width, final float height ) { if ( s instanceof Line2D ) { return resizeLine( (Line2D) s, width, height ); } if ( s instanceof RectangularShape ) { return resizeRect( (RectangularShape) s, width, height ); } return transformShape( s, true, false, new FloatDimension( width, height ) ); }
private Element createLabel() { final LabelElementFactory labelFactory = new LabelElementFactory(); labelFactory.setText( "Large label" ); labelFactory.setFontName( "SansSerif" ); labelFactory.setFontSize( new Integer( 10 ) ); labelFactory.setBold( Boolean.TRUE ); labelFactory.setAbsolutePosition( new Point2D.Double( 0, 0.0 ) ); labelFactory.setMinimumSize( new FloatDimension( 4000, 10.0f ) ); labelFactory.setHorizontalAlignment( ElementAlignment.LEFT ); return labelFactory.createElement(); }
public void testRemoveBandElement() { final MasterReport report = new MasterReport(); report.setName( "A Very Simple Report" ); TextFieldElementFactory factory = new TextFieldElementFactory(); factory.setName( "T1" ); factory.setAbsolutePosition( new Point2D.Float( 0, 0 ) ); factory.setMinimumSize( new FloatDimension( 150, 20 ) ); factory.setColor( Color.black ); factory.setHorizontalAlignment( ElementAlignment.LEFT ); factory.setVerticalAlignment( ElementAlignment.MIDDLE ); factory.setNullString( "-" ); factory.setFieldname( "Column1" ); final Element element1 = factory.createElement(); report.getItemBand().addElement( element1 ); factory = new TextFieldElementFactory(); factory.setName( "T2" ); factory.setAbsolutePosition( new Point2D.Float( 200, 0 ) ); factory.setMinimumSize( new FloatDimension( 150, 20 ) ); factory.setColor( Color.black ); factory.setHorizontalAlignment( ElementAlignment.LEFT ); factory.setVerticalAlignment( ElementAlignment.MIDDLE ); factory.setNullString( "-" ); factory.setFieldname( "Column2" ); final Element element2 = factory.createElement(); report.getItemBand().addElement( element2 ); // report.getStyleSheetCollection().debug(); report.getItemBand().removeElement( element1 ); // report.getStyleSheetCollection().debug(); DebugReportRunner.execGraphics2D( report ); }
public void testRemoveElement() { final MasterReport report = new MasterReport(); report.setName( "A Very Simple Report" ); TextFieldElementFactory factory = new TextFieldElementFactory(); factory.setName( "T1" ); factory.setAbsolutePosition( new Point2D.Float( 0, 0 ) ); factory.setMinimumSize( new FloatDimension( 150, 20 ) ); factory.setColor( Color.black ); factory.setHorizontalAlignment( ElementAlignment.LEFT ); factory.setVerticalAlignment( ElementAlignment.MIDDLE ); factory.setNullString( "-" ); factory.setFieldname( "Column1" ); final Element element1 = factory.createElement(); report.getItemBand().addElement( element1 ); factory = new TextFieldElementFactory(); factory.setName( "T2" ); factory.setAbsolutePosition( new Point2D.Float( 200, 0 ) ); factory.setMinimumSize( new FloatDimension( 150, 20 ) ); factory.setColor( Color.black ); factory.setHorizontalAlignment( ElementAlignment.LEFT ); factory.setVerticalAlignment( ElementAlignment.MIDDLE ); factory.setNullString( "-" ); factory.setFieldname( "Column2" ); final Element element2 = factory.createElement(); report.getItemBand().addElement( element2 ); // report.getStyleSheetCollection().debug(); report.getItemBand().removeElement( element1 ); report.getItemBand().removeElement( element2 ); // report.getStyleSheetCollection().debug(); }
factory.setName( "T1" ); factory.setAbsolutePosition( new Point2D.Float( 0, 0 ) ); factory.setMinimumSize( new FloatDimension( 150, 20 ) ); factory.setColor( Color.black ); factory.setHorizontalAlignment( ElementAlignment.LEFT ); factory.setName( "T2" ); factory.setAbsolutePosition( new Point2D.Float( 200, 0 ) ); factory.setMinimumSize( new FloatDimension( 150, 20 ) ); factory.setColor( Color.black ); factory.setHorizontalAlignment( ElementAlignment.LEFT );