Commit 8993c12b by Michael Koch Committed by Michael Koch

Font.java [...]: New versions from classpath.

2003-06-19  Michael Koch  <konqueror@gmx.de>

	* java/awt/Font.java
	javax/swing/UIManager.java
	javax/swing/border/AbstractBorder.java
	javax/swing/border/BevelBorder.java
	javax/swing/border/Border.java
	javax/swing/border/CompoundBorder.java
	javax/swing/border/EmptyBorder.java
	javax/swing/border/EtchedBorder.java
	javax/swing/border/LineBorder.java
	javax/swing/border/MatteBorder.java
	javax/swing/border/TitledBorder.java
	javax/swing/plaf/BorderUIResource.java
	javax/swing/plaf/basic/BasicBorders.java
	javax/swing/plaf/basic/BasicButtonUI.java
	javax/swing/plaf/basic/BasicCheckBoxUI.java
	javax/swing/plaf/basic/BasicGraphicsUtils.java
	javax/swing/plaf/basic/BasicLabelUI.java
	javax/swing/plaf/basic/BasicRadioButtonUI.java
	javax/swing/plaf/basic/BasicToggleButtonUI.java:
	New versions from classpath.
	* javax/swing/border/SoftBevelBorder.java:
	New file from classpath.
	* javax/swing/border/doc-files/LineBorder-1.png,
	javax/swing/border/doc-files/BevelBorder-1.png,
	javax/swing/border/doc-files/BevelBorder-2.png,
	javax/swing/border/doc-files/BevelBorder-3.png,
	javax/swing/border/doc-files/EmptyBorder-1.png,
	javax/swing/border/doc-files/EtchedBorder-1.png,
	javax/swing/border/doc-files/EtchedBorder-2.png,
	javax/swing/border/doc-files/MatteBorder-1.png,
	javax/swing/border/doc-files/MatteBorder-2.png,
	javax/swing/border/doc-files/MatteBorder-3.png,
	javax/swing/border/doc-files/MatteBorder-4.png,
	javax/swing/border/doc-files/MatteBorder-5.png,
	javax/swing/border/doc-files/MatteBorder-6.png,
	javax/swing/border/doc-files/SoftBevelBorder-1.png,
	javax/swing/border/doc-files/SoftBevelBorder-2.png,
	javax/swing/border/doc-files/SoftBevelBorder-3.png,
	javax/swing/plaf/basic/doc-files/BasicBorders.MarginBorder-1.png,
	javax/swing/plaf/basic/doc-files/BasicBorders.ButtonBorder-1.png,
	javax/swing/plaf/basic/doc-files/BasicGraphicsUtils-1.png,
	javax/swing/plaf/basic/doc-files/BasicGraphicsUtils-2.png,
	javax/swing/plaf/basic/doc-files/BasicGraphicsUtils-3.png,
	javax/swing/plaf/basic/doc-files/BasicGraphicsUtils-4.png,
	javax/swing/plaf/basic/doc-files/BasicGraphicsUtils-5.png,
	javax/swing/plaf/basic/doc-files/BasicGraphicsUtils-6.png,
	javax/swing/plaf/basic/doc-files/BasicGraphicsUtils-7.png:
	New binary files from classpath.
	* Makefile.am
	(awt_java_source_files): Added
	javax/swing/border/SoftBevelBorder.java.
	* Makefile.in: Regenerated.

From-SVN: r68190
parent 1681bed6
2003-06-19 Michael Koch <konqueror@gmx.de>
* java/awt/Font.java
javax/swing/UIManager.java
javax/swing/border/AbstractBorder.java
javax/swing/border/BevelBorder.java
javax/swing/border/Border.java
javax/swing/border/CompoundBorder.java
javax/swing/border/EmptyBorder.java
javax/swing/border/EtchedBorder.java
javax/swing/border/LineBorder.java
javax/swing/border/MatteBorder.java
javax/swing/border/TitledBorder.java
javax/swing/plaf/BorderUIResource.java
javax/swing/plaf/basic/BasicBorders.java
javax/swing/plaf/basic/BasicButtonUI.java
javax/swing/plaf/basic/BasicCheckBoxUI.java
javax/swing/plaf/basic/BasicGraphicsUtils.java
javax/swing/plaf/basic/BasicLabelUI.java
javax/swing/plaf/basic/BasicRadioButtonUI.java
javax/swing/plaf/basic/BasicToggleButtonUI.java:
New versions from classpath.
* javax/swing/border/SoftBevelBorder.java:
New file from classpath.
* javax/swing/border/doc-files/LineBorder-1.png,
javax/swing/border/doc-files/BevelBorder-1.png,
javax/swing/border/doc-files/BevelBorder-2.png,
javax/swing/border/doc-files/BevelBorder-3.png,
javax/swing/border/doc-files/EmptyBorder-1.png,
javax/swing/border/doc-files/EtchedBorder-1.png,
javax/swing/border/doc-files/EtchedBorder-2.png,
javax/swing/border/doc-files/MatteBorder-1.png,
javax/swing/border/doc-files/MatteBorder-2.png,
javax/swing/border/doc-files/MatteBorder-3.png,
javax/swing/border/doc-files/MatteBorder-4.png,
javax/swing/border/doc-files/MatteBorder-5.png,
javax/swing/border/doc-files/MatteBorder-6.png,
javax/swing/border/doc-files/SoftBevelBorder-1.png,
javax/swing/border/doc-files/SoftBevelBorder-2.png,
javax/swing/border/doc-files/SoftBevelBorder-3.png,
javax/swing/plaf/basic/doc-files/BasicBorders.MarginBorder-1.png,
javax/swing/plaf/basic/doc-files/BasicBorders.ButtonBorder-1.png,
javax/swing/plaf/basic/doc-files/BasicGraphicsUtils-1.png,
javax/swing/plaf/basic/doc-files/BasicGraphicsUtils-2.png,
javax/swing/plaf/basic/doc-files/BasicGraphicsUtils-3.png,
javax/swing/plaf/basic/doc-files/BasicGraphicsUtils-4.png,
javax/swing/plaf/basic/doc-files/BasicGraphicsUtils-5.png,
javax/swing/plaf/basic/doc-files/BasicGraphicsUtils-6.png,
javax/swing/plaf/basic/doc-files/BasicGraphicsUtils-7.png:
New binary files from classpath.
* Makefile.am
(awt_java_source_files): Added
javax/swing/border/SoftBevelBorder.java.
* Makefile.in: Regenerated.
2003-06-19 Michael Koch <konqueror@gmx.de>
* gnu/java/security/x509/X509Certificate.java
(writeReplace): Merged from classpath.
......
......@@ -1151,6 +1151,7 @@ javax/swing/border/EmptyBorder.java \
javax/swing/border/EtchedBorder.java \
javax/swing/border/LineBorder.java \
javax/swing/border/MatteBorder.java \
javax/swing/border/SoftBevelBorder.java \
javax/swing/border/TitledBorder.java \
javax/swing/GrayFilter.java \
javax/swing/AbstractAction.java \
......
......@@ -920,6 +920,7 @@ javax/swing/border/EmptyBorder.java \
javax/swing/border/EtchedBorder.java \
javax/swing/border/LineBorder.java \
javax/swing/border/MatteBorder.java \
javax/swing/border/SoftBevelBorder.java \
javax/swing/border/TitledBorder.java \
javax/swing/GrayFilter.java \
javax/swing/AbstractAction.java \
......@@ -4016,6 +4017,7 @@ DEP_FILES = .deps/$(srcdir)/$(CONVERT_DIR)/gen-from-JIS.P \
.deps/javax/swing/border/EtchedBorder.P \
.deps/javax/swing/border/LineBorder.P \
.deps/javax/swing/border/MatteBorder.P \
.deps/javax/swing/border/SoftBevelBorder.P \
.deps/javax/swing/border/TitledBorder.P \
.deps/javax/swing/colorchooser/AbstractColorChooserPanel.P \
.deps/javax/swing/colorchooser/ColorChooserComponentFactory.P \
......
......@@ -39,6 +39,8 @@ exception statement from your version. */
package java.awt;
import java.awt.peer.FontPeer;
import java.awt.font.FontRenderContext;
import java.awt.font.LineMetrics;
import java.io.Serializable;
import java.util.StringTokenizer;
......@@ -484,5 +486,28 @@ toString()
",size=" + size + ")");
}
/**
* Determines the line metrics for a run of text.
*
* @param str the text run to be measured.
*
* @param frc the font rendering parameters that are used for the
* measurement. The exact placement and size of text slightly
* depends on device-specific characteristics, for instance
* the device resolution or anti-aliasing. For this reason,
* the returned measurement will only be accurate if the
* passed <code>FontRenderContext</code> correctly reflects
* the relevant parameters. Hence, <code>frc</code> should be
* obtained from the same <code>Graphics2D</code> that will
* be used for drawing, and any rendering hints should be set
* to the desired values before obtaining <code>frc</code>.
*
* @see java.awt.Graphics2D#getFontRenderContext()
*/
public LineMetrics getLineMetrics(String str, FontRenderContext frc)
{
throw new UnsupportedOperationException(); // FIXME
}
} // class Font
......@@ -174,11 +174,21 @@ public class UIManager implements Serializable
System.out.println("UIManager.getDim");
return new Dimension(200,100);
}
static Font getFont(Object key)
// Returns a drawing font from the defaults table.
/**
* Retrieves a font from the defaults table of the current
* LookAndFeel.
*
* @param key an Object that specifies the font. Typically,
* this is a String such as
* <code>&quot;TitledBorder.font&quot;</code>.
*/
public static Font getFont(Object key)
{
return (Font) getLookAndFeel().getDefaults().get(key);
}
static Icon getIcon(Object key)
// Returns an Icon from the defaults table.
{
......@@ -207,11 +217,17 @@ public class UIManager implements Serializable
return look_and_feel;
}
static UIDefaults getLookAndFeelDefaults()
// Returns the default values for this look and feel.
/**
* Returns the <code>UIDefaults</code> table of the currently active
* look and feel.
*/
public static UIDefaults getLookAndFeelDefaults()
{
return getLookAndFeel().getDefaults();
}
static String getString(Object key)
// Returns a string from the defaults table.
{
......
......@@ -91,15 +91,16 @@ public abstract class AbstractBorder
/**
* Determines the insets of this border. The implementation provided
* by AbstractButton returns Insets for a zero-width border, whose
* <code>left</code>, <code>right</code>, <code>top</code> and
* <code>bottom</code> fields are all zero.
* Measures the width of this border.
*
* @param c the component whose border is to be measured.
*
* @return a newly created Insets object, indicating a zero-width
* border.
* @return an Insets object whose <code>left</code>, <code>right</code>,
* <code>top</code> and <code>bottom</code> fields indicate the
* width of the border at the respective edge, which is zero
* for the default implementation provided by AbstractButton.
*
* @see #getBorderInsets(java.awt.Component, java.awt.Insets)
*/
public Insets getBorderInsets (Component c)
{
......@@ -113,12 +114,11 @@ public abstract class AbstractBorder
* <code>top</code> and <code>bottom</code> fields of the passed
* <code>insets</code> parameter to zero.
*
* @param c the component in the center of this border.
* @param c the component whose border is to be measured.
*
* @param insets an Insets object for holding the insets of this
* border.
* @return the same object that was passed for <code>insets</code>.
*
* @return the <code>insets</code> object.
* @see #getBorderInsets()
*/
public Insets getBorderInsets (Component c, Insets insets)
{
......
/* Border.java --
Copyright (C) 2002 Free Software Foundation, Inc.
Copyright (C) 2003 Free Software Foundation, Inc.
This file is part of GNU Classpath.
......@@ -42,10 +42,64 @@ import java.awt.Component;
import java.awt.Graphics;
import java.awt.Insets;
/**
* An interface for decorative or spacing borders around a Component.
*
* <p>To reduce memory consumption, several Components may share a
* single Border instance. {@link javax.swing.BorderFactory} is a
* factory class for producing commonly used shared borders.
*
* @see javax.swing.BorderFactory
* @see EmptyBorder
* @see CompoundBorder
* @see BevelBorder
* @see EtchedBorder
* @see LineBorder
* @see MatteBorder
* @see SoftBevelBorder
* @see TitledBorder
* @see AbstractBorder
*
* @author Ronald Veldema (rveldema@cs.vu.nl)
* @author Michael Koch (konqueror@gmx.de)
* @author Sascha Brawer (brawer@dandelis.ch)
*/
public interface Border
{
public Insets getBorderInsets (Component c);
public boolean isBorderOpaque ();
public void paintBorder (Component c, Graphics g, int x, int y,
int width, int height);
/**
* Paints the border for a given component.
*
* @param c the component whose border is to be painted.
* @param g the graphics for painting.
* @param x the horizontal position for painting the border.
* @param y the vertical position for painting the border.
* @param width the width of the available area for painting the border.
* @param height the height of the available area for painting the border.
*/
public void paintBorder(Component c, Graphics g,
int x, int y, int width, int height);
/**
* Measures the width of this border.
*
* @param c the component whose border is to be measured.
*
* @return an Insets object whose <code>left</code>, <code>right</code>,
* <code>top</code> and <code>bottom</code> fields indicate the
* width of the border at the respective edge.
*/
public Insets getBorderInsets(Component c);
/**
* Determines whether this border fills every pixel in its area
* when painting.
*
* @return <code>true</code> if the border is fully opaque, or
* <code>false</code> if some pixels of the background
* can shine through the border.
*/
public boolean isBorderOpaque();
}
......@@ -51,6 +51,10 @@ import java.awt.Insets;
public class CompoundBorder
extends AbstractBorder
{
/**
* Determined using the <code>serialver</code> tool
* of Apple/Sun JDK 1.3.1 on MacOS X 10.1.5.
*/
static final long serialVersionUID = 9054540377030555103L;
......@@ -90,14 +94,14 @@ public class CompoundBorder
* outside borders.
*
* @param outsideBorder the outside border, which is painted to the
* outside of both <code>insideBorder</code> and the bordered
* compoonent. It is acceptable to pass <code>null</code>, in
* which no outside border is painted.
* outside of both <code>insideBorder</code> and the enclosed
* component. It is acceptable to pass <code>null</code>, in
* which case no outside border is painted.
*
* @param insideBorder the inside border, which is painted to
* between <code>outsideBorder</code> and the bordered
* between <code>outsideBorder</code> and the enclosed
* component. It is acceptable to pass <code>null</code>, in
* which no intside border is painted.
* which case no inside border is painted.
*/
public CompoundBorder (Border outsideBorder, Border insideBorder)
{
......
/* EmptyBorder.java --
Copyright (C) 2002 Free Software Foundation, Inc.
Copyright (C) 2003 Free Software Foundation, Inc.
This file is part of GNU Classpath.
......@@ -42,47 +42,182 @@ import java.awt.Component;
import java.awt.Graphics;
import java.awt.Insets;
public class EmptyBorder extends AbstractBorder
/**
* A border for leaving a specifiable number of pixels empty around
* the enclosed component. An EmptyBorder requires some space on each
* edge, but does not perform any drawing.
*
* <p><img src="EmptyBorder-1.png" width="290" height="200"
* alt="[An illustration of EmptyBorder]" />
*
* @author Sascha Brawer (brawer@dandelis.ch)
*/
public class EmptyBorder
extends AbstractBorder
{
/**
* Determined using the <code>serialver</code> tool
* of Apple/Sun JDK 1.3.1 on MacOS X 10.1.5.
*/
static final long serialVersionUID = -8116076291731988694L;
/**
* The number of pixels required at the left edge.
*/
protected int left;
/**
* The number of pixels required at the right edge.
*/
protected int right;
protected int bottom;
/**
* The number of pixels required at the top edge.
*/
protected int top;
public EmptyBorder (Insets borderInsets)
{
this (borderInsets.left, borderInsets.right,
borderInsets.top, borderInsets.bottom);
}
public EmptyBorder (int left, int right, int top, int bottom)
/**
* The number of pixels required at the bottom edge.
*/
protected int bottom;
/**
* Constructs an empty border given the number of pixels required
* on each side.
*
* @param top the number of pixels that the border will need
* for its top edge.
*
* @param left the number of pixels that the border will need
* for its left edge.
*
* @param bottom the number of pixels that the border will need
* for its bottom edge.
*
* @param right the number of pixels that the border will need
* for its right edge.
*/
public EmptyBorder(int top, int left, int bottom, int right)
{
this.left = left;
this.right = right;
this.top = top;
this.left = left;
this.bottom = bottom;
this.right = right;
}
public Insets getBorderInsets (Component c, Insets s)
/**
* Constructs an empty border given the number of pixels required
* on each side, passed in an Insets object.
*
* @param borderInsets the Insets for the new border.
*/
public EmptyBorder(Insets borderInsets)
{
if (s == null)
s = new Insets (0,0,0,0);
s.left = left;
s.right = right;
s.top = top;
s.bottom = bottom;
return s;
this(borderInsets.top, borderInsets.left,
borderInsets.bottom, borderInsets.right);
}
public boolean isBorderOpaque ()
/**
* Performs nothing because an EmptyBorder does not paint any
* pixels. While the inherited implementation provided by
* {@link AbstractBorder#paintBorder} is a no-op as well,
* it is overwritten in order to match the API of the Sun
* reference implementation.
*
* @param c the component whose border is to be painted.
* @param g the graphics for painting.
* @param x the horizontal position for painting the border.
* @param y the vertical position for painting the border.
* @param width the width of the available area for painting the border.
* @param height the height of the available area for painting the border.
*/
public void paintBorder(Component c, Graphics g,
int x, int y, int width, int height)
{
return false;
}
public void paintBorder (Component c, Graphics g, int x, int y,
int width, int height)
/**
* Measures the width of this border.
*
* @param c the component whose border is to be measured.
*
* @return an Insets object whose <code>left</code>, <code>right</code>,
* <code>top</code> and <code>bottom</code> fields indicate the
* width of the border at the respective edge.
*
* @see #getBorderInsets(java.awt.Component, java.awt.Insets)
*/
public Insets getBorderInsets(Component c)
{
return getBorderInsets(c, null);
}
}
/**
* Measures the width of this border, storing the results into a
* pre-existing Insets object.
*
* @param insets an Insets object for holding the result values.
* After invoking this method, the <code>left</code>,
* <code>right</code>, <code>top</code> and
* <code>bottom</code> fields indicate the width of the
* border at the respective edge.
*
* @return the same object that was passed for <code>insets</code>.
*
* @see #getBorderInsets()
*/
public Insets getBorderInsets(Component c, Insets insets)
{
if (insets == null)
insets = new Insets(0, 0, 0, 0);
insets.left = left;
insets.right = right;
insets.top = top;
insets.bottom = bottom;
return insets;
}
/**
* Measures the width of this border.
*
* @return an Insets object whose <code>left</code>, <code>right</code>,
* <code>top</code> and <code>bottom</code> fields indicate the
* width of the border at the respective edge.
*
* @see #getBorderInsets(java.awt.Component, java.awt.Insets)
*/
public Insets getBorderInsets()
{
return getBorderInsets(null, null);
}
/**
* Determines whether this border fills every pixel in its area
* when painting. Since an empty border does not paint any pixels
* whatsoever, the result is <code>false</code>.
*
* @return <code>false</code>.
*/
public boolean isBorderOpaque()
{
/* The inherited implementation of AbstractBorder.isBorderOpaque()
* would also return false. It is not clear why this is overriden
* in the Sun implementation, at least not from just reading the
* JavaDoc.
*/
return false;
}
}
/* LineBorder.java --
Copyright (C) 2002 Free Software Foundation, Inc.
Copyright (C) 2003 Free Software Foundation, Inc.
This file is part of GNU Classpath.
......@@ -41,45 +41,294 @@ package javax.swing.border;
import java.awt.Color;
import java.awt.Component;
import java.awt.Graphics;
import java.awt.Insets;
public class LineBorder extends AbstractBorder
/**
* A border that consists of a line whose thickness and color can be
* specified. There also is a variant with rounded corners.
*
* @author Sascha Brawer (brawer@dandelis.ch)
*/
public class LineBorder
extends AbstractBorder
{
/**
* Determined using the <code>serialver</code> tool
* of Apple/Sun JDK 1.3.1 on MacOS X 10.1.5.
*/
static final long serialVersionUID = -787563427772288970L;
/**
* A shared instance of a black, one pixel thick, plain LineBorder.
* The singleton object is lazily created by {@link
* #createBlackLineBorder()} upon its first invocation.
*/
private static LineBorder blackLineBorder;
/**
* A shared instance of a gray, one pixel thick, plain LineBorder.
* The singleton object is lazily created by {@link
* #createBlackGrayBorder()} upon its first invocation.
*/
private static LineBorder grayLineBorder;
/**
* The width of the line in pixels.
*/
protected int thickness;
/**
* The color of the line.
*/
protected Color lineColor;
/**
* Indicates whether the line is drawn with rounded corners
* (<code>true</code>) or not ((<code>false</code>).
*/
protected boolean roundedCorners;
protected int thickness;
public LineBorder (Color color)
/**
* Constructs a LineBorder given its color. The border will be one
* pixel thick and have plain corners.
*
* @param color the color for drawing the border.
*
* @see #LineBorder(java.awt.Color, int, boolean)
*/
public LineBorder(Color color)
{
this (color, 1);
this(color, /* thickness */ 1, /* roundedCorners */ false);
}
public LineBorder (Color color, int thickness)
/**
* Constructs a LineBorder given its color and thickness. The
* border will have plain corners.
*
* @param color the color for drawing the border.
* @param thickness the width of the line in pixels.
*
* @see #LineBorder(java.awt.Color, int, boolean)
*/
public LineBorder(Color color, int thickness)
{
this (color, thickness, false); // FIXME: check roundedCorners argument
this (color, thickness, /* roundedCorners */ false);
}
/**
* Constructs a LineBorder given its color, thickness, and whether
* it has rounded corners.
*
* <p><img src="LineBorder-1.png" width="500" height="200"
* alt="[An illustration of two LineBorders] />
*
* <p>Note that the enlarged view in the right-hand picture shows
* that the implementation draws one more pixel than specified,
* provided that <code>roundedCorders</code> is <code>true</code>
* and anti-aliasing is turned on while painting. While this might
* be considered a bug, the Sun reference implementation (at least
* JDK 1.3.1 on Apple MacOS X 10.1.5) can be observed to fill
* exactly the same pixels as shown above. The GNU Classpath
* LineBorder replicates the observed behavior of the Sun
* implementation.
*
* @param color the color for drawing the border.
* @param thickness the width of the line in pixels.
* @param roundedCorners <code>true</code> for rounded corners,
* <code>false</code> for plain corners.
*
* @since 1.3
*/
public LineBorder (Color color, int thickness, boolean roundedCorners)
// For the bug mentioned in the JavaDoc, please see also the comment
// in the paintBorder method below.
//
public LineBorder(Color color, int thickness, boolean roundedCorners)
{
if ((color == null) || (thickness < 0))
throw new IllegalArgumentException();
this.lineColor = color;
this.thickness = thickness;
this.roundedCorners = roundedCorners;
}
public boolean isBorderOpaque()
/**
* Returns a black, one pixel thick, plain LineBorder. The method
* may always return the same (singleton) LineBorder instance.
*/
public static Border createBlackLineBorder()
{
/* Swing is not designed to be thread-safe, so there is no
* need to synchronize the access to the global variable.
*/
if (blackLineBorder == null)
blackLineBorder = new LineBorder(Color.black);
return blackLineBorder;
}
/**
* Returns a gray, one pixel thick, plain LineBorder. The method
* may always return the same (singleton) LineBorder instance.
*/
public static Border createGrayLineBorder()
{
/* Swing is not designed to be thread-safe, so there is no
* need to synchronize the access to the global variable.
*/
if (grayLineBorder == null)
grayLineBorder = new LineBorder(Color.gray);
return grayLineBorder;
}
/**
* Paints the line border around a given Component.
*
* @param c the component whose border is to be painted.
* @param g the graphics for painting.
* @param x the horizontal position for painting the border.
* @param y the vertical position for painting the border.
* @param width the width of the available area for painting the border.
* @param height the height of the available area for painting the border.
*/
public void paintBorder(Component c, Graphics g,
int x, int y, int width, int height)
{
Color oldColor = g.getColor();
try
{
g.setColor(lineColor);
/* If width and height were not adjusted, the border would
* appear one pixel too large in both directions.
*/
width -= 1;
height -= 1;
/* Blurred, too large appearance
* -----------------------------
* While Java 2D has introduced line strokes of arbitrary width,
* it seems desirable to keep this code independent of Java 2D.
* Therefore, multiple nested rectangles (or rounded rectangles)
* are drawn in order to simulate a line whose thickness is
* greater than one pixel.
*
* This hack causes a blurred appearance when anti-aliasing is
* on. Interestingly enough, though, the Sun JDK 1.3.1 (at least
* on MacOS X 10.1.5) shows exactly the same appearance under
* this condition. It thus seems likely that Sun does the same
* hack for simulating thick lines. For this reason, the
* blurred appearance seems acceptable -- especially since GNU
* Classpath tries to be compatible with the Sun reference
* implementation.
*/
for (int i = 0; i < thickness; i++)
{
if (roundedCorners)
g.drawRoundRect(x, y, width, height, thickness, thickness);
else
g.drawRect(x, y, width, height);
x += 1;
y += 1;
width -= 2;
height -= 2;
}
}
finally
{
return false;
g.setColor(oldColor);
}
}
public void paintBorder(Component c,
Graphics g,
int x,
int y,
int width,
int height)
/**
* Measures the width of this border.
*
* @param c the component whose border is to be measured.
*
* @return an Insets object whose <code>left</code>, <code>right</code>,
* <code>top</code> and <code>bottom</code> fields indicate the
* width of the border at the respective edge, which is the
* thickness of the line.
*
* @see #getBorderInsets(java.awt.Component, java.awt.Insets)
*/
public Insets getBorderInsets(Component c)
{
return new Insets(thickness, thickness, thickness, thickness);
}
/**
* Measures the width of this border, storing the results into a
* pre-existing Insets object.
*
* @param insets an Insets object for holding the result values.
* After invoking this method, the <code>left</code>,
* <code>right</code>, <code>top</code> and
* <code>bottom</code> fields indicate the width of the
* border at the respective edge, which is the thickness
* of the line.
*
* @return the same object that was passed for <code>insets</code>.
*
* @see #getBorderInsets()
*/
public Insets getBorderInsets(Component c, Insets insets)
{
insets.left = insets.right = insets.top = insets.bottom = thickness;
return insets;
}
/**
* Returns the thickness of the line in pixels.
*/
public int getThickness()
{
return thickness;
}
/**
* Returns whether this LineBorder os drawm with rounded
* or with plain corners.
*
* @return <code>true</code> if the corners are rounded,
* <code>false</code> if the corners are plain.
*/
public boolean getRoundedCorners()
{
return roundedCorners;
}
/**
* Determines whether this border fills every pixel in its area
* when painting.
*
* @return <code>true</code> if the corners are plain and the line
* color is fully opaque; <code>false</code> if the corners
* are rounded or the line color is partially transparent.
*/
public boolean isBorderOpaque()
{
return (!roundedCorners) && (lineColor.getAlpha() == 255);
}
}
......@@ -74,14 +74,7 @@ public class BasicButtonUI extends ButtonUI
public Dimension getPreferredSize(JComponent c)
{
AbstractButton b = (AbstractButton)c;
Dimension d = BasicGraphicsUtils.getPreferredSize(b,
gap,
b.getText(),
b.getIcon(),
b.getVerticalAlignment(),
b.getHorizontalAlignment(),
b.getHorizontalTextPosition(),
b.getVerticalTextPosition());
Dimension d = BasicGraphicsUtils.getPreferredButtonSize(b, gap);
// System.out.println("^^^^^^^^^^^^^^^^^^^^^^ BASIC-PREF="+d + ",T="+b.text);
return d;
}
......@@ -99,7 +92,7 @@ public class BasicButtonUI extends ButtonUI
g.setFont(f);
FontMetrics fm = SwingUtilities.getFontMetrics(f);
FontMetrics fm = g.getFontMetrics(f);
Insets i = c.getInsets();
......@@ -198,7 +191,7 @@ public class BasicButtonUI extends ButtonUI
g.setFont(f);
FontMetrics fm = SwingUtilities.getFontMetrics(f);
FontMetrics fm = g.getFontMetrics(f);
g.setColor(c.isEnabled() ? textColor : disabledTextColor);
......
......@@ -57,15 +57,7 @@ public class BasicCheckBoxUI extends BasicRadioButtonUI
public Dimension getPreferredSize(JComponent c)
{
AbstractButton b = (AbstractButton)c;
Dimension d = BasicGraphicsUtils.getPreferredSize(b,
gap,
b.getText(),
b.getIcon(),
b.getVerticalAlignment(),
b.getHorizontalAlignment(),
b.getHorizontalTextPosition(),
b.getVerticalTextPosition());
Dimension d = BasicGraphicsUtils.getPreferredButtonSize(b, gap);
//System.out.println("^^^^^^^^^^^^^^^^^^^^^^ BASIC-PREF="+d + ",T="+b.text);
return d;
}
......
......@@ -65,6 +65,10 @@ public class BasicLabelUI extends LabelUI
public Dimension getPreferredSize(JComponent c)
{
JLabel b = (JLabel)c;
/*
We cannot use this method because it is not part of the
official Swing API.
Dimension d = BasicGraphicsUtils.getPreferredSize(b,
gap,
b.getText(),
......@@ -74,7 +78,8 @@ public class BasicLabelUI extends LabelUI
b.getHorizontalTextPosition(),
b.getVerticalTextPosition());
System.out.println("JLABEL->^^^^^^^^^^^^^^^^^^^^^^ BASIC-PREF="+d + ",T="+b.getText());
return d;
*/
return new Dimension(100, 30);
}
......@@ -90,7 +95,7 @@ public class BasicLabelUI extends LabelUI
g.setFont(f);
FontMetrics fm = SwingUtilities.getFontMetrics(f);
FontMetrics fm = g.getFontMetrics(f);
Insets i = c.getInsets();
......
......@@ -60,14 +60,7 @@ public class BasicRadioButtonUI extends BasicToggleButtonUI
public Dimension getPreferredSize(JComponent c)
{
AbstractButton b = (AbstractButton)c;
Dimension d = BasicGraphicsUtils.getPreferredSize(b,
gap,
b.getText(),
b.getIcon(),
b.getVerticalAlignment(),
b.getHorizontalAlignment(),
b.getHorizontalTextPosition(),
b.getVerticalTextPosition());
Dimension d = BasicGraphicsUtils.getPreferredButtonSize(b, gap);
// and add a little something for the circles:
......
......@@ -58,14 +58,7 @@ public class BasicToggleButtonUI extends BasicButtonUI
public Dimension getPreferredSize(JComponent c)
{
AbstractButton b = (AbstractButton)c;
Dimension d = BasicGraphicsUtils.getPreferredSize(b,
gap,
b.getText(),
b.getIcon(),
b.getVerticalAlignment(),
b.getHorizontalAlignment(),
b.getHorizontalTextPosition(),
b.getVerticalTextPosition());
Dimension d = BasicGraphicsUtils.getPreferredButtonSize(b, gap);
//System.out.println("^^^^^^^^^^^^^^^^^^^^^^ BASIC-PREF="+d + ",T="+b.text);
return d;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment