4358979: javax.swing.border should have a DashedBorder

Reviewed-by: flar, alexp
This commit is contained in:
Sergey Malenkov 2010-10-21 20:41:20 +04:00
parent eee0c8b959
commit 704780d250
13 changed files with 601 additions and 6 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -25,6 +25,8 @@
package java.awt;
import java.beans.ConstructorProperties;
/**
* The <code>BasicStroke</code> class defines a basic set of rendering
* attributes for the outlines of graphics primitives, which are rendered
@ -183,6 +185,7 @@ public class BasicStroke implements Stroke {
* <code>dash</code> is zero
* @throws IllegalArgumentException if dash lengths are all zero.
*/
@ConstructorProperties({ "lineWidth", "endCap", "lineJoin", "miterLimit", "dashArray", "dashPhase" })
public BasicStroke(float width, int cap, int join, float miterlimit,
float dash[], float dash_phase) {
if (width < 0.0f) {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -29,6 +29,7 @@ import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import java.awt.geom.AffineTransform;
import java.awt.image.ColorModel;
import java.beans.ConstructorProperties;
/**
* The <code>GradientPaint</code> class provides a way to fill
@ -166,6 +167,7 @@ public class GradientPaint implements Paint {
* @throws NullPointerException if either one of colors or points
* is null
*/
@ConstructorProperties({ "point1", "color1", "point2", "color2", "cyclic" })
public GradientPaint(Point2D pt1,
Color color1,
Point2D pt2,

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2006, 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -26,10 +26,10 @@
package java.awt;
import java.awt.geom.AffineTransform;
import java.awt.geom.NoninvertibleTransformException;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import java.awt.image.ColorModel;
import java.beans.ConstructorProperties;
/**
* The {@code LinearGradientPaint} class provides a way to fill
@ -271,6 +271,7 @@ public final class LinearGradientPaint extends MultipleGradientPaint {
* or a {@code fractions} value is less than 0.0 or greater than 1.0,
* or the {@code fractions} are not provided in strictly increasing order
*/
@ConstructorProperties({ "startPoint", "endPoint", "fractions", "colors", "cycleMethod", "colorSpace", "transform" })
public LinearGradientPaint(Point2D start, Point2D end,
float[] fractions, Color[] colors,
CycleMethod cycleMethod,

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2006, 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -29,6 +29,7 @@ import java.awt.geom.AffineTransform;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import java.awt.image.ColorModel;
import java.beans.ConstructorProperties;
/**
* The {@code RadialGradientPaint} class provides a way to fill a shape with
@ -428,6 +429,7 @@ public final class RadialGradientPaint extends MultipleGradientPaint {
* or a {@code fractions} value is less than 0.0 or greater than 1.0,
* or the {@code fractions} are not provided in strictly increasing order
*/
@ConstructorProperties({ "centerPoint", "radius", "focusPoint", "fractions", "colors", "cycleMethod", "colorSpace", "transform" })
public RadialGradientPaint(Point2D center,
float radius,
Point2D focus,

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2006, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -26,6 +26,7 @@
package java.awt.geom;
import java.awt.Shape;
import java.beans.ConstructorProperties;
/**
* The <code>AffineTransform</code> class represents a 2D affine transform
@ -508,6 +509,7 @@ public class AffineTransform implements Cloneable, java.io.Serializable {
* @param m12 the Y coordinate translation element of the 3x3 matrix
* @since 1.2
*/
@ConstructorProperties({ "scaleX", "shearY", "shearX", "scaleY", "translateX", "translateY" })
public AffineTransform(float m00, float m10,
float m01, float m11,
float m02, float m12) {

View File

@ -24,8 +24,10 @@
*/
package javax.swing;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Font;
import java.awt.Paint;
import javax.swing.border.*;
/**
@ -636,4 +638,125 @@ public class BorderFactory
Icon tileIcon) {
return new MatteBorder(top, left, bottom, right, tileIcon);
}
//// StrokeBorder //////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/**
* Creates a border of the specified {@code stroke}.
* The component's foreground color will be used to render the border.
*
* @param stroke the {@link BasicStroke} object used to stroke a shape
* @return the {@code Border} object
*
* @throws NullPointerException if the specified {@code stroke} is {@code null}
*
* @since 1.7
*/
public static Border createStrokeBorder(BasicStroke stroke) {
return new StrokeBorder(stroke);
}
/**
* Creates a border of the specified {@code stroke} and {@code paint}.
* If the specified {@code paint} is {@code null},
* the component's foreground color will be used to render the border.
*
* @param stroke the {@link BasicStroke} object used to stroke a shape
* @param paint the {@link Paint} object used to generate a color
* @return the {@code Border} object
*
* @throws NullPointerException if the specified {@code stroke} is {@code null}
*
* @since 1.7
*/
public static Border createStrokeBorder(BasicStroke stroke, Paint paint) {
return new StrokeBorder(stroke, paint);
}
//// DashedBorder //////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
private static Border sharedDashedBorder;
/**
* Creates a dashed border of the specified {@code paint}.
* If the specified {@code paint} is {@code null},
* the component's foreground color will be used to render the border.
* The width of a dash line is equal to {@code 1}.
* The relative length of a dash line and
* the relative spacing between dash lines are equal to {@code 1}.
* A dash line is not rounded.
*
* @param paint the {@link Paint} object used to generate a color
* @return the {@code Border} object
*
* @since 1.7
*/
public static Border createDashedBorder(Paint paint) {
return createDashedBorder(paint, 1.0f, 1.0f, 1.0f, false);
}
/**
* Creates a dashed border of the specified {@code paint},
* relative {@code length}, and relative {@code spacing}.
* If the specified {@code paint} is {@code null},
* the component's foreground color will be used to render the border.
* The width of a dash line is equal to {@code 1}.
* A dash line is not rounded.
*
* @param paint the {@link Paint} object used to generate a color
* @param length the relative length of a dash line
* @param spacing the relative spacing between dash lines
* @return the {@code Border} object
*
* @throws IllegalArgumentException if the specified {@code length} is less than {@code 1}, or
* if the specified {@code spacing} is less than {@code 0}
* @since 1.7
*/
public static Border createDashedBorder(Paint paint, float length, float spacing) {
return createDashedBorder(paint, 1.0f, length, spacing, false);
}
/**
* Creates a dashed border of the specified {@code paint}, {@code thickness},
* line shape, relative {@code length}, and relative {@code spacing}.
* If the specified {@code paint} is {@code null},
* the component's foreground color will be used to render the border.
*
* @param paint the {@link Paint} object used to generate a color
* @param thickness the width of a dash line
* @param length the relative length of a dash line
* @param spacing the relative spacing between dash lines
* @param rounded whether or not line ends should be round
* @return the {@code Border} object
*
* @throws IllegalArgumentException if the specified {@code thickness} is less than {@code 1}, or
* if the specified {@code length} is less than {@code 1}, or
* if the specified {@code spacing} is less than {@code 0}
* @since 1.7
*/
public static Border createDashedBorder(Paint paint, float thickness, float length, float spacing, boolean rounded) {
boolean shared = !rounded && (paint == null) && (thickness == 1.0f) && (length == 1.0f) && (spacing == 1.0f);
if (shared && (sharedDashedBorder != null)) {
return sharedDashedBorder;
}
if (thickness < 1.0f) {
throw new IllegalArgumentException("thickness is less than 1");
}
if (length < 1.0f) {
throw new IllegalArgumentException("length is less than 1");
}
if (spacing < 0.0f) {
throw new IllegalArgumentException("spacing is less than 0");
}
int cap = rounded ? BasicStroke.CAP_ROUND : BasicStroke.CAP_SQUARE;
int join = rounded ? BasicStroke.JOIN_ROUND : BasicStroke.JOIN_MITER;
float[] array = { thickness * (length - 1.0f), thickness * (spacing + 1.0f) };
Border border = createStrokeBorder(new BasicStroke(thickness, cap, join, thickness * 2.0f, array, 0.0f), paint);
if (shared) {
sharedDashedBorder = border;
}
return border;
}
}

View File

@ -0,0 +1,156 @@
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.swing.border;
import java.awt.BasicStroke;
import java.awt.Component;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Insets;
import java.awt.Paint;
import java.awt.RenderingHints;
import java.awt.geom.Rectangle2D;
import java.beans.ConstructorProperties;
/**
* A class which implements a border of an arbitrary stroke.
* <p>
* <strong>Warning:</strong>
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is
* appropriate for short term storage or RMI
* between applications running the same version of Swing.
* As of 1.4, support for long term storage of all JavaBeans&trade;
* has been added to the <code>java.beans</code> package.
* Please see {@link java.beans.XMLEncoder}.
*
* @author Sergey A. Malenkov
*
* @since 1.7
*/
public class StrokeBorder extends AbstractBorder {
private final BasicStroke stroke;
private final Paint paint;
/**
* Creates a border of the specified {@code stroke}.
* The component's foreground color will be used to render the border.
*
* @param stroke the {@link BasicStroke} object used to stroke a shape
*
* @throws NullPointerException if the specified {@code stroke} is {@code null}
*/
public StrokeBorder(BasicStroke stroke) {
this(stroke, null);
}
/**
* Creates a border of the specified {@code stroke} and {@code paint}.
* If the specified {@code paint} is {@code null},
* the component's foreground color will be used to render the border.
*
* @param stroke the {@link BasicStroke} object used to stroke a shape
* @param paint the {@link Paint} object used to generate a color
*
* @throws NullPointerException if the specified {@code stroke} is {@code null}
*/
@ConstructorProperties({ "stroke", "paint" })
public StrokeBorder(BasicStroke stroke, Paint paint) {
if (stroke == null) {
throw new NullPointerException("border's stroke");
}
this.stroke = stroke;
this.paint = paint;
}
/**
* Paints the border for the specified component
* with the specified position and size.
*
* @param c the component for which this border is being painted
* @param g the paint graphics
* @param x the x position of the painted border
* @param y the y position of the painted border
* @param width the width of the painted border
* @param height the height of the painted border
*
* @throws NullPointerException if the specified {@code c} or {@code g} are {@code null}
*/
@Override
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
float size = this.stroke.getLineWidth();
if (size > 0.0f) {
g = g.create();
if (g instanceof Graphics2D) {
Graphics2D g2d = (Graphics2D) g;
g2d.setStroke(this.stroke);
g2d.setPaint(this.paint != null ? this.paint : c.getForeground());
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
g2d.draw(new Rectangle2D.Float(x + size / 2, y + size / 2, width - size, height - size));
}
g.dispose();
}
}
/**
* Reinitializes the {@code insets} parameter
* with this border's current insets.
* All insets are equal to the line width of the stroke.
*
* @param c the component for which this border insets value applies
* @param insets the {@code Insets} object to be reinitialized
* @return the reinitialized {@code insets} parameter
*
* @throws NullPointerException if the specified {@code insets} is {@code null}
*/
@Override
public Insets getBorderInsets(Component c, Insets insets) {
int size = (int) Math.ceil(this.stroke.getLineWidth());
insets.set(size, size, size, size);
return insets;
}
/**
* Returns the {@link BasicStroke} object used to stroke a shape
* during the border rendering.
*
* @return the {@link BasicStroke} object
*/
public BasicStroke getStroke() {
return this.stroke;
}
/**
* Returns the {@link Paint} object used to generate a color
* during the border rendering.
*
* @return the {@link Paint} object or {@code null}
* if the {@code paint} parameter is not set
*/
public Paint getPaint() {
return this.paint;
}
}

View File

@ -0,0 +1,46 @@
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 4358979
* @summary Tests BasicStroke encoding
* @author Sergey Malenkov
*/
import java.awt.BasicStroke;
public final class java_awt_BasicStroke extends AbstractTest<BasicStroke> {
public static void main(String[] args) {
new java_awt_BasicStroke().test(true);
}
protected BasicStroke getObject() {
return new BasicStroke();
}
protected BasicStroke getAnotherObject() {
float[] f = {1.0f, 2.0f, 3.0f, 4.0f};
return new BasicStroke(f[1], BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, f[2], f, f[3]);
}
}

View File

@ -0,0 +1,47 @@
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 4358979
* @summary Tests GradientPaint encoding
* @author Sergey Malenkov
*/
import java.awt.Color;
import java.awt.GradientPaint;
public final class java_awt_GradientPaint extends AbstractTest<GradientPaint> {
public static void main(String[] args) {
new java_awt_GradientPaint().test(true);
}
protected GradientPaint getObject() {
return new GradientPaint(0.1f, 0.2f, Color.BLACK, 0.3f, 0.4f, Color.WHITE, true);
}
protected GradientPaint getAnotherObject() {
return null; /* TODO: could not update property
return new GradientPaint(0.4f, 0.3f, Color.WHITE, 0.2f, 0.1f, Color.BLACK, false);*/
}
}

View File

@ -0,0 +1,60 @@
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 4358979
* @summary Tests LinearGradientPaint encoding
* @author Sergey Malenkov
*/
import java.awt.Color;
import java.awt.LinearGradientPaint;
import java.awt.geom.AffineTransform;
import java.awt.geom.Point2D;
import static java.awt.MultipleGradientPaint.ColorSpaceType.LINEAR_RGB;
import static java.awt.MultipleGradientPaint.CycleMethod.REFLECT;
public final class java_awt_LinearGradientPaint extends AbstractTest<LinearGradientPaint> {
public static void main(String[] args) {
new java_awt_LinearGradientPaint().test(true);
}
protected LinearGradientPaint getObject() {
float[] f = { 0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f };
Color[] c = { Color.BLUE, Color.GREEN, Color.RED, Color.BLUE, Color.GREEN, Color.RED };
return new LinearGradientPaint(f[0], f[1], f[2], f[3], f, c);
}
protected LinearGradientPaint getAnotherObject() {
return null; /* TODO: could not update property
float[] f = { 0.4f, 0.5f, 0.6f, 0.7f, 0.8f, 0.9f };
Color[] c = { Color.RED, Color.GREEN, Color.BLUE, Color.RED, Color.GREEN, Color.BLUE };
return new LinearGradientPaint(
new Point2D.Float(f[0], f[1]),
new Point2D.Float(f[2], f[3]),
f, c, REFLECT, LINEAR_RGB,
new AffineTransform(f));*/
}
}

View File

@ -0,0 +1,60 @@
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 4358979
* @summary Tests RadialGradientPaint encoding
* @author Sergey Malenkov
*/
import java.awt.Color;
import java.awt.RadialGradientPaint;
import java.awt.geom.AffineTransform;
import java.awt.geom.Point2D;
import static java.awt.MultipleGradientPaint.ColorSpaceType.LINEAR_RGB;
import static java.awt.MultipleGradientPaint.CycleMethod.REFLECT;
public final class java_awt_RadialGradientPaint extends AbstractTest<RadialGradientPaint> {
public static void main(String[] args) {
new java_awt_RadialGradientPaint().test(true);
}
protected RadialGradientPaint getObject() {
float[] f = { 0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f };
Color[] c = { Color.BLUE, Color.GREEN, Color.RED, Color.BLUE, Color.GREEN, Color.RED };
return new RadialGradientPaint(f[0], f[1], f[2], f, c);
}
protected RadialGradientPaint getAnotherObject() {
return null; /* TODO: could not update property
float[] f = { 0.4f, 0.5f, 0.6f, 0.7f, 0.8f, 0.9f };
Color[] c = { Color.RED, Color.GREEN, Color.BLUE, Color.RED, Color.GREEN, Color.BLUE };
return new RadialGradientPaint(
new Point2D.Float(f[0], f[1]), 100.0f,
new Point2D.Float(f[2], f[3]),
f, c, REFLECT, LINEAR_RGB,
new AffineTransform(f));*/
}
}

View File

@ -0,0 +1,45 @@
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 4358979
* @summary Tests AffineTransform encoding
* @author Sergey Malenkov
*/
import java.awt.geom.AffineTransform;
public final class java_awt_geom_AffineTransform extends AbstractTest<AffineTransform> {
public static void main(String[] args) {
new java_awt_geom_AffineTransform().test(true);
}
protected AffineTransform getObject() {
return new AffineTransform(0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f);
}
protected AffineTransform getAnotherObject() {
return new AffineTransform(0.4f, 0.5f, 0.6f, 0.7f, 0.8f, 0.9f);
}
}

View File

@ -0,0 +1,48 @@
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 4358979
* @summary Tests StrokeBorder encoding
* @author Sergey Malenkov
*/
import java.awt.BasicStroke;
import java.awt.Color;
import javax.swing.border.StrokeBorder;
public final class javax_swing_border_StrokeBorder extends AbstractTest<StrokeBorder> {
public static void main(String[] args) {
new javax_swing_border_StrokeBorder().test(true);
}
protected StrokeBorder getObject() {
return new StrokeBorder(new BasicStroke(0), Color.WHITE);
}
protected StrokeBorder getAnotherObject() {
return null; // TODO: could not update property
//return new StrokeBorder(new BasicStroke(1));
}
}