|
From: <ls...@us...> - 2007-02-04 10:20:21
|
Revision: 3107
http://jnode.svn.sourceforge.net/jnode/?rev=3107&view=rev
Author: lsantha
Date: 2007-02-04 02:20:16 -0800 (Sun, 04 Feb 2007)
Log Message:
-----------
Classpath patches.
Modified Paths:
--------------
trunk/core/src/classpath/javax/javax/swing/plaf/metal/DefaultMetalTheme.java
trunk/core/src/classpath/javax/javax/swing/plaf/metal/MetalCheckBoxIcon.java
trunk/core/src/classpath/javax/javax/swing/plaf/metal/MetalComboBoxUI.java
trunk/core/src/classpath/javax/javax/swing/plaf/metal/MetalFileChooserUI.java
trunk/core/src/classpath/javax/javax/swing/plaf/metal/MetalIconFactory.java
trunk/core/src/classpath/javax/javax/swing/plaf/metal/MetalRadioButtonUI.java
trunk/core/src/classpath/javax/javax/swing/plaf/metal/MetalScrollBarUI.java
trunk/core/src/classpath/javax/javax/swing/plaf/metal/MetalSliderUI.java
trunk/core/src/classpath/javax/javax/swing/plaf/metal/MetalUtils.java
Modified: trunk/core/src/classpath/javax/javax/swing/plaf/metal/DefaultMetalTheme.java
===================================================================
--- trunk/core/src/classpath/javax/javax/swing/plaf/metal/DefaultMetalTheme.java 2007-02-04 09:46:03 UTC (rev 3106)
+++ trunk/core/src/classpath/javax/javax/swing/plaf/metal/DefaultMetalTheme.java 2007-02-04 10:20:16 UTC (rev 3107)
@@ -38,8 +38,11 @@
package javax.swing.plaf.metal;
+import gnu.classpath.SystemProperties;
+
import java.awt.Font;
+import javax.swing.UIManager;
import javax.swing.plaf.ColorUIResource;
import javax.swing.plaf.FontUIResource;
@@ -63,10 +66,6 @@
private static final ColorUIResource SECONDARY3 =
new ColorUIResource(204, 204, 204);
- private static final FontUIResource CONTROL_TEXT_FONT =
- new FontUIResource("Dialog", Font.BOLD, 12);
- private static final FontUIResource MENU_TEXT_FONT =
- new FontUIResource("Dialog", Font.BOLD, 12);
private static final FontUIResource SUB_TEXT_FONT =
new FontUIResource("Dialog", Font.PLAIN, 10);
private static final FontUIResource SYSTEM_TEXT_FONT =
@@ -77,6 +76,40 @@
new FontUIResource("Dialog", Font.BOLD, 12);
/**
+ * The control text font for swing.boldMetal=false.
+ */
+ private static final FontUIResource PLAIN_CONTROL_TEXT_FONT =
+ new FontUIResource("Dialog", Font.PLAIN, 12);
+
+ /**
+ * The standard control text font.
+ */
+ private static final FontUIResource BOLD_CONTROL_TEXT_FONT =
+ new FontUIResource("Dialog", Font.BOLD, 12);
+
+ /**
+ * The menu text font for swing.boldMetal=false.
+ */
+ private static final FontUIResource PLAIN_MENU_TEXT_FONT =
+ new FontUIResource("Dialog", Font.PLAIN, 12);
+
+ /**
+ * The menu control text font.
+ */
+ private static final FontUIResource BOLD_MENU_TEXT_FONT =
+ new FontUIResource("Dialog", Font.BOLD, 12);
+
+ /**
+ * Indicates the control text font.
+ */
+ static final int CONTROL_TEXT_FONT = 1;
+
+ /**
+ * Indicates the menu text font.
+ */
+ static final int MENU_TEXT_FONT = 2;
+
+ /**
* Creates a new instance of this theme.
*/
public DefaultMetalTheme()
@@ -156,23 +189,28 @@
/**
* Returns the font used for text on controls. In this case, the font is
- * <code>FontUIResource("Dialog", Font.BOLD, 12)</code>.
+ * <code>FontUIResource("Dialog", Font.BOLD, 12)</code>, unless the
+ * <code>swing.boldMetal</code> UI default is set to {@link Boolean#FALSE}
+ * in which case it is <code>FontUIResource("Dialog", Font.PLAIN, 12)</code>.
*
* @return The font.
*/
public FontUIResource getControlTextFont()
{
- return CONTROL_TEXT_FONT;
+ return getFont(CONTROL_TEXT_FONT);
}
+
/**
* Returns the font used for text in menus. In this case, the font is
- * <code>FontUIResource("Dialog", Font.BOLD, 12)</code>.
+ * <code>FontUIResource("Dialog", Font.BOLD, 12)</code>, unless the
+ * <code>swing.boldMetal</code> UI default is set to {@link Boolean#FALSE}
+ * in which case it is <code>FontUIResource("Dialog", Font.PLAIN, 12)</code>.
*
* @return The font used for text in menus.
*/
public FontUIResource getMenuTextFont()
{
- return MENU_TEXT_FONT;
+ return getFont(MENU_TEXT_FONT);
}
/**
@@ -218,4 +256,50 @@
{
return WINDOW_TITLE_FONT;
}
+
+ /**
+ * Returns the appropriate font. The font type to return is identified
+ * by the specified id.
+ *
+ * @param id the font type to return
+ *
+ * @return the correct font
+ */
+ private FontUIResource getFont(int id)
+ {
+ FontUIResource font = null;
+ switch (id)
+ {
+ case CONTROL_TEXT_FONT:
+ if (isBoldMetal())
+ font = BOLD_CONTROL_TEXT_FONT;
+ else
+ font = PLAIN_CONTROL_TEXT_FONT;
+ break;
+ case MENU_TEXT_FONT:
+ if (isBoldMetal())
+ font = BOLD_MENU_TEXT_FONT;
+ else
+ font = PLAIN_MENU_TEXT_FONT;
+ break;
+ // TODO: Add other font types and their mapping here.
+ }
+ return font;
+ }
+
+ /**
+ * Determines if the theme should be bold or not. The theme is bold by
+ * default, this can be turned off by setting the system property
+ * swing.boldMetal to true, or by putting the property with the same name
+ * into the current UIManager's defaults.
+ *
+ * @return <code>true</code>, when the theme is bold, <code>false</code>
+ * otherwise
+ */
+ private boolean isBoldMetal()
+ {
+ Object boldMetal = UIManager.get("swing.boldMetal");
+ return (boldMetal == null || ! Boolean.FALSE.equals(boldMetal))
+ && ! ("false".equals(SystemProperties.getProperty("swing.boldMetal")));
+ }
}
Modified: trunk/core/src/classpath/javax/javax/swing/plaf/metal/MetalCheckBoxIcon.java
===================================================================
--- trunk/core/src/classpath/javax/javax/swing/plaf/metal/MetalCheckBoxIcon.java 2007-02-04 09:46:03 UTC (rev 3106)
+++ trunk/core/src/classpath/javax/javax/swing/plaf/metal/MetalCheckBoxIcon.java 2007-02-04 10:20:16 UTC (rev 3107)
@@ -1,5 +1,5 @@
/* MetalCheckBoxIcon.java -- An icon for JCheckBoxes in the Metal L&F
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -42,8 +42,8 @@
import java.awt.Graphics;
import java.io.Serializable;
+import javax.swing.AbstractButton;
import javax.swing.Icon;
-import javax.swing.JCheckBox;
import javax.swing.SwingConstants;
import javax.swing.UIManager;
import javax.swing.plaf.UIResource;
@@ -134,8 +134,9 @@
MetalUtils.paintGradient(g, x, y, getIconWidth(), getIconHeight(),
SwingConstants.VERTICAL, "CheckBox.gradient");
border.paintBorder(c, g, x, y, getIconWidth(), getIconHeight());
- JCheckBox cb = (JCheckBox) c;
- if (cb.isSelected())
- drawCheck(c, g, x, y);
+
+ AbstractButton b = (AbstractButton) c;
+ if (b.isSelected())
+ drawCheck(b, g, x, y);
}
}
Modified: trunk/core/src/classpath/javax/javax/swing/plaf/metal/MetalComboBoxUI.java
===================================================================
--- trunk/core/src/classpath/javax/javax/swing/plaf/metal/MetalComboBoxUI.java 2007-02-04 09:46:03 UTC (rev 3106)
+++ trunk/core/src/classpath/javax/javax/swing/plaf/metal/MetalComboBoxUI.java 2007-02-04 10:20:16 UTC (rev 3107)
@@ -48,7 +48,6 @@
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
-import javax.swing.CellRendererPane;
import javax.swing.ComboBoxEditor;
import javax.swing.Icon;
import javax.swing.JButton;
@@ -217,7 +216,7 @@
*/
protected ComboPopup createPopup()
{
- return new MetalComboPopup(comboBox);
+ return super.createPopup();
}
/**
@@ -228,7 +227,7 @@
protected JButton createArrowButton()
{
JButton button = new MetalComboBoxButton(comboBox, new MetalComboBoxIcon(),
- new CellRendererPane(), listBox);
+ currentValuePane, listBox);
button.setMargin(new Insets(0, 1, 1, 3));
return button;
}
@@ -305,7 +304,6 @@
{
MetalComboBoxButton b = (MetalComboBoxButton) arrowButton;
d = getDisplaySize();
- Insets insets = b.getInsets();
Insets arrowInsets = b.getInsets();
Insets comboInsets = comboBox.getInsets();
Icon icon = b.getComboIcon();
Modified: trunk/core/src/classpath/javax/javax/swing/plaf/metal/MetalFileChooserUI.java
===================================================================
--- trunk/core/src/classpath/javax/javax/swing/plaf/metal/MetalFileChooserUI.java 2007-02-04 09:46:03 UTC (rev 3106)
+++ trunk/core/src/classpath/javax/javax/swing/plaf/metal/MetalFileChooserUI.java 2007-02-04 10:20:16 UTC (rev 3107)
@@ -42,6 +42,7 @@
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
+import java.awt.Graphics;
import java.awt.GridLayout;
import java.awt.Insets;
import java.awt.LayoutManager;
@@ -55,7 +56,7 @@
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.io.File;
-import java.util.Date;
+import java.sql.Date;
import java.text.DateFormat;
import java.text.NumberFormat;
import java.util.List;
@@ -303,7 +304,8 @@
if (file == null)
setFileName(null);
- else
+ else if (file.isFile() || filechooser.getFileSelectionMode()
+ != JFileChooser.FILES_ONLY)
setFileName(file.getName());
int index = -1;
index = getModel().indexOf(file);
@@ -439,7 +441,7 @@
filechooser.revalidate();
filechooser.repaint();
}
- };
+ }
/**
* A combo box model containing the selected directory and all its parent
@@ -567,10 +569,17 @@
extends DefaultListCellRenderer
{
/**
+ * This is the icon that is displayed in the combobox. This wraps
+ * the standard icon and adds indendation.
+ */
+ private IndentIcon indentIcon;
+
+ /**
* Creates a new renderer.
*/
public DirectoryComboBoxRenderer(JFileChooser fc)
{
+ indentIcon = new IndentIcon();
}
/**
@@ -586,28 +595,83 @@
* @return The list cell renderer.
*/
public Component getListCellRendererComponent(JList list, Object value,
- int index, boolean isSelected, boolean cellHasFocus)
+ int index,
+ boolean isSelected,
+ boolean cellHasFocus)
{
- FileView fileView = getFileView(getFileChooser());
+ super.getListCellRendererComponent(list, value, index, isSelected,
+ cellHasFocus);
File file = (File) value;
- setIcon(fileView.getIcon(file));
- setText(fileView.getName(file));
+ setText(getFileChooser().getName(file));
- if (isSelected)
+ // Install indented icon.
+ Icon icon = getFileChooser().getIcon(file);
+ indentIcon.setIcon(icon);
+ int depth = directoryModel.getDepth(index);
+ indentIcon.setDepth(depth);
+ setIcon(indentIcon);
+
+ return this;
+ }
+ }
+
+ /**
+ * An icon that wraps another icon and adds indentation.
+ */
+ class IndentIcon
+ implements Icon
{
- setBackground(list.getSelectionBackground());
- setForeground(list.getSelectionForeground());
+
+ /**
+ * The indentation level.
+ */
+ private static final int INDENT = 10;
+
+ /**
+ * The wrapped icon.
+ */
+ private Icon icon;
+
+ /**
+ * The current depth.
+ */
+ private int depth;
+
+ /**
+ * Sets the icon to be wrapped.
+ *
+ * @param i the icon
+ */
+ void setIcon(Icon i)
+ {
+ icon = i;
}
- else
+
+ /**
+ * Sets the indentation depth.
+ *
+ * @param d the depth to set
+ */
+ void setDepth(int d)
{
- setBackground(list.getBackground());
- setForeground(list.getForeground());
+ depth = d;
}
- setEnabled(list.isEnabled());
- setFont(list.getFont());
- return this;
+ public int getIconHeight()
+ {
+ return icon.getIconHeight();
}
+
+ public int getIconWidth()
+ {
+ return icon.getIconWidth() + depth * INDENT;
+ }
+
+ public void paintIcon(Component c, Graphics g, int x, int y)
+ {
+ icon.paintIcon(c, g, x + depth * INDENT, y);
+ }
+
}
/**
@@ -956,9 +1020,12 @@
{
String text = editField.getText();
if (text != null && text != "" && !text.equals(fc.getName(editFile)))
- if (editFile.renameTo(fc.getFileSystemView().createFileObject(
- fc.getCurrentDirectory(), text)))
+ {
+ File f = fc.getFileSystemView().
+ createFileObject(fc.getCurrentDirectory(), text);
+ if ( editFile.renameTo(f) )
rescanCurrentDirectory(fc);
+ }
list.remove(editField);
}
startEditing = false;
@@ -982,17 +1049,8 @@
*/
public void actionPerformed(ActionEvent e)
{
- if (e.getActionCommand().equals("notify-field-accept"))
+ if (editField != null)
completeEditing();
- else if (editField != null)
- {
- list.remove(editField);
- startEditing = false;
- editFile = null;
- lastSelected = null;
- editField = null;
- list.repaint();
- }
}
}
}
@@ -1101,7 +1159,7 @@
lastSelected = selVal;
if (f.isFile())
setFileName(path.substring(path.lastIndexOf("/") + 1));
- else if (fc.getFileSelectionMode() == JFileChooser.DIRECTORIES_ONLY)
+ else if (fc.getFileSelectionMode() != JFileChooser.FILES_ONLY)
setFileName(path);
}
fileTable.repaint();
@@ -1171,16 +1229,8 @@
*/
public void actionPerformed(ActionEvent e)
{
- if (e.getActionCommand().equals("notify-field-accept"))
+ if (editField != null)
completeEditing();
- else if (editField != null)
- {
- table.remove(editField);
- startEditing = false;
- editFile = null;
- editField = null;
- table.repaint();
- }
}
}
Modified: trunk/core/src/classpath/javax/javax/swing/plaf/metal/MetalIconFactory.java
===================================================================
--- trunk/core/src/classpath/javax/javax/swing/plaf/metal/MetalIconFactory.java 2007-02-04 09:46:03 UTC (rev 3106)
+++ trunk/core/src/classpath/javax/javax/swing/plaf/metal/MetalIconFactory.java 2007-02-04 10:20:16 UTC (rev 3107)
@@ -1039,21 +1039,23 @@
g.drawLine(x + 6, y + 14, x, y + 8);
g.drawLine(x, y + 7, x, y + 1);
- // Fill the icon.
- if (MetalLookAndFeel.getCurrentTheme() instanceof OceanTheme
- && enabled)
+// The following is commented out until the masking for the gradient painting
+// is working correctly
+// // Fill the icon.
+// if (MetalLookAndFeel.getCurrentTheme() instanceof OceanTheme
+// && enabled)
+// {
+// String gradient;
+// if (focus)
+// gradient = "Slider.focusGradient";
+// else
+// gradient = "Slider.gradient";
+// MetalUtils.paintGradient(g, x + 1, y + 2, 12, 13,
+// SwingConstants.VERTICAL, gradient,
+// gradientMask);
+// }
+// else
{
- String gradient;
- if (focus)
- gradient = "Slider.focusGradient";
- else
- gradient = "Slider.gradient";
- MetalUtils.paintGradient(g, x + 1, y + 2, 12, 13,
- SwingConstants.VERTICAL, gradient,
- gradientMask);
- }
- else
- {
if (focus)
g.setColor(MetalLookAndFeel.getPrimaryControlShadow());
else
@@ -1700,21 +1702,23 @@
g.drawLine(x + 8, y + 14, x + 1, y + 14);
g.drawLine(x, y + 13, x, y + 1);
- // Fill the icon.
- if (MetalLookAndFeel.getCurrentTheme() instanceof OceanTheme
- && enabled)
+// The following is commented out until the masking for the gradient painting
+// is working correctly
+// // Fill the icon.
+// if (MetalLookAndFeel.getCurrentTheme() instanceof OceanTheme
+// && enabled)
+// {
+// String gradient;
+// if (focus)
+// gradient = "Slider.focusGradient";
+// else
+// gradient = "Slider.gradient";
+// MetalUtils.paintGradient(g, x + 2, y + 1, 13, 12,
+// SwingConstants.HORIZONTAL, gradient,
+// gradientMask);
+// }
+// else
{
- String gradient;
- if (focus)
- gradient = "Slider.focusGradient";
- else
- gradient = "Slider.gradient";
- MetalUtils.paintGradient(g, x + 2, y + 1, 13, 12,
- SwingConstants.HORIZONTAL, gradient,
- gradientMask);
- }
- else
- {
if (focus)
g.setColor(MetalLookAndFeel.getPrimaryControlShadow());
else
Modified: trunk/core/src/classpath/javax/javax/swing/plaf/metal/MetalRadioButtonUI.java
===================================================================
--- trunk/core/src/classpath/javax/javax/swing/plaf/metal/MetalRadioButtonUI.java 2007-02-04 09:46:03 UTC (rev 3106)
+++ trunk/core/src/classpath/javax/javax/swing/plaf/metal/MetalRadioButtonUI.java 2007-02-04 10:20:16 UTC (rev 3107)
@@ -177,7 +177,7 @@
protected void paintFocus(Graphics g, Rectangle t, Dimension d)
{
g.setColor(focusColor);
- g.drawRect(t.x - 1, t.y - 1, t.width + 2, t.height + 2);
+ g.drawRect(t.x - 1, t.y - 1, t.width + 1, t.height + 1);
}
}
Modified: trunk/core/src/classpath/javax/javax/swing/plaf/metal/MetalScrollBarUI.java
===================================================================
--- trunk/core/src/classpath/javax/javax/swing/plaf/metal/MetalScrollBarUI.java 2007-02-04 09:46:03 UTC (rev 3106)
+++ trunk/core/src/classpath/javax/javax/swing/plaf/metal/MetalScrollBarUI.java 2007-02-04 10:20:16 UTC (rev 3107)
@@ -1,5 +1,5 @@
/* MetalScrollBarUI.java
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006, Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -169,6 +169,7 @@
Boolean prop = (Boolean) scrollbar.getClientProperty(FREE_STANDING_PROP);
isFreeStanding = prop == null ? true : prop.booleanValue();
scrollBarShadowColor = UIManager.getColor("ScrollBar.shadow");
+ scrollBarWidth = UIManager.getInt("ScrollBar.width");
super.installDefaults();
}
@@ -187,7 +188,10 @@
/**
* Creates a new button to use as the control at the lower end of the
- * {@link JScrollBar}.
+ * {@link JScrollBar}. This method assigns the new button (an instance of
+ * {@link MetalScrollButton} to the {@link #decreaseButton} field, and also
+ * returns the button. The button width is determined by the
+ * <code>ScrollBar.width</code> setting in the UI defaults.
*
* @param orientation the orientation of the button ({@link #NORTH},
* {@link #SOUTH}, {@link #EAST} or {@link #WEST}).
@@ -196,7 +200,6 @@
*/
protected JButton createDecreaseButton(int orientation)
{
- scrollBarWidth = UIManager.getInt("ScrollBar.width");
decreaseButton = new MetalScrollButton(orientation, scrollBarWidth,
isFreeStanding);
return decreaseButton;
@@ -204,7 +207,10 @@
/**
* Creates a new button to use as the control at the upper end of the
- * {@link JScrollBar}.
+ * {@link JScrollBar}. This method assigns the new button (an instance of
+ * {@link MetalScrollButton} to the {@link #increaseButton} field, and also
+ * returns the button. The button width is determined by the
+ * <code>ScrollBar.width</code> setting in the UI defaults.
*
* @param orientation the orientation of the button ({@link #NORTH},
* {@link #SOUTH}, {@link #EAST} or {@link #WEST}).
@@ -213,7 +219,6 @@
*/
protected JButton createIncreaseButton(int orientation)
{
- scrollBarWidth = UIManager.getInt("ScrollBar.width");
increaseButton = new MetalScrollButton(orientation, scrollBarWidth,
isFreeStanding);
return increaseButton;
Modified: trunk/core/src/classpath/javax/javax/swing/plaf/metal/MetalSliderUI.java
===================================================================
--- trunk/core/src/classpath/javax/javax/swing/plaf/metal/MetalSliderUI.java 2007-02-04 09:46:03 UTC (rev 3106)
+++ trunk/core/src/classpath/javax/javax/swing/plaf/metal/MetalSliderUI.java 2007-02-04 10:20:16 UTC (rev 3107)
@@ -352,7 +352,10 @@
*/
public int getTickLength()
{
- return tickLength + TICK_BUFFER;
+ int len = tickLength + TICK_BUFFER + 1;
+ if (slider.getOrientation() == JSlider.VERTICAL)
+ len += 2;
+ return len;
}
/**
@@ -406,9 +409,9 @@
// Note the incoming 'g' has a translation in place to get us to the
// start of the tick rect already...
if (slider.isEnabled())
- g.setColor(MetalLookAndFeel.getPrimaryControlShadow());
+ g.setColor(slider.getForeground());
else
- g.setColor(MetalLookAndFeel.getControlDisabled());
+ g.setColor(MetalLookAndFeel.getControlShadow());
g.drawLine(x, TICK_BUFFER, x, TICK_BUFFER + tickLength / 2);
}
@@ -425,10 +428,10 @@
// Note the incoming 'g' has a translation in place to get us to the
// start of the tick rect already...
if (slider.isEnabled())
- g.setColor(MetalLookAndFeel.getPrimaryControlShadow());
+ g.setColor(slider.getForeground());
else
- g.setColor(MetalLookAndFeel.getControlDisabled());
- g.drawLine(x, TICK_BUFFER, x, TICK_BUFFER + tickLength);
+ g.setColor(MetalLookAndFeel.getControlShadow());
+ g.drawLine(x, TICK_BUFFER, x, TICK_BUFFER + tickLength - 1);
}
/**
@@ -444,10 +447,10 @@
// Note the incoming 'g' has a translation in place to get us to the
// start of the tick rect already...
if (slider.isEnabled())
- g.setColor(MetalLookAndFeel.getPrimaryControlShadow());
+ g.setColor(slider.getForeground());
else
- g.setColor(MetalLookAndFeel.getControlDisabled());
- g.drawLine(TICK_BUFFER - 1, y, TICK_BUFFER - 1 + tickLength / 2, y);
+ g.setColor(MetalLookAndFeel.getControlShadow());
+ g.drawLine(TICK_BUFFER, y, TICK_BUFFER + tickLength / 2, y);
}
/**
@@ -463,10 +466,10 @@
// Note the incoming 'g' has a translation in place to get us to the
// start of the tick rect already...
if (slider.isEnabled())
- g.setColor(MetalLookAndFeel.getPrimaryControlShadow());
+ g.setColor(slider.getForeground());
else
- g.setColor(MetalLookAndFeel.getControlDisabled());
- g.drawLine(TICK_BUFFER - 1, y, TICK_BUFFER - 1 + tickLength, y);
+ g.setColor(MetalLookAndFeel.getControlShadow());
+ g.drawLine(TICK_BUFFER, y, TICK_BUFFER + tickLength, y);
}
}
Modified: trunk/core/src/classpath/javax/javax/swing/plaf/metal/MetalUtils.java
===================================================================
--- trunk/core/src/classpath/javax/javax/swing/plaf/metal/MetalUtils.java 2007-02-04 09:46:03 UTC (rev 3106)
+++ trunk/core/src/classpath/javax/javax/swing/plaf/metal/MetalUtils.java 2007-02-04 10:20:16 UTC (rev 3107)
@@ -41,6 +41,7 @@
import java.awt.Color;
import java.awt.Component;
+import java.awt.GradientPaint;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.TexturePaint;
@@ -108,7 +109,7 @@
for (int mX = x + xOff; mX < (x + w); mX += 4)
{
- g.drawLine(mX, mY, mX, mY);
+ g.fillRect(mX, mY, 1, 1);
}
// increase x offset
@@ -341,7 +342,7 @@
y0 = mask[xc - x0][0] + y;
y1 = mask[xc - x0][1] + y;
}
- g.drawLine(xc, y0, xc, y1);
+ g.fillRect(xc, y0, 1, y1 - y0);
}
// Paint solid c2 area.
g.setColor(c2);
@@ -355,7 +356,7 @@
{
y0 = mask[xc - x0][0] + y;
y1 = mask[xc - x0][1] + y;
- g.drawLine(xc, y0, xc, y1);
+ g.fillRect(xc, y0, 1, y1 - y0);
}
}
@@ -379,7 +380,7 @@
y0 = mask[xc - x0][0] + y;
y1 = mask[xc - x0][1] + y;
}
- g.drawLine(xc, y0, xc, y1);
+ g.fillRect(xc, y0, 1, y1 - y0);
}
// Paint third gradient area (c1->c3).
@@ -423,7 +424,7 @@
* described above
*/
static void paintVerticalGradient(Graphics g, int x, int y, int w, int h,
- double g1, double g2, Color c1, Color c2,
+ float g1, float g2, Color c1, Color c2,
Color c3, int[][] mask)
{
// Calculate the coordinates.
@@ -460,7 +461,7 @@
x0 = mask[yc - y0][0] + x;
x1 = mask[yc - y0][1] + x;
}
- g.drawLine(x0, yc, x1, yc);
+ g.fillRect(x0, yc, x1 - x0, 1);
}
// Paint solid c2 area.
g.setColor(c2);
@@ -474,7 +475,7 @@
{
x0 = mask[yc - y0][0] + x;
x1 = mask[yc - y0][1] + x;
- g.drawLine(x0, yc, x1, yc);
+ g.fillRect(x0, yc, x1 - x0, 1);
}
}
@@ -498,7 +499,7 @@
x0 = mask[yc - y0][0] + x;
x1 = mask[yc - y0][1] + x;
}
- g.drawLine(x0, yc, x1, yc);
+ g.fillRect(x0, yc, x1 - x0, 1);
}
// Paint third gradient area (c1->c3).
@@ -521,7 +522,61 @@
x0 = mask[yc - y0][0] + x;
x1 = mask[yc - y0][1] + x;
}
- g.drawLine(x0, yc, x1, yc);
+ g.fillRect(x0, yc, x1 - x0, 1);
}
}
+
+ /**
+ * Paints a horizontal gradient using Graphics2D functionality.
+ *
+ * @param g the Graphics2D instance
+ * @param x the X coordinate of the upper left corner of the rectangle
+ * @param y the Y coordinate of the upper left corner of the rectangle
+ * @param w the width of the rectangle
+ * @param h the height of the rectangle
+ * @param g1 the relative width of the c1->c2 gradients
+ * @param g2 the relative width of the c2 solid area
+ * @param c1 the color 1
+ * @param c2 the color 2
+ * @param c3 the color 3
+ * @param mask the mask that should be used when painting the gradient as
+ * described above
+ */
+ private static void paintHorizontalGradient2D(Graphics2D g, int x, int y,
+ int w, int h, float g1,
+ float g2, Color c1,
+ Color c2, Color c3,
+ int[][] mask)
+ {
+ // FIXME: Handle the mask somehow, or do Graphics2D clipping instead.
+ GradientPaint p1 = new GradientPaint(x, y, c1, x + w * g1, y, c2);
+ g.setPaint(p1);
+ // This fills the first gradient and the solid area in one go.
+ g.fillRect(x, y, (int) (w * (g1 + g2)), h);
+
+ GradientPaint p2 = new GradientPaint(x + (w * (g1 + g2)), y, c2, x + w, y,
+ c3);
+ g.setPaint(p2);
+ g.fillRect((int) (x + (w * (g1 + g2))), y,
+ (int) (w * (1. - (g1 + g2))), h);
}
+
+ private static void paintVerticalGradient2D(Graphics2D g, int x, int y,
+ int w, int h, float g1,
+ float g2, Color c1,
+ Color c2, Color c3,
+ int[][] mask)
+ {
+ // FIXME: Handle the mask somehow, or do Graphics2D clipping instead.
+ GradientPaint p1 = new GradientPaint(x, y, c1, x, y + h * g1, c2);
+ g.setPaint(p1);
+ // This fills the first gradient and the solid area in one go.
+ g.fillRect(x, y, w, (int) (h * (g1 + g2)));
+
+ GradientPaint p2 = new GradientPaint(x, y + (h * (g1 + g2)), c2, x, y + h,
+ c3);
+ g.setPaint(p2);
+ g.fillRect(x, (int) (y + (h * (g1 + g2))), w,
+ (int) (h * (1. - (g1 + g2))));
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|